Advertisement
falling1

egedraw onchat

Nov 13th, 2022 (edited)
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // example: onchat(function(m) {console.log(m)});
  2. chatevents = [];
  3. funcstr = onmes.toString();
  4. funcstr = funcstr.replaceAll('var dv = document.createElement("div");', 'if(parsed.type != \'userjoin\' && parsed.type != \'userinfoupdate\') chatevents.forEach(func => func(parsed)); var dv = document.createElement("div");');
  5. eval(funcstr);
  6. function onchat(call) {
  7.     if (typeof call != "function") throw "Callback is not a function";
  8.     chatevents.push(call);
  9. };
  10. function offchat(call) {
  11.     while(true) {
  12.         const i = chatevents.indexOf(call);
  13.         if (i == -1) break;
  14.         chatevents.splice(i, 1);
  15.     };
  16. };
  17.  
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement