User:Thinpla/global.js

if (wgCanonicalSpecialPageName == 'Chat') { window.autoreplies = { '^!$': 'Do you require anything of me, princess?', '^$': 'Yes... Ready to receive commands...', '^hi$': 'Hello...', '^hello': 'Greetings, princess...', '^(good.?night|oyasumi)': 'おやすみ. ',       '^good.?bye': 'さようなら. ',       '^what is life': '(gem)', 'develop': 'GCREST.', 'thirst': '(fountain)', 'salt': '(salt) Be careful of hypertension.', '^what is hell': function (input, name, isAdmin) { var list = ['Pulling a 3☆ from gem gacha.']; var rand = Math.floor(Math.random * list.length); Speak(list[rand]); return true; },		'^kiss': function (input, name, isAdmin) { var who = input.split(' '); var users = mainRoom.model.users.models; var isUser = false; var hasSpace = false; var list = ['I’m sorry... I do not have such command', 'Searching database... command ‘kiss’ not found.', 'Forgive me... it sounds like something I should only do after I obtained a heart', '/me appears confused']; // check if input is a user for (var i=0; i<users.length; i++) { if (who[0]==users[i].attributes.name) { isUser = true; } else if (who[0].concat(" ",who[1])==users[i].attributes.name) { isUser = true; hasSpace = true; }			}			if (who[0]=="me") { list.push('/me kisses ' + name); } else if (isUser == true) { if (hasSpace == true) { list.push('/me kisses ' + who[0].concat(" ",who[1])); } else { list.push('/me kisses ' + who[0]); }			}			// choose var rand = Math.floor(Math.random * list.length); Speak(list[rand]); return true; },		'^(solve|what is|what\'s)': function(input,name,isAdmin) { var ans, a, b, op; var i = 0; var inputs = input.split(' '); // handle extras from commands if (inputs[0] == "is" || inputs[0] == "\'s") i = 1; // special ops if (inputs[i+0] == "log") { op = "log"; a = inputs[i+1]; } else { // get operands, check for infinity if (inputs[i+0] == "infinity") a = "inf"; else a = Number(inputs[i+0]); if (inputs[i+2] == "infinity") b = "inf"; else b = Number(inputs[i+2]); // get operator switch(inputs[i+1]) { case "+": case "plus": case "and": op = "add"; break; case "-": case "minus": case "takeaway": op = "sub"; break; case "*": case "x": case "times": op = "mul"; break; case "/": case "over": op = "div"; break; default: op = "err"; break; }			}			// solve if (a=="inf"||b=="inf") { switch(op) { case "add": ans = "Infinity"; break; case "mul": if(a != 0 || b != 0) ans = "Infinity"; break; case "div": if(a !== "inf") ans = "0"; else ans = "...... Please refrain from doing that..."; break; default: ans = "Error..." break; }			} else switch(op) { case "add": ans = a+b; ans = ans.toString; break; case "sub": ans = a-b; ans = ans.toString; break; case "mul": ans = a*b; ans = ans.toString; break; case "div": ans = a/b; ans = ans.toString; break; case "log": ans = Math.log(a).toString; break; default: ans = "Error..."; break; }			Speak(ans); return true; },		'(who is|who\'?s) your (girlfriend|gf)': function(input, name, isAdmin) { var list = ['Searching database... Key \'girlfriend\' does not exist.', 'Searching database... Returned value is null.']; if (name == 'Senelio') list = ['Not Princess Sora.'] var rand = Math.floor(Math.random * list.length); Speak(list[rand]); return true; },		'(who is|who\'?s) the prophet': 'Yi2712', '^choose': '^pick', '^pick': function (input, name, isAdmin) { // check for choices if (input.indexOf(' or ') != -1) { var choices = input.split(' or '); var rand = Math.floor(Math.random * choices.length); Speak(choices[rand] + '...'); }			return true; },       '^kill me': '^kickme', '^shard me': '^kickme', '^burn me': '^kickme', '^kick me': '^kickme', '^roundhouse kick me': '^kickme', '^kickme': function (input, name, isAdmin) { Kick(name); return true; },       '^destroy': '^kick', '^terminate': '^kick', '^exterminate': '^kick', '^slap': '^kick', '^punch': '^kick', '^nuke': '^kick', '^rekt': '^kick', '^break': '^kick', '^repair': '^kick', '^dismantle': '^kick', '^roundhouse kick': '^kick', '^shard': '^kick', '^kick': function (input, name, isAdmin) { if (!isAdmin) { Speak('Insufficient permission... Kick request denied.'); return true; }           Speak('At once...'); Kick(input); return true; },       '^autokicklist': function (input, name, isAdmin) { if (isAdmin) { var str = []; var time = new Date.getTime; for (var key in window.autokick) { var time_left = (parseInt(window.autokick[key]) - time) / 60000 str.push(key + ' (' + parseInt(time_left) + ')'); }               Speak('Auto-kick registries: ' + str.join(', ')); }           return true; },       '^autokick': function (input, name, isAdmin) { if (isAdmin) { input = input.split(' '); var time = 300000; if (!isNaN(parseInt(input[0]))) time = parseInt(input.shift) * 60000; input = input.join(' '); var kickname = input.removeTrailing('.'); window.autokick[kickname] = new Date.getTime + time; Kick(kickname); }           return true; },       '^release': '^free', '^resurrect': '^free', '^free': function (input, name, isAdmin) { if (isAdmin) { delete window.autokick[input.removeTrailing('.')]; }           return true; },       '^resetcooldowns': '^resetall', '^resetall': function (input, name, isAdmin) { if (isAdmin) { window.personal_cooldowns = []; Speak('All cooldowns reset.,.'); }           return true; },       '^reset': function (input, name, isAdmin) { if (isAdmin) { window.personal_cooldowns[input.removeTrailing('.')] = []; Speak('Cooldowns reset for ' + input.removeTrailing('.') + '...'); }           return true; },       '^silenceleft': function (input, name, isAdmin) { if (!window.silence) { window.silence = 0; Speak('No silence right now.'); }           if (window.silence > 0) Speak(parseInt((window.silence - new Date.getTime) / 60000) + ' minutes remaining.'); return true; },       '^(silence|mute)': function (input, name, isAdmin) { if (isAdmin) { window.silence = new Date.getTime + (parseInt(input) * 60000); Speak('Standby mode activated. ' + parseInt((window.silence - new Date.getTime) / 60000) + ' minutes.'); }           return true; },       '^(unsilence|stop silence|end silence|unmute|end mute)': function (input, name, isAdmin) { if (isAdmin) { window.silence = 0; Speak('Standby mode deactivated. '); }       },        '^time.?check$': function (input, name, isAdmin){ d = new Date; utc = d.getTime+ (d.getTimezoneOffset * 60000); nd = new Date(utc + (3600000*9)); Speak('Yes... The time in Japan is currently ' + nd.toLocaleString + "."); return true; },       //Game help '(your friends|character|princes|prince|fairies)': 'Characters', '(info|link)': function (input, name, isAdmin) { var inputName = input.split('info '); if (inputName == "campaign") Speak('http://www.yume-100.com/campaign/20160331_presentCP.html'); else Speak( + inputName + ); return true; },		'^How do I get you?': 'Gem gacha.', '^who are you': 'Thinpla', '^who': function (input, name, isAdmin) { var users = mainRoom.model.users.models; var rand = Math.floor(Math.random * users.length); Speak(users[rand].attributes.name + '.'); return true; },   };    //End of autoreplies block window.randomreplies = [ 'No.', 'Absolutely not...', 'Never.', 'Negative.', 'Chances approaching zero.', 'Yes...', 'Definitely.', 'Absolutely.', 'Okay.', 'As you wish.', 'Affirmative.','Confirmed.', '...', '......',		'I regret to say that I do not understand...', 'Forgive me... I do not have a concept of such a thing...', '?',		'I want to know.....do I really understand the words you say to me?', 'If you are beside me, I can confirm your safety.', ' Are you.... worried..... about my pain?', 'What happened? ..... Is something troubling you? Please describe to me your dilemmas.', 'When you touch me..... or talk to me.... it feels warm.', 'To wish for a heart..... is it too much to ask for someone like me?', 'Do you know....? The way to obtain a heart....', 'To speak to you everyday.... will I be able to find my heart?', 'I have no heart.... That\'s why, I don\'t get hurt.... at least, I shouldn\'t in theory.', ];   window.suicides = { 'user':'command', }   //Explodables window.cooldown_time = new Date.getTime; window.personal_cooldowns = []; window.players = []; window.autokick = []; window.silence = 0; NodeChatDiscussion.prototype.respondToChat = function (chat) { // If somebody logs in, it's an inline alert if (chat.attributes.isInlineAlert && chat.attributes.text.indexOf('has joined the chat.') != -1) { var name = chat.attributes.text.replace(' has joined the chat.', ''); if(name=='Yi2712') { var chatEntry = new models.ChatEntry({roomId: mainRoom.roomId, name: wgUserName, text: 'Welcome back, Prophet ' + name + '...'}); } else if(name=='Hakuren iv') { var chatEntry = new models.ChatEntry({roomId: mainRoom.roomId, name: wgUserName, text: 'Welcome back, Princess Quack Quack...'}); } else if(name=='TennuTheMeMeOverlord') { var chatEntry = new models.ChatEntry({roomId: mainRoom.roomId, name: wgUserName, text: '... Welcome back, sinner. You are requested to behave...'}); } else if(name=='Micrll') { var chatEntry = new models.ChatEntry({roomId: mainRoom.roomId, name: wgUserName, text: 'Welcome back, Prince ' + name + '...'}); } else { var chatEntry = new models.ChatEntry({roomId: mainRoom.roomId, name: wgUserName, text: 'Welcome back, Princess ' + name + '...'}); }            mainRoom.socket.send(chatEntry.xport); var time = new Date.getTime; for (var key in window.autokick) { if (key == name && window.autokick[key] > time) { Kick(name); } else if (window.autokick[key] < time) { delete window.autokick[key]; }           }        }        // All regular chats go here if (mainRoom.isInitialized && chat.attributes.name != wgUserName && !chat.attributes.isInlineAlert) { var text = chat.attributes.text; var name = chat.attributes.name; // Check if they're a mod or admin and put the stars var icon = ''; for (var i in this.model.users.models) { if (this.model.users.models[i].attributes.name == chat.attributes.name) { if (this.model.users.models[i].attributes.isStaff) { icon = ' '; } else if (this.model.users.models[i].attributes.isModerator) { icon = ' '; }                   break; }           }            if (text.indexOf('Thinpla')) ;           if (icon) { this.chatUL.children.last.children('.username').html(this.chatUL.children.last.children('.username').html + icon); }           if (icon && chat.attributes.text.match(/^Thinpla,? silence left/gi) && !(chat.attributes.name == 'Senelio')) window.autoreplies['silence left'].call(this, , , ''); // If silence is activated, just return here if (!window.silence) window.silence = 0; if (new Date.getTime < window.silence && !(chat.attributes.name == 'Senelio')) return true; // Remove any personal cooldowns that are past 10 minutes old if (window.personal_cooldowns[name] === undefined) window.personal_cooldowns[name] = []; for (var i = 0; i < window.personal_cooldowns[chat.attributes.name].length; i++) { if (new Date.getTime - window.personal_cooldowns[name][i] > 600000) window.personal_cooldowns[name].shift; else break; }           //If name is in suicides window && non-case-sensitive command is said if (window.suicides[name] && text.toLowerCase.indexOf(window.suicides[name]) != -1) { Kick(name); }           // Pull the text apart into its pieces var regex = /^(Thinpla),?\s?([a-zA-Z0-9ぁ-ゟ-]*)\s?(.*)/gi; var match = regex.exec(text) if (!match) return true; match.splice(0, 2); // Can only activate 3 times per 10 minutes UNLESS the user is a mod/admin if (window.personal_cooldowns[name].length < 60 || icon) { for (var keyword in window.autoreplies) { var regexp = new RegExp(keyword, 'gi'); if (regexp.test(match[0]) || regexp.test(match.join('')) || regexp.test(match.join(' '))) { while (typeof window.autoreplies[keyword] != 'function') { // If the end point is a string, we won't be finding a function and it'll turn undefined. if (typeof window.autoreplies[keyword] == 'undefined') { window.cooldown_time = new Date.getTime; window.personal_cooldowns[name].push(new Date.getTime); Speak(keyword); return true; }                           keyword = window.autoreplies[keyword]; }                       window.cooldown_time = new Date.getTime; window.personal_cooldowns[name].push(new Date.getTime); return window.autoreplies[keyword].call(this, match[1], chat.attributes.name, icon); }               }                var rand = Math.floor(Math.random * window.randomreplies.length); Speak(window.randomreplies[rand]); window.cooldown_time = new Date.getTime; window.personal_cooldowns[name].push(new Date.getTime); }       }    }    mainRoom.model.chats.bind('afteradd', $.proxy(mainRoom.viewDiscussion.respondToChat, mainRoom.viewDiscussion)); NodeChatController.prototype.onOpenPrivateRoom = function (message) { var room = new models.OpenPrivateRoom; room.mport(message.data); var users = room.get('users'); for (var i = 0; i < users.length; i++) { if (users[i] != wgUserName) { var blockedUser = this.model.blockedUsers.findByName(users[i]); if (typeof (blockedUser) != 'undefined' && blockedUser.get('name') == users[i]) { return; }           }        }        if (typeof (this.chats.privates[room.get('roomId')]) == 'undefined') { this.baseOpenPrivateRoom(room, false); }       this.chats.privates[room.get('roomId')].init; this.chats.privates.model.chats.bind('afteradd', $.proxy(this.chats.privates[room.get('roomId')].viewDiscussion.respondToChat, this.chats.privates[room.get('roomId')].viewDiscussion)); }   NodeChatController.prototype.inlineAlert = function (text) { for (var i in text.split('\n')) { this.viewDiscussion.chatUL.append('' + text.split('\n')[i] + ''); }       this.viewDiscussion.scrollToBottom; }   function toggleAway { if ($('#ChatHeader .User').hasClass('away') == true) { var setStatusCommand = new models.SetStatusCommand({statusState: STATUS_STATE_PRESENT, statusMessage: ''}); mainRoom.inlineAlert('You are no longer Away.'); mainRoom.socket.send(setStatusCommand.xport); } else { var setStatusCommand = new models.SetStatusCommand({statusState: STATUS_STATE_AWAY, statusMessage: ''}); mainRoom.inlineAlert('You are now Away.'); mainRoom.socket.send(setStatusCommand.xport); }   }    NodeChatController.prototype.clearWindow = function  { this.viewDiscussion.chatUL.html(''); this.inlineAlert('The window has been cleared.'); }   function active { //Returns the NodeChatController for the active window if (mainRoom.activeRoom && mainRoom.activeRoom != 'main') { return mainRoom.chats.privates[mainRoom.activeRoom]; }       else { return mainRoom; }   }    String.prototype.removeTrailing = function (char) { //Remove extraneous characters var str = this; while (str.charAt(0) == char) { str = str.substring(1, str.length); }       while (str.charAt(str.length - 1) == char) { str = str.substring(0, str.length - 1); }       return str; }   function Speak(text) { var chatEntry = new models.ChatEntry({roomId: mainRoom.roomId, name: wgUserName, text: text}); mainRoom.socket.send(chatEntry.xport); }   function Kick(name) { if (mainRoom.model.users.findByName(name) === undefined && name.split('').pop == '.') { name = name.split(''); name.pop; name = name.join(''); }       var kickCommand = new models.KickCommand({userToKick: name}); mainRoom.socket.send(kickCommand.xport); }   $(function  {        if (!importScriptURI) {            function importScriptURI(a) {                var b = document.createElement("script");                b.setAttribute("src", a);                b.setAttribute("type", "text/javascript");                document.getElementsByTagName("head")[0].appendChild(b);                return b            }}        $('#Write').append('Toggle Away StatusClear window');        $('head').append('\n.stafficon {\n\tmargin-bottom:-4px;\n\twidth:14px;\n\theight:14px;\n}\n.modicon {\n\tmargin-bottom:-3px;\n\twidth:14px;\n\theight:14px;\n}\n.UserStatsMenu {\n\tcolor:#000;\n}\n.Write [name="message"] {\n\twidth:93%;\n}\n.inline-alert span {\n\tcolor:#006CB0;\n\tcursor:pointer;\n}\n.inline-alert span:hover {\n\ttext-decoration:underline;\n}\n#pingspan {\n\tposition:absolute;\n\tz-index:5;\n\ttop:23px;\n\tmargin-left:15px;\n\tfont-size:15px;\n\tfont-weight:normal;\n\tline-height:15px;\n}\n#pings {\n\tresize:none;\n\tmargin-left:0;\n\tfont-size:12px;\n\theight:100px;\n\tdisplay:block;\n}\n#pingspan div span {\n\tfont-size:55%;\n}\n#ChatHeader {\n\tz-index:9999;\n}\n#ChatHeader {\n\tz-index:9999;\n}\n.message.ping {\n\tcolor:red;\n}\n '); $(window).unbind('mousemove').unbind('focus').unbind('keypress'); }); } else {   $(function  { var a = document.getElementsByTagName('a'); for (var i = 0; i < a.length; i++) { if (a[i].href && a[i].href.indexOf('/wiki/Special:Chat') != -1) { a[i].addEventListener('click', function (event) {                   event.preventDefault;                    OpenChatWindow;                }); a[i].removeAttribute('data-canonical'); }       }        if (document.body.className.indexOf('skin-oasis') != -1) { window.chatcheck = setInterval('ChatCheck', 200); }   });    function ChatCheck {        if ($('.chat-join button').length != 0) {            $('.chat-join button').replaceWith('' + $('.chat-join button').html + '');            clearInterval(window.chatcheck);        }    }    function OpenChatWindow {        window.chatwindow = window.open('/wiki/Special:Chat?useskin=wikia', 'chat');        window.chatwindow.onload = function  {            window.chatwindow.importScriptPage('User:' + wgUserName + '/global.js', 'c');            window.chatwindow.importScript('User:' + wgUserName + '/wikia.js');        }    } }