User:Thundercraft5/common.js

/** User:Thundercraft5/common.js * Licensed Under CC-BY-SA-3.0. * * =====Contents===== * *Personal Adjustments *	*Upper icons adjustment *	*Top Menu *	* * * Major Scripts *	*blockListLookup *	*rangeBlockLinks *	*blockListTools

/* global mw, test, mediaWiki, ace */ /* jshint esversion: 5, forin: true, immed: true, indent: 4, latedef: false, newcap: true, noarg: true, undef: true, undef: true, unused: true, browser: true, jquery: true, onevar: true, eqeqeq: true, multistr: true, maxerr: 999999

//#==================================================# //# PERSONAL ADJUSTMENTS //#==================================================# window.dontWantRoleSpecificJS = true;

window.test = new Proxy({	test: "$", }, {	deleteProperty: function(o, k) {		throw new TypeError(o, k);	}, }); try { delete test.test; } catch (e) { console.warn(e); }

/* jshint forin: true, immed: true, indent: 4, latedef: true, newcap: true, noarg: true, undef: true, undef: true, unused: true, browser: true, jquery: true, onevar: true, eqeqeq: true, multistr: true, maxerr: 999999, -W082, -W084 /* global mw, ace */ mw.loader.using(['mediawiki.util', 'mediawiki.api']).then(function {		var api = new mw.Api;	var aceShown = false;	var contentEditor, titleEditor;	var canDelete = !!mw.config.get('wgUserGroups').join.match('^(bureaucrat|sysop|staff|util|wiki-manager|content-moderator|soap|content-team-member)');	mw.loader.load(['ext.codeEditor.ace']);	ace.define('ace/mode/regex', [], function(require, exports) { var oop = require("../lib/oop"); var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var RegexHighlightRules = function { this.$rules = { "start": [{ // escapes token: "regexp.keyword.operator", regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" }, {					// flag token: "string.regexp", regex: "/[sxngimy]*", }, {					// invalid operators token : "invalid", regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/ }, {					// operators token : "constant.language.escape", regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[$^+*?.]/ }, {					token : "constant.language.delimiter", regex: /\|/ }, {					token: "constant.language.escape", regex: /\[\^?/, next: "regex_character_class" }, {					defaultToken: "string.regexp" }],			};		};		oop.inherits(RegexHighlightRules, TextHighlightRules); exports.RegexHighlightRules = RegexHighlightRules; });

function setupEditor(id) { var aceEditor = ace.edit(id); var mode = new (ace.require("ace/mode/javascript").Mode); mode.HighlightRules = ace.require('ace/mode/regex').RegexHighlightRules; aceEditor.session.setMode(mode);

if (id === "SP-ContentRegex") { aceEditor.setOptions({				wrapBehavioursEnabled: true,				wrap: true,			}); aceEditor.session.on('change', function {				var height = aceEditor.session.getScreenLength					* aceEditor.renderer.lineHeight					+ aceEditor.renderer.scrollBar.getWidth + 'px';				$(id).css({ height: height });				aceEditor.resize;			}); }		return aceEditor; }	function generateNamespaces { var o = mw.config.get('wgFormattedNamespaces'), ret = [];

Object.keys(o).forEach(function(key) {			var value = o[key];

ret.push($(' ', { value: key, text: value, }));		});		ret[0] = $(' ', { value: 0, text: "(Main)", selected: true, });

return $(' ', {			id: "SP-namespace",			html: ret,		}); }

function getData { var def = new $.Deferred;

api.get({			action: "query",			format: "json",			list: "allpages",			aplimit: 5000,			apnamespace: $('#SP-namespace').val || 0,			apfilterredir: !$('#showredir').prop('checked') ? 'nonredirects' : null,		}).then(function(d) {			var pages = d.query.allpages.map(function(v) { return v.title; });			var titles = ;

var counter = 0; var calls = 0; pages.forEach(function(page) {				counter++;				if (counter >= 35) {					titles.push([page]);					counter = 0;					calls++;				} else {					titles[calls].push(page);				}			});

$.when.apply($, titles.map(function(v) { return api.get({					action: "query",					format: "json",					prop: "revisions",					titles: v.join('|'),					formatversion: "2",					rvprop: "content",					rvslots: "*",				}); })).then(function {				var revs = [];				Array.from(arguments).filter(function(v) { console.log(v); return v[0] || v.query; }).forEach(function(query) { (query[0] || query).query.pages.forEach(function(v) {						revs.push(v);					}); });

revs = revs.map(function(v) {					return { 						pageid: v.pageid,						ns: v.ns,						title: v.title,						content: v.revisions[0].slots.main.content,						contentformat: v.revisions[0].slots.main.contentformat,						contentmodel: v.revisions[0].slots.main.contentmodel,					};				}); def.resolve(revs); }, def.reject);		}, def.reject); return def; }

function filterMatch(data, titleSearch, contentSearch, caseInsensitive, regex, regexFlags) { if (regexFlags.match(/[^gmisuy]/)) return error("Invalid regular expression flags \"" + regexFlags + "\""); if (regex) { try { titleSearch = new RegExp(titleSearch, regexFlags + (caseInsensitive && !regexFlags.includes('i') ? "i" : "")); contentSearch = new RegExp(contentSearch, regexFlags + (caseInsensitive && !regexFlags.includes('i') ? "i" : "")); } catch(e) { return error(e.message); }		}

function testMatch(testString, matcher, caseInsensitive) { if (matcher instanceof RegExp) { return !!matcher.test(testString); } else { if (caseInsensitive) { testString = testString.toLowerCase; matcher = matcher.toLowerCase; }				return !!testString.includes(matcher); }		}		return data.filter(function(page) {			var pass = true;			if (titleSearch && !testMatch(page.title, titleSearch, caseInsensitive)) {				pass = false;			}			if (contentSearch && !testMatch(page.content, contentSearch, caseInsensitive)) {				pass = false;			}			return pass;		}); }

function error(msg) { $('#SP-results').html($("", { html: "Error in getting data: " + msg.replace(/(\/.+?\/[a-z]*)/, $(' ', { style: "font-family: consolas;", text: '$1' }).prop('outerHTML')), class: "error", }));	}

function createCheckbox(label, title, id, click, options) { if (typeof(click) === 'object') options = click, click = undefined; options = options || {}; return $(' ', $.extend({ class: "SP-checkbox", id: "SP-" + id + "-wrapper", html: [ $(' ', $.extend({ id: "SP-" + id, name: "SP-" + id, type: "checkbox", title: title, }, options.input)), ' ',				$(' ', $.extend({ for: "SP-" + id, id: "SP-" + id + "-label", text: label, title: title, click: click, }, options.label)), ],		}, options.wrapper)); }	function createInput(label, title, id, options) { options = options || {}; options.input = options.input || {}; var html = [ !options.input.type ? $('', $.extend({ html: label + ': ', title: title, }, options.label)) : "", $(' ', $.extend({ id: "SP-" + id, name: options.input.name || "SP-" + id, title: title, }, options.input)), options.input.type ? $(' ', $.extend({ for: "SP-" + id, id: "SP-" + id + "-label", text: label, title: title, }, options.label)) : "", ];		return $(' ', $.extend({ class: "SP-input", id: "SP-" + id + "-wrapper", html: html, }, options.wrapper)); }	function createLinks(title) { return $(' ', {			html: [				$('', { href: mw.util.getUrl(title), title: title, text: title, }),				' (',				$('', {					href: mw.util.getUrl(title, { action: "edit" }),					title: mw.util.getUrl(title, { action: "edit" }),					text: "edit",				}), ' | ',				$('', {					href: mw.util.getUrl(title, { action: "history" }),					title: mw.util.getUrl(title, { action: "history" }),					text: "hist",				}), ' | ',				$('', {					href: mw.util.getUrl('Special:Log', { page: title }),					title: mw.util.getUrl('Special:Log', { page: title }),					text: "logs",				}), ')',			],		});	}	function toggleEditors { aceShown = !aceShown; $('#SP-ContentRegex, #SP-TitleRegex, #SP-title-search, #SP-content-search').fadeToggle; if (aceShown) { $('#SP-ContentRegex, #SP-TitleRegex').removeClass('hidden'); $('#SP-title-search, #SP-content-search').addClass('hidden'); contentEditor.setValue($('#SP-content-search').val); titleEditor.setValue($('#SP-title-search').val); $('#SP-title-search').css({ display: 'inline-block' }); } else { $('#SP-ContentRegex, #SP-TitleRegex').addClass('hidden'); $('#SP-title-search, #SP-content-search').removeClass('hidden'); $('#SP-content-search').val(contentEditor.getValue); $('#SP-title-search').val(titleEditor.getValue); }	}	function setPending { $('#mw-content-text input, select').prop('disabled', true); contentEditor.setOptions({ readOnly: true }); titleEditor.setOptions({ readOnly: true }); $('#SP-results').addClass('mw-ajax-loader').empty; }	function donePending { $('#SP-results').removeClass('mw-ajax-loader'); contentEditor.setOptions({ readOnly: false }); titleEditor.setOptions({ readOnly: false }); $('#mw-content-text input, select').prop('disabled', false); }	function onSubmit { setPending; getData.then(function(d) {			donePending;			d = filterMatch( d, (aceShown ? titleEditor.getValue : $('#SP-title-search').val).trim, ( aceShown ? contentEditor.getValue : $('#SP-content-search').val).trim, $("#SP-case-insensitive").prop('checked'), $("#SP-regex").prop('checked'), $('#SP-regex-flags').val );			if (!d) return;			var oldD = d;			d = d.map(function(v) { return $('', {					html: createLinks(v.title),				}); });			var on = false;			if (!d.length) return $('#SP-results').html($(' ', { text: 'No pages matched your search.' }));			$('#SP-results').html([ canDelete ? createCheckbox('Delete Found', 'Delete all pages found', 'del-found', function {					if (on) $('#SP-protect-levels-wrapper').fadeOut;					$('#SP-del-reason-wrapper, #SP-protect-del-wrapper').fadeToggle;						on = !on;				}) : "", canDelete ? createInput('Deletion reason', 'Deletion reason', 'del-reason', {					wrapper: {						style: "display: none",					}				}) : "", canDelete ? createCheckbox('Protect Deleted', 'Protet Deleted pages', 'protect-del', function {					$('#SP-protect-levels-wrapper').fadeToggle;				}, {					wrapper: {						style: "display: none",					},				}) : "", $(' ', {					id: "SP-protect-levels-wrapper",					style: "display: none",					html: [						$("", { text: "Create Protection level: ", id: "SP-protect-level-sign", }),					].concat( createInput('Administrators only', 'Administrators only can edit the deleted page.', 'pl-admin-only', {							input: {								type: "radio",								selected: true,								name: "pl-protect-options",							},						}), createInput('Autoconfirmed only', 'Autoconfirmed users only can edit the deleted page.', 'pl-auto-only', {							input: {								type: "radio",								name: "pl-protect-options",							},						}) ),				}),				$('', {					html: [						"Total Results: " + d.length,						' (', $('', {							style: "cursor: pointer",							text: "copy pages",							click: function {								window.navigator.clipboard.writeText(oldD.map(function(v) {									return v.title;									}).join('\n'));								return alert('Copied!');							},						}), ')',					],				}),				$('', {					html: d,				}) ]);		}, error); }	function initInterface { document.getElementById('firstHeading').innerHTML = 'Search For Pages'; document.title = 'Search For Pages | ' + mw.config.get('wgSiteName') + ' | Fandom';

$('#mw-content-text').html($(' ', { html: [ 'Namespace to search: ', generateNamespaces, createCheckbox("Show Redirects", "Show redirects in the results", "showredir"), createCheckbox("Case insensitive", "Make the matchers case insensitive", "case-insensitive"), createCheckbox("Regex", "Make the matchers use regular expressions", "regex", function {					toggleEditors;					$('#SP-regex-flags-wrapper').fadeToggle;				}), $(' ', {					id: "SP-regex-flags-wrapper",					style: "display: none;",					html: [						$('', { title: "Regular expression flags to use", id: "SP-regex-flags-label", text: "Regex Flags: ", }),						$(' ', {							id: "SP-regex-flags", title: "Regular expression flags to use", }),					],				}),				'Page title to match: ', $(' ', { type: "text", id: "SP-title-search" }).attr({ size: 100 }), $(' ', { 					id: "SP-TitleRegex",					css: {						display: "none",						width: "600px",						height: "20px",						'font-size': '14px',						'line-height': '18px',						'border': '1px solid #474747',						'margin-bottom': '-5px',					},				}), ' ',				'Page content to match: ', ' ',				$(' ', { cols: 100, rows: 6, id: "SP-content-search", resizable: true }), $(' ', { 					id: "SP-ContentRegex", 					css: {						display: "none",						'font-size': '14px',						'line-height': '18px',						'min-height': '200px',						'max-height': '400px',						'min-width': '600px',						'max-width': '1000px',						'border': '1px solid #474747',					},				}), ' ',				' ',				$(' ', {					html: ["Search Results", " ".repeat(2), $(' ', { id: "SP-submit", text: "Submit", click: onSubmit, })],				}), 				' ',				$(' ', { id: "SP-results", html: $(' ', { text: "Submit inputs to see pages.", }) }), ],		}));		contentEditor = setupEditor("SP-ContentRegex"); titleEditor = setupEditor("SP-TitleRegex"); }

function initSpecialPages { var listItem = $('', {			html: $('', { text: "Search For Pages", href: mw.util.getUrl('Special:SearchPages'), }),		});		$('#mw-specialpagesgroup-pagetools').next.find('ul').append(listItem); $('#AdminDashboardAdvanced').find('h2').parent.slice(8, 9).next.find('ul').last.append(listItem); }

function init { if (window.searchPagesLoaded || mw.config.get('wgNamespaceNumber') !== -1) return; window.searchPagesLoaded = true;

mw.util.addCSS('#SP-title-search, #SP-content-search { font-family: consolas; } .SP-checkbox > * { cursor: pointer !important; } .hidden { display: none !important }'); switch(mw.config.get('wgTitle')) { case('SearchPages'): return initInterface; case('AdminDashboard'): case('SpecialPages'): initSpecialPages; }	}	init; }).catch(console.warn);

var inter = setInterval(function {	var userGroups = mw.config.get('wgUserGroups');	var canBlock = /sysop|util|staff|helper|global-discussions-moderator|wiki-manager|soap/.test(userGroups.join('\n'));	if ($('[class^="ReplyCreate_reply-create"]').length) {		clearInterval(inter);

function changeCommentLinks { // jshint ignore:line $('span[class^="EntityHeader_header-details"] > div[class^="wds-avatar EntityHeader_avatar"] > a').each(function {				var user = $(this).attr('href').replace(/\/wiki\/(User:|Special:Contributions\/)/gi, ''),					$link = $(this).parent.parent.children('a:last-of-type:not(.mw-user-anon-link)'),					$this = $(this);

$link .attr('href', '/wiki/Special:Contributions/' + user) .html(user);

$this.attr('href', '/wiki/Special:Contributions/' + user);

$link.after(					' (', $('', {						href: "/wiki/Message_wall:" + user,						html: "wall",						title: "Message_wall:" + user,						class: "mw-user-anon-link",					}), canBlock ? ' &bull; ' : "", canBlock ? $('', {						href: "/wiki/Special:Block/" + user,						html: "block",						title: "Special:Block/" + user,						class: "mw-user-anon-link",					}) : "", ')'				);			});		}

changeCommentLinks;

$('[class^="ReplyList_view-all-replies"]').click(function {			setTimeout(changeCommentLinks, 25);		}); } }, 25);

document.addEventListener('keydown', function(e) {	var key = e.key.toLowerCase;	if (key === "l" && e.ctrlKey) {		e.preventDefault;		document.querySelector('.oo-ui-iconElement-icon.oo-ui-icon-gotoLine').click;	} else if (key === "s" && e.ctrlKey) {		e.preventDefault;		document.querySelector('.oo-ui-iconElement-icon.oo-ui-icon-pilcrow').click;	} });

var pagePathname = mw.config.get('wgArticlePath').replace('$1', ''), sitename = mw.config.get('wgSiteName'), // jshint ignore:line userGroups = mw.config.get('wgUserGroups'), // jshint ignore:line namespace = mw.config.get("wgNamespaceNumber"), // jshint ignore:line pagename = mw.config.get('wgPageName'), // jshint ignore:line wikiUrl = mw.config.get('wgServer').replace(/https?:\/\//g, ''), // jshint ignore:line server = mw.config.get('wgServer'); // jshint ignore:line

var inter = setInterval(function {	if (namespace !== 828) {		clearInterval(inter);		return;	}	if ($('.ace_content').length && namespace === 828) {		clearInterval(inter);	} else {		return;	}	var histList = [''], 		histPos = 0, 		question, input, output, $spinner, 		sessionContent = null, 		sessionKey = null, 		pending = false, 		clearNextRequest = false,		debugConsole,		session;	function refocus { // jshint ignore:line		debugConsole.blur;		debugConsole.focus;	}	function initConsole { // jshint ignore:line		input = document.getElementById('mw-scribunto-input');		output = document.getElementById('mw-scribunto-output');		$spinner = $.createSpinner({ size: 'small', type: 'block', id: "consoleSpinner", });		println(mw.msg('scribunto-console-intro'), 'mw-scribunto-message');		debugConsole = ace.edit('debugConsole');		ace.console = {};		ace.console.editor = debugConsole;		session = debugConsole.session;		debugConsole.resize;		debugConsole.getSession.setMode('ace/mode/lua');		session.on('change', function { var size = debugConsole.session.getScreenLength * debugConsole.renderer.lineHeight + debugConsole.renderer.scrollBar.getWidth; $('#debugConsole').css('height', size); debugConsole.resize; });		debugConsole.setOptions({ enableSnippets: true, enableLiveAutocompletion: true, enableBasicAutocompletion: true, });		// Toggle enableLiveAutocompletion (Ctrl-S)		debugConsole.commands.addCommand({ name: 'toggleAutocomplete', bindKey: {win: 'Ctrl-S'}, exec: function(editor) { var on = editor.$enableLiveAutocompletion === true; editor.setOptions({					enableLiveAutocompletion: !editor.$enableLiveAutocompletion,				}); if (on) editor.completer.detach; }		});		// Clear Console (Ctrl-Alt-C)		debugConsole.commands.addCommand({ name: 'clearConsole', bindKey: {win: 'Ctrl-Alt-C'}, exec: function { clearOutput; }		});		// Clear Console State (Ctrl-Shift-C)		debugConsole.commands.addCommand({ name: 'clearConsoleState', bindKey: {win: 'Ctrl-Shift-C'}, exec: function { onClearClick; }		});		// Replace Spaces (Ctrl-Shift-S)		debugConsole.commands.addCommand({ name: 'replaceSpaces', bindKey: {win: 'Ctrl-Shift-S'}, exec: function(editor) { var pos = editor.getCursorPosition; editor.find('	'); editor.replaceAll('\t'); editor.moveCursorToPosition(pos); }		});

session.on('focus', inputFocus); // Submit (Ctrl-Enter) debugConsole.commands.addCommand({			name: 'consoleSubmit',			bindKey: {win: 'Ctrl-Enter'},			exec: function {				go;			}		}); // Go To previous history entry (UpArrow) debugConsole.commands.addCommand({			name: 'navigateUp',			bindKey: { win: 'Up' },			exec: function(editor) {				if (caretInFirstLine) {					hist('up');				} else {					// If cursor is not in first posistion, dont suppress default behavior					editor.navigateUp;				}			},		}); // Go To next history entry (DownArrow) debugConsole.commands.addCommand({			name: 'navigateDown',			bindKey: { win: 'Down' },			exec: function(editor) {				if (caretInLastLine) {					hist('down');				} else {					// If cursor is not in last posistion, dont suppress default behavior					editor.navigateDown;				}			},		}); }	function inputFocus { // jshint ignore:line if (sessionContent === null) { return; }		if (clearNextRequest) { return; }		if (getContent !== sessionContent) { printClearBar('scribunto-console-cleared'); clearNextRequest = true; }	}	function caretInFirstLine { // jshint ignore:line return debugConsole.getCursorPosition.row === 0; }	function caretInLastLine { // jshint ignore:line return debugConsole.getCursorPosition.row+1 === debugConsole.session.getLength; }	function println(s, type) { // jshint ignore:line var newdiv; if ((s = String(s))) { newdiv = document.createElement('div'); newdiv.appendChild(document.createTextNode(s)); newdiv.className = type; output.appendChild(newdiv); return newdiv; }	}	function printClearBar(msg) { // jshint ignore:line $(' ').attr('class', 'mw-scribunto-clear').text(mw.msg(msg)).appendTo(output); }	function hist(direction) {// jshint ignore:line var L = histList.length; var session = debugConsole.session; if (L === 1) { return; }		if (direction === 'up') { if (histPos === L - 1) { histList[histPos] = session.getValue; }			if (histPos > 0) { histPos--; setTimeout(function {					session.setValue('');					session.setValue(histList[histPos]);				}, 0); }		} else { if (histPos < L - 1) { histPos++; session.setValue(histList[histPos]); } else if (histPos === L - 1) { if (session.getValue) { histList[histPos] = session.getValue; ++histPos; session.setValue(''); }			}		}	}	function printQuestion(q) { // jshint ignore:line println(q.match(/^=/) ? q.replace(/^=/, '') : q, 'mw-scribunto-input' + (q.match(/^=/) ? ' exp' : '')); }	function printError(er) { // jshint ignore:line var lineNumberString; if (er.name) { lineNumberString = (er.lineNumber !== undefined) ? (' on line ' + er.lineNumber + ': ') : ': '; println(er.name + lineNumberString + er.message, 'mw-scribunto-error'); } else { println(er, 'mw-scribunto-error'); }	}	function setPending { // jshint ignore:line pending = true; debugConsole.setOptions({			readOnly: true,		}); $spinner.insertBefore($('#debugConsole').parent); }	function clearPending { // jshint ignore:line $spinner.remove; pending = false; debugConsole.setOptions({			readOnly: false,		}); }	function go { // jshint ignore:line var params, api, content, sentContent; if (pending) { return; }		question = debugConsole.session.getValue; if (question === '') { return; }		histList[histList.length - 1] = question; histList[histList.length] = ''; histPos = histList.length - 1; debugConsole.session.setValue(''); setTimeout(function {			debugConsole.session.setValue('');		}, 0); printQuestion(question); params = { action: 'scribunto-console', title: mw.config.get('wgPageName'), question: question };		content = getContent; sentContent = false; if (!sessionKey || sessionContent !== content) { params.clear = true; params.content = content; sentContent = true; }		if (sessionKey) { params.session = sessionKey; }		if (clearNextRequest) { params.clear = true; clearNextRequest = false; }		api = new mw.Api; setPending; api.post(params).done(function(result) {			if (result.sessionIsNew ===  && !sentContent) {				printClearBar('scribunto-console-cleared-session-lost');				sessionContent = null;				clearPending;				debugConsole.setValue(params.question);				go;				return;			}			sessionKey = result.session;			sessionContent = content;			if (result.type === 'error') {				$(' ')					.addClass('mw-scribunto-error')					.html(result.html)					.appendTo(output);			} else {				if (result.print !== ) {					println(result.print, 'mw-scribunto-print');				}				if (result.return !== '') {					println(result.return, 'mw-scribunto-normalOutput');				}			}			clearPending;			setTimeout(refocus, 0);		}).fail(function(code, result) {			if (result.error && result.error.info) {				printError(result.error.info);			} else if (result.exception) {				printError('Error sending API request: ' + result.exception);			} else { mw.log(result); printError('Error sending API request: ' + code); }			clearPending; setTimeout(refocus, 0); });	}	function getContent { // jshint ignore:line		var $textarea = $('#wpTextbox1'),			context = $textarea.data('wikiEditor-context');		if (context === undefined || context.codeEditor === undefined) {			return $textarea.val;		} else {			return $textarea.textSelection('getContents');		}	}	function onClearClick {// jshint ignore:line		$('#mw-scribunto-output').empty;		clearNextRequest = true;		refocus;	}	function clearOutput {// jshint ignore:line		$('#mw-scribunto-output').empty;		refocus;	}	function initEditPage { // jshint ignore:line		$('#mw-scribunto-console').first.remove;		var $wpTextbox1, 			$console = $('#mw-scribunto-console');		mw.messages.set('scribunto-console-clear-output', 'Clear Console Output');		mw.messages.set('scribunto-console-clear', 'Clear Console State');		mw.messages.set('scribunto-console-submit', 'Submit');		if (!$console.length) {			$wpTextbox1 = $('#wpTextbox1'); $console = $(' ').attr({				id: 'mw-scribunto-console'			}); console.log(!$('.editOptions').length); $('.editOptions').before($console); }		$(' ')			.attr('class', 'mw-scribunto-console-fieldset') .append($(' ')				.text(mw.msg('scribunto-console-title'))			) .append($(' ')) .append($(' ').append( $(' ', {					id: "debugConsole",					css: {						'width': 'calc(-webkit-fill-available+100px)',						'font-size': '14px',						'line-height': '18px',						'min-height': '100px',						'max-height': '400px',					}				}) ))			.append($(' ').append( $(' ')					.attr({						type: 'button',						value: 'Clear Console Output'					}) .on('click', clearOutput), $(' ')					.attr({						type: 'button',						value: mw.msg('scribunto-console-clear')					}) .on('click', onClearClick), $(' ')					.attr({						type: 'button',						value: mw.msg('scribunto-console-submit')					}) .on('click', function(e) {						e.preventDefault;						go;					}) ))			.wrap(' ') .appendTo($console); initConsole; }	$(function {		var action = mw.config.get('wgAction');		if (action === 'edit' || action === 'submit' || action === 'editredlink') {			initEditPage;		}	}); });

/* Upper icons adjustment */ $('a[href="' + pagePathname + 'Special:CreatePage"]').remove; $('a[title="Recent Changes"]').after(		$('<a>', { class: "wds-button wds-is-secondary", href: mw.util.getUrl("Special:SocialActivity"), title: "Social Activity", html: "<svg class=\"wds-icon wds-icon-small\"><use xlink:href=\"#wds-icons-comment-small\"> ", }),	$('<a>', { class: "wds-button wds-is-secondary", href: mw.util.getUrl("Special:AbuseLog"), title: "Abuse Log", html: "<svg class=\"wds-icon wds-icon-small\"><use xlink:href=\"#wds-icons-poll\"> ", }) ); /* Top Menu */ var topListSelector = 'div.wds-community-header__wiki-buttons > div.wds-dropdown ul.wds-list.wds-is-linked'; $(topListSelector) .empty .attr('title', 'More Tools and Links') .append(		$('<li>', { html: $('<a>', {				href: pagePathname + "Special:BlockLookup",				html: "Block Lookup",				title: 'Special:BlockLookup',			}), }),		$('<li>', { html: $('<a>', {				href: pagePathname + "Special:BlockList",				html: "Blocked Users",				title: 'Special:BlockList',			}), }),		$('<li>', { html: $('<a>', {				href: pagePathname + "Special:AllMessages",				html: "All System Messages",				title: 'Special:AllMessages',			}), }),		$('<li>', { html: $('<a>', {				href: pagePathname + "Special:AllPages",				html: "All pages",				title: 'Special:AllPages',			}) }),		$('<li>', { html: $('<a>', {				href: pagePathname + "Special:Watchlist",				html: "Watch list",				title: 'Special:Watchlist',			}) }),		$('<li>', { html: $('<a>', {				href: pagePathname + "Special:ListUsers",				html: "Users List",				title: 'Special:ListUsers',			}) }),		$('<li>', { html: $('<a>', {				href: pagePathname + "Special:ListGroupRights",				html: "User Group Rights",				title: 'Special:ListGroupRights',			}) })	);

/* rangeBlockLinks */ var pagename = mw.config.get("wgTitle"), namespace = mw.config.get("wgNamespaceNumber"), username = mw.config.get("wgTitle").split('/')[1], usergroups = mw.config.get('wgUserGroups');
 * (function($, mw, window) {

if (		namespace !== -1		|| !pagename.match(/(?:\d{1,3}\.){3}\d{1,3}/)		|| !/sysop|soap|staff|helper|global-discussions-moderator|wiki-manager/gmi.test(usergroups.join)		|| window.rangeBlockLinksInit	) { console.log('RangeBlockLinks: Import conditions not met, skipping import.'); return; }	window.rangeBlockLinksInit = true; function makeRangeBlockLink(range) { return([				"<a href=\"/wiki/Special:Block/",				username,				'/',				range,				"\" title=\"Block the /",				range,				" CIDR range this IP address originates from\"",				" id=\"rangelinks-range-block-CIDR-" + range + "\"",				">/",				range,				"</a>",			].join('')); }	$("#contentSub > a[href=\"/wiki/Special:Block/" + username + "\"]") .after(			" <small id=\"rangeblock-links\">(" + [					makeRangeBlockLink(24), makeRangeBlockLink(22), makeRangeBlockLink(20), makeRangeBlockLink(18), makeRangeBlockLink(16), ].join(' • ') + ") "		);

console.log('RangeBlockLinks: Successfully added range block links!'); })(jQuery, mediaWiki, window);

/* blockListTools */ function _main { var pagePathname = mw.config.get('wgArticlePath').replace('$1', ''), $ipToolsSel = $('td.TablePager_col_ipb_target span.mw-usertoollinks'), namespace = mw.config.get("wgNamespaceNumber"), pagename = mw.config.get("wgTitle");
 * (function {

function logMsg(data) { return console.log('BlockListTools:', typeof(data) === 'object' ? data.join(' ') : data); }

if (namespace !== -1 && pagename !== 'BlockList') { logMsg('Namespace/page is not supported, skipping importing script.'); return; }

window.blockListToolsInit = true;

/* IP tools */ $ipToolsSel.each(function {			/* Variables within iterator */			var $elem = $(this).children('a'),				href = $elem.prop('href'),				ip = href.match(/(\d{1,3}\.){3}\d{1,3}/g),				classes = $elem.prop('class'), // jshint ignore:line				user = href.split(':')[2]; // jshint ignore:line

if (ip) { $elem.first.after(					" &bull; ",					/* Proxy Check/General Info */					$('<a>', { href: "//www.ipqualityscore.com/free-ip-lookup-proxy-vpn-test/lookup/" + ip, title: "Proxy check for " + ip, html: "PC", class: $elem.prop('class'), }),					" &bull; ",					/* Spam Blacklist check */					$('<a>', { href: "//cleantalk.org/blacklists/" + ip, title: "Spam Blacklist check for " + ip, html: "BC", class: $elem.prop('class'), }),					" &bull; ",					$('<a>', { href: "https://cleantalk.org/whois/" + ip, title: "WHOIS for " + ip, html: "WHOIS", class: $elem.prop('class'), })				);			}		});		logMsg('Sucessfully appended IP tool links!');

/* Variables */ var blOpsArray = [], blActionsSel = 'span.mw-blocklist-actions', cbSel = 'a[title^="Special:Block/"]', // jshint ignore:line uSel = 'a[title^="Special:Unblock/"]'; // jshint ignore:line

/* Get Block List Unblock/Block Links and store them */ $(blActionsSel).each(function(i, elem) {			elem.remove;			blOpsArray.push(elem);		});

/* Append Stored elements */ $('td.TablePager_col_ipb_timestamp').each(function(i, elem) {			elem.append(blOpsArray[i]);		});

/* Adjustments */ $(blActionsSel).before(' '); /* Iterate over new elements */ $('span.mw-blocklist-actions > a').each(function(i) {			var $this = $(this),				user;			/* Save User variable for future modifications */			user = $this.prop('title').match(/Special\:((?:Un)?block)\/(.+)/i);			user = user ? user[2] : null;			/* Format Titles */			$this.prop('title', $this.prop('title').replace(/Special\:((?:Un)?block)\/(.+)/i, function(match, $1, $2) {			  if ($1.toLowerCase === 'block') {					return 'Change block settings for ' + $2;			   } else {					return 'Unblock ' + $2;			   }			}));

/* Shorten Link Text */ if ($this.html.toLowerCase === 'change block') { $this.html('CB'); } else { $this.html('U'); }

if (i % 2 === 1) { /* Extra Tool Links */ $this.after(' | ', $('<a>', { href: pagePathname + 'Special:AbuseLog?wpSearchUser=' + user, html: "AL", title: "Abuse logs for " + user }));			}		});		logMsg('Sucessfully Modified block list action links!');	}	window.ajaxCallAgain = window.ajaxCallAgain || [];	window.ajaxCallAgain.push(_main);	_main; })(jQuery, mediaWiki, window);