User:.jun/common.js

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

/** * chatconnect.js * based on the one by ozuzanna * * features * - lists all accounts under an IP * -- the IP is the one with which they last they connected to chat * - maintains and auto-refreshes the original list * * todo: accounts with accents in the name are not listed */ $(function {   var regex = {        timestamp: /^[0-2]?[0-9]?:[0-5]?[0-9]?, [A-Z]+[a-z]{2,8} [0-3]?[0-9]?, \d{4,}/g,        ip: /(?:\d{1,3}\.){3}\d{1,3}/    },        title = document.title;    function getDupes(doc) {        doc = doc || window.document;        var list = {}, modified = {};        var keys = [], dupes = {};        $(doc).find('.mw-logline-chatconnect').each(function(i) { var s = seconds($(this).text.match(regex.timestamp)[0]), a = 0; while (!a) { if (list[s]) { s = s + 1; } else { a++; }           }            list[s] = $(this).text + '[]' + $(this).find('.mw-userlink').text; });       function seconds(date) {            date = date.split(', ');            return Date.UTC(date[2], mw.config.get('wgMonthNames').indexOf(date[1].split(' ')[0] - 1), date[1].split(' ')[1], date[0].split(':')[0], date[0].split(':')[1], 0);        }        keys = Object.keys(list).sort;        for (var i = 0; i < keys.length; i++) {            var name = list[keys[i]].split('[]')[1];            modified[name] = list[keys[i]];        }        for (i in modified) {            var iname = modified[i].split('[]')[1],                iaddress = modified[i].match(regex.ip)[0];            dupes[iaddress] = [];            for (var j in modified) {                var jname = modified[j].split('[]')[1],                    jaddress = modified[j].match(regex.ip)[0];                if (iaddress == jaddress && iname !== jname) {                    dupes[iaddress].push(modified[i], modified[j]); delete modified[j]; }           }            if (!dupes[iaddress].length) { delete dupes[iaddress]; }       }        html(dupes, doc); setTimeout(function {           $('#loading').show;            $('#chat-connect').load(window.location.pathname + window.location.search + ' #mw-content-text > ul > li', function(data) { $('#loading').hide; getDupes(data); });       }, 30000);    }    function html(dupes, doc) { document.title = '(' + Object.keys(dupes).length + ') ' + title; $('#dupe-count').text(Object.keys(dupes).length); var str = ''; for (var i in dupes) { str += '' + i + ''; }       $('#dupeIPs').html(str); $('#dupeIPs > li').each(function {           var arr = [];            $.each(dupes[$(this).text], function(a, b) { if ($.inArray(b, arr) == -1) { arr.push(b); }           });            var str = '';            for (i = 0; i < arr.length; i++) {                var user = arr[i].split('[]')[1];                str += '' + arr[i].match(regex.timestamp)[0] + ' ' + user + ' (wall | contribs | check)';            }            str += '';            $(this).append(str);        }); }   function init { $('.header-title > h1').append(''); $('#mw-content-text > ul').attr('id', 'chat-connect'); $('#mw-content-text > ul').before(' Breakdown A total of 0 duplicate IP entries were found. </ul> Chat connection log '); getDupes; }   if (mw.config.get('wgPageName') == 'Special:Log/chatconnect') { init; } });