User:.jun/common.js

importScriptURI('http://monchbox.wikia.com/wiki/User:Monchoman45/monobook.js?action=raw&ctype=text/javascript&templates=expand&debug=true');

window.localStorage.setItem('torus-pings', '{"#global":{"enabled":true,"alert":"Activity!","interval":500,"beep":true,"sound":"http://images.wikia.com/monchbox/images/0/01/Beep-sound.ogg","regex":[],"literal":[]},"community":{"enabled":true,"alert":"Activity!","interval":500,"beep":true,"sound":"http://images.wikia.com/monchbox/images/0/01/Beep-sound.ogg","regex":["/slyst/gi", "/mod(|s)\\b/gi", "/[A-Z]{10,}/g"],"literal":[]}}');

/* chat connect - vanilla version */ var chatconnect = { regex: { timestamp: /[0-2]{1}\d{1}:[0-5]{1}\d{1}, \w* \d{1,2}, \d{4}/gi, ip: /(?:\d{1,3}\.){3}\d{1,3}/gi },       title: document.title, add: function(doc) { var doc = doc || document, list = doc.getElementsByClassName('mw-logline-chatconnect'); Array.prototype.forEach.call(list, function(item, i) {               list[i].innerHTML = list[i].innerHTML.replace(chatconnect.regex.timestamp, function(match) { return ' ' + match + ' '; }).replace(chatconnect.regex.ip, function(match) { return ' ' + match + ' '; });           });        },        get: function(doc) { var doc = doc || document; this.add(doc); var list = {}, logs = doc.getElementsByClassName('mw-logline-chatconnect'), rev = [].slice.call(logs, 0).reverse; Array.prototype.forEach.call(rev, function(item) {               list[item.children[1].innerText] = {                    timestamp: item.children[0].innerText,                    ip: item.children[4].innerText                };            }); return list; },       process: function(list) { var dupes = {}; for (var i in list) { for (var j in list) { if (i !== j && list[i].ip == list[j].ip) { var ip = list[i].ip; if (typeof dupes[ip] == 'undefined') { dupes[ip] = {}; dupes[ip][i] = list[i].timestamp; }                       dupes[ip][j] = list[j].timestamp; delete list[j]; }               }            }            return dupes; },       generate: function(dupes) { require(['wikia.nirvana'], function(nirvana) {               nirvana.sendRequest({ controller: 'ChatRail', type: 'GET', method: 'executeGetUsers', callback: function(data) { var inchat = []; for (var i in data.users) { inchat.push(data.users[i].username); }                       var html = ' '; for (var i in dupes) { html += '' + i + ' (whois)'; for (var j in dupes[i]) { html += '' + dupes[i][j] + ' ' + j + ' (wall | contribs | check | bans | blocks</a>)</li>'; }                           html += '</ul></li>'; }                       html += '</ul>'; if (!document.getElementById('chat-connect')) { document.querySelectorAll('#mw-content-text > ul')[0].insertAdjacentHTML('beforebegin', ' Breakdown A total of 0 duplicate IP entries were found. </ul> Chat connection log '); }                       document.getElementById('dupe-count').textContent = Object.keys(dupes).length; document.getElementById('dupes').outerHTML = html; document.title = '[' + Object.keys(dupes).length + '] | ' + chatconnect.title; setTimeout(chatconnect.update, 30000); }               });            });        },        update: function { var xhr = new XMLHttpRequest; xhr.open('GET', window.location.pathname, true); xhr.onload = function { if (xhr.status == 200) { var doc = (function(str) {                       var temp = document.implementation.createHTMLDocument;                        temp.body.innerHTML = str;                        return temp;                    })(xhr.responseText); chatconnect.generate(chatconnect.process(chatconnect.get(doc))); }           };            xhr.send; },       init: function { this.generate(this.process(this.get)); }   };    if (mw.config.get('wgTitle') == 'Log/chatconnect') { chatconnect.init; } });
 * (function {