Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // example: onchat(function(m) {console.log(m)});
- chatevents = [];
- funcstr = onmes.toString();
- 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");');
- eval(funcstr);
- function onchat(call) {
- if (typeof call != "function") throw "Callback is not a function";
- chatevents.push(call);
- };
- function offchat(call) {
- while(true) {
- const i = chatevents.indexOf(call);
- if (i == -1) break;
- chatevents.splice(i, 1);
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement