User:Miss Undyne The Undead (Yarana Rouja)/chat.js

/* Pings */ var PING_LIST = [ "Yarana", "Yaran", "Mitsuki", "Undyne" ]; var afterChat = function (chat) { var t = chat.attributes.text, n = chat.attributes.name, isInline = chat.attributes.isInlineAlert || false, context = mainRoom.viewDiscussion.chatUL.children.last; if (new RegExp(PING_LIST.join('|'), 'mi').test(t) && n != mw.config.get('wgUserName') && !isInline) { $(' ', {           id: 'ping',            src: 'http://vignette2.wikia.nocookie.net/smoky/images/6/61/Smallbells_v41xnr93.ogg ',            autoplay: true        }).appendTo('body'); // Display desktop notifications. if (Notification.permission === 'granted') { new Notification(n + " mentioned you!", {               body: t,                icon: context.children('.avatar').attr('src').slice(0, -2) + '150'            }); }       // Change the look of the triggered message. context.children('.message').wrap(''); }   var chatMain = mainRoom.viewDiscussion.chatDiv[0]; if (chatMain.scrollHeight - chatMain.scrollTop - chatMain.clientHeight > 150) return; mainRoom.viewDiscussion.scrollToBottom; }; // Fix "mainRoom is not defined" // Thanks to Akri for this var binded = false; var interval = setInterval(function {   if (window.mainRoom && !binded) {        Notification.requestPermission;        mainRoom.model.chats.bind('afteradd', afterChat);        binded = true;        clearInterval(interval);    } }, 250);