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 */ $(function {   function getDupes(doc) {        doc = doc || window.document;        var list = {}, modified = {};        var keys = [], dupes = {};        $(doc).find('.mw-logline-chatconnect').each(function(i) { var s = $(this).text.match(/^[0-2]?[0-9]?:[0-5]?[0-9]?, [A-Z]+[a-z]{2,8} [0-3]?[0-9]?, \d{4,}/g)[0]; if (list[s]) { s = s + 1; }           list[seconds(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(/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])/g)[0];            dupes[iaddress] = [];            for (var j in modified) {                var jname = modified[j].split('[]')[1],                    jaddress = modified[j].match(/(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])/g)[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) { $('#mw-content-text .breakdown').html($('#mw-content-text .breakdown').text.replace(/\$1/g, 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(/^[0-2]?[0-9]?:[0-5]?[0-9]?, [A-Z]+[a-z]{2,8} [0-3]?[0-9]?, \d{4,}/g)[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 $1 duplicate IP entries were found. </ul> Chat connection log '); getDupes; }   if (mw.config.get('wgPageName') == 'Special:Log/chatconnect') { init; } });