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];            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[dupes.length] = [modified[i], modified[j]]; delete modified[i]; delete modified[j]; }           }        }        html(dupes, doc); setTimeout(function {           $('#loading').show;            $('#chat-connect').load(window.location.pathname + ' #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, dupes.length)); var str = ''; for (var i = 0; i < dupes.length; i++) { var IP = dupes[i][0].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]; str += '' + IP + ''; }       $('#dupeIPs').html(str); $('#dupeIPs > li').each(function {           var str = '';            for (i = 0; i < dupes[$(this).data('id')].length; i++) {                var user = dupes[$(this).data('id')][i].split('[]')[1];                str += '' + dupes[$(this).data('id')][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; } });