User:2Actimv/wikia.js

/* advancedChatconnectRevisionDelete = true; mw.loader.using(['mediawiki.util', 'mediawiki.api'], function { if (mw.config.get('wgPageName') == "Special:Log/chatconnect") {	$('#mw-content-text p:first').append(' Advanced chat connection log');	return; } else if (mw.config.get('wgCanonicalSpecialPageName') != "Blankpage" || $.getUrlVar('blankspecial') != "advancedchatconnect") 	return; var API = new mw.Api, articlePath = mw.config.get('wgArticlePath').slice(0,-2), listLoader, lastOffset, formHTML = '\  \	 \		 Advanced Chatconnect \		Limit: \		 \		User:  \		 \		 \		Year (and earlier):  \		 \ Month (and earlier): \  \ all \ January \ February \ March \ April \ May \ June \ July \ August \ September \ October \ November \ December \ \		 \		Auto-refresh: \  \ \		Older: \  \ \		 Go \ \ ', regex = window.advancedChatconnectRevisionDelete ? /^((?:\S+\s+){7}\S+)\s+(.+)/ : /^((?:\S+\s+){3}\S+)\s+(.+)/, //Conditional regex depending on if revision delete links are present normalTitle = "Advanced chat connection log - " + mw.config.get('wgSiteName'); //Page styling $('#mw-content-text p').html('Advanced chat connection log Please direct suggestions or bugs here</a>. Standard chat connection log</a>').append(formHTML + ' <ul id="mw-chatconnect-list"></ul> '); $('.header-column.header-title h1').text('Advanced chat connection log'); document.title = normalTitle; mw.util.addCSS('.duplicate-user-blocked { color:red; font-weight:bold; }'); function generateURL { var string = articlePath + "Special:Log/chatconnect"; string += "?limit=" + $('#mw-log-limit').val || 50; string += "&user=" + $('#mw-log-user').val || ""; string += "&year=" + $('#mw-log-year').val || ""; string += "&month=" + $('#mw-log-month').val || ""; if (document.getElementById('mw-log-previous').checked) string += "&offset=" + lastOffset; return string } function generateEntries { var IPs = [], names = [], dupeIPs = [], newList = [], checkBan = [], checkBlockBan = [], IP, name, line; document.title = normalTitle; $.get(generateURL, function(data) {		$(data).find('.mw-logline-chatconnect').each(function { //Construct entries of new list IP = $(this).text.match(/(((?:\d{1,3}\.){3}\d{1,3})|(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])))/)[0]; name = decodeURIComponent($(this).children('a.mw-userlink').attr('href').split(':')[1]); line = $(this).html.match(regex)[2] + '(lookup</a> | contribs</a> | block</a>16</a> | check</a> | connect</a>)'; if ($.inArray(line, newList) == -1) { newList.push(line); if ($.inArray(IP, IPs) == -1) IPs.push(IP); else if ($.inArray(IP, dupeIPs) == -1) { dupeIPs.push(IP); checkBlockBan.push(IP); }			}		});		//Determine the multiple accounts from the detected duplicate IP addresses and listify the dupe IPs with useful links		$.each(dupeIPs, function(i,v) { $.each(newList, function(i2,v2) {				if (v2.indexOf(v) != -1)					names.push(v + ' ' + $(v2).filter('a.mw-userlink').text);			}); dupeIPs[i] = '<li class="duplicate-user">' + v + '</a> (lookup</a> | block</a>16</a> | log</a> | check</a>)</li>'; });		//Listify the names and add useful links alongside them		$.each(names, function(i,v) { IP = v.match(/(((?:\d{1,3}\.){3}\d{1,3})|(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])))/)[0]; name = v.replace(IP,'').trim; checkBan.push(name); names[i] = '<li class="duplicate-user">' + IP + ' ' + name + '</a> (block</a> | <a href="' + articlePath + 'Special:Log/block?page=' + name + '">log</a> | <a href="' + articlePath + 'Special:CheckUser?user=' + name + '">check</a> | <a href="' + articlePath + 'Special:Log/chatconnect?user=' + name + '">connect</a>)</li>'; });			$.each(newList, function(i,v) { newList[i] = '<li class="chatconnect-custom"> ' + v + '</li>'; });		//Replace the list with the new one and add breakdown summary		$('#mw-chatconnect-wrapper').empty.prepend('<ul id="mw-chatconnect-list" style="display:none"></ul>');		$('#mw-chatconnect-list').html(newList.sort.join('\n').trim).before(' Breakdown IPs A total of ' + dupeIPs.length + ' duplicate IP entries were found. <ul>' + dupeIPs.sort.join('\n').trim + '</ul> Accounts A total of ' + names.length + ' duplicate account entries were found. <ul>' + names.sort.join('\n').trim + '</ul> Entries ' + $('.chatconnect-custom').length + ' unique chatconnect entries were found. </ul>').fadeIn(800);		//Check if there is duplicates		if (dupeIPs.length > 0) {			checkBlockBan = $.merge(checkBlockBan,checkBan);			//Change the page title to number of duplicates			document.title = '(' + dupeIPs.length + ') ' + normalTitle;			//Check if user or IP is already blocked; output if true			API.get({ action: 'query', list: 'blocks', bkusers: checkBlockBan.join('|'), bklimit: 500 })			.done(function(d) { if (!d.error) { var blocks = d.query.blocks; if (blocks[0] == null) return; for (var i in blocks) { if (!$('.duplicate-user a:contains(' + blocks[i].user + ')').parent.children('.duplicate-user-blocked').length) { $('.duplicate-user a:contains(' + blocks[i].user + ')').parent.append(' (blocked)'); delete checkBan[blocks[i].user]; }					}				}			});			//Get last 100 banned users			API.get({ action: 'query', list: 'logevents', letype: 'chatban', lelimit: 100 })			.done(function(d) { if (!d.error) { //Check if user already banned; output if true (does not overwrite block) $.each(checkBan, function(index, user) {						for (var i in d.query.logevents) {							if (d.query.logevents[i].action == "chatbanadd" && d.query.logevents[i].title.slice(5) == user) {								if (!$('.duplicate-user a:contains(' + d.query.logevents[i].title.slice(5) + ')').parent.children('.duplicate-user-blocked').length)									$('.duplicate-user a:contains(' + d.query.logevents[i].title.slice(5) + ')').parent.append(' (may be banned)');								break;							}						}					}); }			});		}		//Set the most recent offset		lastOffset = $(data).find('.mw-nextlink').attr('href').split('?offset=')[1].split('&type')[0];		//Reload if checked		if (document.getElementById('mw-log-refresh').checked) {			clearInterval(listLoader);			listLoader = setInterval(function { generateEntries; }, 10*60*60);		}		else			clearInterval(listLoader);	}); } generateEntries; $('#advanced-chatconnect-go').click(function {	generateEntries; }); });
 * Advanced chatconnect log interface
 * @author Ozuzanna
 * @fixer Jr Mime (IPV6)
 * NOTE: If you have Revision Delete you need to set a config before the import as follows: