User:Tails Wx/common.js

importScript('User:Jackmcbarn/editProtectedHelper.js'); // Linkback: User:Jackmcbarn/editProtectedHelper.js importScript( 'User:Qwertyytrewqqwerty/DisamAssist.js' ); // Backlink: User:Qwertyytrewqqwerty/DisamAssist.js //Mass rollback function //Written by John254 and modified/rewritten by Writ Keeper with modifications by TheDJ; original is at https://en.wikipedia.org/wiki/User:John254/mass_rollback.js //Adapted from User:Mr.Z-man/rollbackSummary.js //Instructions: Selecting the "rollback all" tab when viewing a user's contributions history //will open all rollback links displayed there. (Use with caution) if(typeof wkContribsCheckboxInit === "undefined") {	wkContribsCheckboxInit = false; }

function rollbackEverythingWKMR(editSummary) {	if(editSummary === null) {		return false; }	mw.loader.using( 'mediawiki.api' ).done( function	{		var rbMetadata = {};		rbMetadata.api = new mw.Api;		rbMetadata.userName = mw.config.get("wgRelevantUserName");		rbMetadata.ipRange = (rbMetadata.userName === null);		rbMetadata.titleRegex = /title=([^&]+)/;		rbMetadata.editSummary = editSummary;		$("a[href*='action=rollback']").each(function(ind, el) {			rollbackOneThingWKMR(el, rbMetadata); } );	} );	return false; } function rollbackSomeThingsWKMR(editSummary) {	if(editSummary === null) {		return false; }	mw.loader.using( 'mediawiki.api' ).done( function	{		var rbMetadata = {};		rbMetadata.api = new mw.Api;		rbMetadata.userName = mw.config.get("wgRelevantUserName");		rbMetadata.titleRegex = /title=([^&]+)/;		rbMetadata.editSummary = editSummary;		var rollbackList = $("input.revdelIds:checked").parents("li.mw-contributions-current").find("a[href*='action=rollback']");		if(rollbackList.length <= 0)		{			mw.notify("You didn't select any edits that could be rolled back!");			return;		}		$("input.revdelIds:checked").parents("li.mw-contributions-current").find("a[href*='action=rollback']").each(function(ind, el) {			rollbackOneThingWKMR(el, rbMetadata); } );	} ); } function rollbackOneThingWKMR(edit, rbMetadata) {	var userName; //if we're in an anonymous IP range, we have to figure out each username on its own, since they might be different for each edit. if(rbMetadata.userName === null) {		//the not clause is probably not necessary, but I'm including it just to be sure. userName = $(edit).parents("li:first").children("a.mw-anonuserlink").not(".mw-contributions-title").text; }	else {		userName = rbMetadata.userName; }	var params = {}; if( rbMetadata.editSummary != '' ) {		params.summary = rbMetadata.editSummary; }	rbMetadata.api.rollback( decodeURIComponent(rbMetadata.titleRegex.exec(edit.href)[1]), userName, params).done( function	{		$(edit).after("reverted");		$(edit).remove;	} ); } $(document).ready(function {	if(mw.config.get("wgCanonicalSpecialPageName") == "Contributions" && $("span.mw-rollback-link").length > 0)	{		mw.loader.using("mediawiki.util").done( function {			mw.util.addPortletLink('p-cactions', '#', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here"); if(!wkContribsCheckboxInit) {				if($("ul.mw-contributions-list .mw-revdelundel-link").length > 0) {					$("ul.mw-contributions-list .mw-revdelundel-link").each(function(ind,el){						if($(this).children("a").length > 0)						{							var revId = /ids=(\d+)/.exec($(this).children("a").attr("href"))[1];							var pageTitle = /target=([^&]+)/.exec($(this).children("a").attr("href"))[1];							$(el).prepend(" ");							$(el).children(".revdelIds").data("index", ind);						}					}); }				else {					$("ul.mw-contributions-list a.mw-changeslist-date").each(function(ind,el){						$(el).before(" ");					}); }				wkContribsCheckboxInit = true; }			mw.util.addPortletLink('p-cactions', '#', "rollback selected", "ca-rollbacksome", "rollback selected edits"); $("#ca-rollbackeverything").click( function(event)			{				event.preventDefault;				mw.loader.load( 'mediawiki.api' ); //start loading, while the user is in the prompt					return rollbackEverythingWKMR(prompt("Enter an edit summary, or leave blank to use the default (or hit Cancel to cancel the rollback entirely)"));			}); $("#ca-rollbacksome").click( function(event)			{				event.preventDefault;				mw.loader.load( 'mediawiki.api' ); //start loading, while the user is in the prompt					return rollbackSomeThingsWKMR(prompt("Enter an edit summary, or leave blank to use the default (or hit Cancel to cancel the rollback entirely)"));			}); });	} }); importScript( 'User:Enterprisey/orcp-helper.js' ); // Backlink: User:Enterprisey/orcp-helper.js importScript( 'User:Evad37/OneClickArchiver.js' ); // Backlink: User:Evad37/OneClickArchiver.js //Mass rollback function //Written by John254 and modified/rewritten by Writ Keeper with modifications by TheDJ; original is at https://en.wikipedia.org/wiki/User:John254/mass_rollback.js //Adapted from User:Mr.Z-man/rollbackSummary.js //Instructions: Selecting the "rollback all" tab when viewing a user's contributions history //will open all rollback links displayed there. (Use with caution) if(typeof wkContribsCheckboxInit === "undefined") {	wkContribsCheckboxInit = false; }

function rollbackEverythingWKMR(editSummary) {	if(editSummary === null) {		return false; }	mw.loader.using( 'mediawiki.api' ).done( function	{		var rbMetadata = {};		rbMetadata.api = new mw.Api;		rbMetadata.userName = mw.config.get("wgRelevantUserName");		rbMetadata.ipRange = (rbMetadata.userName === null);		rbMetadata.titleRegex = /title=([^&]+)/;		rbMetadata.editSummary = editSummary;		$("a[href*='action=rollback']").each(function(ind, el) {			rollbackOneThingWKMR(el, rbMetadata); } );	} );	return false; } function rollbackSomeThingsWKMR(editSummary) {	if(editSummary === null) {		return false; }	mw.loader.using( 'mediawiki.api' ).done( function	{		var rbMetadata = {};		rbMetadata.api = new mw.Api;		rbMetadata.userName = mw.config.get("wgRelevantUserName");		rbMetadata.titleRegex = /title=([^&]+)/;		rbMetadata.editSummary = editSummary;		var rollbackList = $("input.revdelIds:checked").parents("li.mw-contributions-current").find("a[href*='action=rollback']");		if(rollbackList.length <= 0)		{			mw.notify("You didn't select any edits that could be rolled back!");			return;		}		$("input.revdelIds:checked").parents("li.mw-contributions-current").find("a[href*='action=rollback']").each(function(ind, el) {			rollbackOneThingWKMR(el, rbMetadata); } );	} ); } function rollbackOneThingWKMR(edit, rbMetadata) {	var userName; //if we're in an anonymous IP range, we have to figure out each username on its own, since they might be different for each edit. if(rbMetadata.userName === null) {		//the not clause is probably not necessary, but I'm including it just to be sure. userName = $(edit).parents("li:first").children("a.mw-anonuserlink").not(".mw-contributions-title").text; }	else {		userName = rbMetadata.userName; }	var params = {}; if( rbMetadata.editSummary != '' ) {		params.summary = rbMetadata.editSummary; }	rbMetadata.api.rollback( decodeURIComponent(rbMetadata.titleRegex.exec(edit.href)[1]), userName, params).done( function	{		$(edit).after("reverted");		$(edit).remove;	} ); } $(document).ready(function {	if(mw.config.get("wgCanonicalSpecialPageName") == "Contributions" && $("span.mw-rollback-link").length > 0)	{		mw.loader.using("mediawiki.util").done( function {			mw.util.addPortletLink('p-cactions', '#', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here"); if(!wkContribsCheckboxInit) {				if($("ul.mw-contributions-list .mw-revdelundel-link").length > 0) {					$("ul.mw-contributions-list .mw-revdelundel-link").each(function(ind,el){						if($(this).children("a").length > 0)						{							var revId = /ids=(\d+)/.exec($(this).children("a").attr("href"))[1];							var pageTitle = /target=([^&]+)/.exec($(this).children("a").attr("href"))[1];							$(el).prepend(" ");							$(el).children(".revdelIds").data("index", ind);						}					}); }				else {					$("ul.mw-contributions-list a.mw-changeslist-date").each(function(ind,el){						$(el).before(" ");					}); }				wkContribsCheckboxInit = true; }			mw.util.addPortletLink('p-cactions', '#', "rollback selected", "ca-rollbacksome", "rollback selected edits"); $("#ca-rollbackeverything").click( function(event)			{				event.preventDefault;				mw.loader.load( 'mediawiki.api' ); //start loading, while the user is in the prompt					return rollbackEverythingWKMR(prompt("Rollback all edits: Enter an edit summary, or leave blank to use the default (or hit Cancel to cancel the rollback entirely)"));			}); $("#ca-rollbacksome").click( function(event)			{				event.preventDefault;				mw.loader.load( 'mediawiki.api' ); //start loading, while the user is in the prompt					return rollbackSomeThingsWKMR(prompt("Rollback selected edits: Enter an edit summary, or leave blank to use the default (or hit Cancel to cancel the rollback entirely)"));			}); $("#ca-rollbacksome").data("lastSelectedIndex", -1);

$("input.revdelIds").off("click").click(				function(ev)				{					var lastSelectedRevdel = $("#ca-rollbacksome").data("lastSelectedIndex");					var newIndex = $(this).data("index")					if(ev.shiftKey && lastSelectedRevdel >= 0)					{						var checkboxArray = $("input.revdelIds");						var start = lastSelectedRevdel;						var stop = newIndex;						if(start < stop)						{							for(var i = start; i < stop; i++)							{								$(checkboxArray[i]).prop("checked", true);							}						}						else						{							for(var i = start; i > stop; i--)							{								$(checkboxArray[i]).prop("checked", true);							}						}					}					 $("#ca-rollbacksome").data("lastSelectedIndex", newIndex);				});

});	} }); importScript('User:Mr. Stradivarius/gadgets/ConfirmRollback.js'); // Linkback: User:Mr. Stradivarius/gadgets/ConfirmRollback.js importScript('User:MusikAnimal/confirmationRollback.js'); // Linkback: User:MusikAnimal/confirmationRollback.js importScript( 'User:DannyS712/DiscussionCloser.js' );// User:DannyS712/DiscussionCloser.js // --- // // What follows is a fork of User:GregU/dashes.js (forked on 27 May 2020) // The editor who developed the script is no longer active, and changes to //  Wikipedia have restricted who can edit the old script page. // // Please see the edit history for User:GregU/dashes.js for attribution // //  -- //  Fix hyphens, dashes, and minus signs per MOS:DASH. // // See talk page for instructions. // // The user can disable these conversions by putting "nodashes" somewhere // in the text — either temporarily or permanently. You can similarly add // "scores" if the score-detection heuristic doesn't trigger automatically. // // This tool can be used standalone until it is added to AutoEd and wikEd. // This module should follow unicodify.js if it is used. // Testing page is at User:GregU/dashes.js/tests. // Please report false positives on the talk page.

function autoEdDashes (str) { if (str.search(/nodashes/i) >= 0) return str;

var scpat = /\bscores?\b|\[\[Category:.*\b(sport|athlet|players|teams|games|league|champion|tournament|competit|cup\b|\w+ball\b|hockey|lacrosse|cricket|rugby|tennis|golf|polo|boxing|boxers|martial.art|chess)/i; var scoresAreLikely = (str.search(scpat) >= 0);

// Ensure the replacement isn't a link such as FOO - BAR before // replacing it, so that we don't break the link. But we do want to // replace dashes used in the right-side label part of links. Also, // don't break templates, URLs, DOIs,, equations, // source code, or . // function ifNotLink (str) {   var pos    = arguments[ arguments.length - 2 ]; var string = arguments[ arguments.length - 1 ];

var pat = /\[\^|\*$|\{\{[^|}]*$|[:\/%][^\s|>]+$|<[^>]*$|#\w*expr:.*$/i; if (string.substring(pos-260,pos+1).search(pat) >= 0) return str;            // it's a link, so don't change it

var pat2 = /\{\{(main|see|detail|excerpt|about|for\b|other|redir|conv|coor|sort|anchor|Israel populations|ISBN|DNB(?: [Cc]ite|)|[Cc]ite DNB)[^}]*$/i; if (string.substring(pos-260,pos+1).search(pat2) >= 0) return str;            // likely templates with page-name or neg params var pat3 = /\|\s*(CAS_number)\s*=\s*/i; if (string.substring(pos-260,pos+1).search(pat3) >= 0) return str;            // drugbox CAS_number var pat4 = /\|\s*(doi|elevation|filename|isbn)\s*=\s*/i; if (string.substring(pos-260,pos+1).search(pat4) >= 0) return str;            // doi or isbn (or elevation parameter in Template:Infobox German location which can contain range marked using hyphen)

var m = string.slice(pos).search(/<\/?(math|pre|code|tt|source|syntaxhighlight|gallery)\b/i); if (m >= 0 && string.charAt(pos+m+1) == '/') return str;            // don't break a  equation, or source code

m = string.slice(pos).search(/\{\{[\s]*[Gg]raph:Chart\b/i); if (m >= 0) return str;            // don't break a Graph:Chart

if (string.slice(pos).search(/^[^|{}[\]<>\n]*\.([a-z]{3,4}\s*[|}]|jpg|png|svg)|^.*hyphen/i) >= 0) return str;            // it's a file name parameter, or

if (str.search(/[ |(>][-–]\b/) >= 0)       return str.replace(/[-–]/, "−");       // minus sign    else        return str.replace(/--+\b/g, "—") . replace(/[-–−]+/g, "–");     // dash  }

str = str.replace(/\s--?\s/g, ifNotLink);                // en dash looks better str = str.replace(/[a-z\d]---?[a-z\d]/ig, ifNotLink);    // em dash str = str.replace(/\d\d\d]*}*[-−](present|current)\b/ig, ifNotLink);      // 1973-present str = str.replace(/[^\w−-](18|19|20)\d\d]*}*[-−][^\w−-]/g, ifNotLink);    // (1973-) str = str.replace(/\d(s|%|\?|''')[-−]\d/g, ifNotLink);   // 1950s-1960s, 40%-50% str = str.replace(/\d[-−](\$|'+)\d/g, ifNotLink);        // $40-$50, 7-4, '49-'53 str = str.replace(/[½⅓⅔¼¾⅛⅜⅝⅞]%?[-−][\d½⅓⅔¼¾⅛⅜⅝⅞]/g, ifNotLink);          // 3½-6 str = str.replace(/\d(st|nd|rd|th)?[-−]\d+(st|nd|rd|th)\b/g, ifNotLink);  // 2nd-3rd

str = str.replace(/([a-z,'"”\]>] +|\(|^\| *|\|\| *)[-–]\d/mig, ifNotLink);  // minus -35  str = str.replace(/<((sup|sub|td)>\s*)[-–](\d)/ig, "<$1−$3");         // 10-3  str = str.replace(/,*(?=.? ) *[-–—−] *(\d*:\d\d[\s*<])/g, " – $1");   // album track listings

// November 15, 2005-March 7, 2006; March 18-April 4 str = str.replace(/(\d\]*)[-–—−](\[*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]* +\d)/g, "$1 – $2"); // July-August 2007 str = str.replace(/\b((Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]*[-−]?\b){2,}/g, ifNotLink); // 266-283 str = str.replace(/(\d(?: BC)?\]\])[-−]((ca?\.|AD ?)?\[\[\d+[^\d-])/g, "$1–$2"); // (1984 – 1992) str = str.replace(/([(|=] *\[*\d+\]*) +[–—−] +(\[*\d+\]*\s*[)|}])/g, "$1–$2"); // iv-xii str = str.replace(/[ ;(=](?=\w+-)(m*(cm|cd|d?c*)(xc|xl|l?x*)(ix|iv|v?i*)-?\b){2}[^\w-]/g, ifNotLink);

if (scoresAreLikely)     // W-L-D or 73–70–67–70=280, but not castling str = str.replace(/[^\w−–-](?!0-0-0)(\d\d?\d?[-–−]){2,}\d\d?[^\w\/−–-]/g, ifNotLink);

str = str.replace(/\b(\d+)[–−](year|month|day|hour|minute|mile|yard|foot|inch|bit|door|speed|gun|page|seat|way|point|ton|man)\b/g, "$1-$2");    // hyphen

// Number ranges and scores should use en dashes, per MOS:DASH. // This has been well-tested and false positives (e.g., ID nos.) are rare. // function range (str, from,to, pos,string) {   var dash   = true; var except = /\b(fig(ure)?|table|example|exhibit|circular|section|part|number|no|nr|id|model|pub|std|report|rpt|law|[P.]L|p|page|date|IS\wN\b[ a-z]*|SCOTUS)[^\w(,;]*$/i;   var rpat   = /^([^A-Za-z]|nbsp)*(AD|BC|B?CE|BP|[kMG]a|km|mi|kg|lb|\w?Hz|vote|decision|record|odds|scor\w*|win|loss|tie|draw|lead|victory|defeat|upset|run|deficit|start|finish|season|game)\b/;    var lpat   = /\b(pages|pp|rp|nos|\d+\)?'*[:,]|(w[io]n|lost?|tie|dr.w|lea?d|f.ll|vot|rul|decid|pass|fail|defeat|scor|gam|match|trail|finish|end)e?[ds]?|\w\w+ing|ahead|behind|up|down|from|to|is|are|was|were|of|out|by|an?|at|it|went|go|gone|beaten|between)([^a-z]|nbsp)*$/i; var inorder  = (to-0 > from.slice(-to.length));     // pp 362-5 var precision = Math.max( from.search(/0*$/), to.search(/0*$/) );

if (string.substring(pos-20,pos+1).search(except) >= 0) { return str;     // based on preceding word, looks like a ref number }   if (from == 9 && to == 11) { dash = false;   // 9-11 is a common special case }   if (from-0 >= to) { dash = false;   // values don't look like a range }   if (to-from > 120 && from * (precision > 2 ? 5 : 50) < to && from > 1) { dash = false;   // values don't look like a range }   if (scoresAreLikely && from <= 900 && to <= 900) { dash = true;    // likely a score or wins-losses }   if (from < 2-to && string.search(/Category:.*\bChess\b/i) >= 0) { dash = false;   // chess notations 0-0, 0-1, 1-0 }   if (str.charAt(0) == '(' && string.charAt(pos + str.length) == ')') { dash = true;    // scores often seen as (8-4) }   if (from.search(/^0./) >= 0 || to.search(/^0./) >= 0) { dash = false;   // 3-07 and 0123-4567 look like ref numbers }   if (string.substr(pos-1,15).search(/^\d([:,.])\d+.\d+\1\d/) >= 0) { dash = true;    // 10:30-11:30, 35,000-40,000, 2.5-4.0 }   if (string.substr(pos,30).search(rpat) >= 0) { dash = true;    // 12-5 BC, 5-5000 km, 6-4 win, 73-50 vote }   if (string.substring(pos-80,pos).search(lpat) >= 0) { dash = true;    // pp. 8, 25, 270-74, 313-7; won 6-4, 6-2 }   if (from > 1000 && from < 2100 && to.length == 2 && inorder) { dash = true;    // 1994-95 year range }   return dash ? ifNotLink(str,pos,string) : str; }

str = str.replace(/[^\w\/+−–-](\d{1,4})[-−](\d{1,4})(?!'*[\w\/+−–-])/g, range);

return str; }

// Hook to allow using this tool "standalone"

if (importScript("Wikipedia:AutoEd/core.js"))  // if not otherwise using AutoEd console.log('imported')

function autoEdFunctions { var txt = document.editform.wpTextbox1; var str = txt.value. replace(/&mdash;/g, '—'). replace(/–/g, '–'). // simplify core regexes replace(/&minus;/g, '−'); var newstr = autoEdDashes( str ); if (newstr != str) {        // don't alter encoding style if no fixes txt.value = newstr; autoEdTag = "fixed dashes using User:Ohconfucius/dashes.js"; }   }    autoEdLinkName  = "–"; autoEdLinkHover = "Fix dashes, hyphens, and minus signs"; autoEdTag      = ""; importScript( 'User:Qwertyytrewqqwerty/DisamAssist.js' ); // Backlink: User:Qwertyytrewqqwerty/DisamAssist.js mw.loader.load( '/w/index.php?title=User:EnterpriseyBot/delsort.js&action=raw&ctype=text/javascript' ); // Backlink: User:EnterpriseyBot/delsort.js importScript( 'User:Qwertyytrewqqwerty/DisamAssist.js' ); // Backlink: User:Qwertyytrewqqwerty/DisamAssist.js importScript( 'User:SD0001/BDCS.js' ); // Backlink: User:SD0001/BDCS.js importScript("User:Awesome Aasim/xfdvote."); importScript('User:Novem Linguae/Scripts/CiteHighlighter.js'); // Backlink: User:Novem Linguae/Scripts/CiteHighlighter.js importScript( 'User:Ingenuity/AntiVandal.js' ); // Backlink: User:Ingenuity/AntiVandal.js importScript( 'User:MPGuy2824/MoveToDraft.js' ); // Backlink: User:MPGuy2824/MoveToDraft.js mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Uziel302/typo.js&action=raw&ctype=text/javascript'); importScript("User:Writ Keeper/Scripts/teahouseUtility.js"); // Gives one-click option to add Teahouse invitation or talkback to a user

importScript("User:Writ Keeper/Scripts/teahouseTalkback.js"); // Adds Talkback reminder when you save an edit at the Teahouse

importScript("User:Writ Keeper/Scripts/teahouseTalkbackLink.js"); // Adds a talkback link to signatures on the Teahouse

importScript("User:Ocaasi/WikiLoveinstallscript.js");// Adds Teahouse Badges to WikiLove importScript('User:SD0001/DYK-helper.js'); // User:SD0001/DYK-helper.js importScript( 'User:Enterprisey/cv-revdel.js' ); // Backlink: User:Enterprisey/cv-revdel.js importScript('User:Shubinator/DYKcheck.js'); //DYKcheck tool importScript( 'User:Headbomb/unreliable.js' ); // Backlink: User:Headbomb/unreliable.js mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Wugapodes/Capricorn.js&action=raw&ctype=text/javascript'); importScript( 'User:Eejit43/scripts/redirect-helper.js' ); // Backlink: User:Eejit43/scripts/redirect-helper.js mw.loader.load( '/w/index.php?title=User:Evad37/rater.js&action=raw&ctype=text/javascript' ); // Backlink: User:Evad37/rater.js importScript('User:SD0001/GAN-helper.js'); // User:SD0001/GAN-helper.js // // Attribution: Enterprisey and Red-tailed Hawk // Licenses: CC BY-SA 3.0 unported and GFDL // License link (CC): https://creativecommons.org/licenses/by-sa/3.0/legalcode // License link (GNU): https://www.gnu.org/licenses/fdl-1.3.html

$( function {    var ADVERT = " (cv-revdel — Red-tailed hawk's version)";    var SUMMARY = "Requesting copyvio revdel" + ADVERT;    var SUMMARY_TALK = "Add note about recent copyvio" + ADVERT;    var CCLEAN_TPL = "Cclean";    var pageName; // Current page name    var urlCounter = 1;    var api;

/**    * Make a link to a given oldid of the current page. */   function makeOldidLink( oldid ) { var href = "/w/index.php?title=" + encodeURIComponent( pageName ) + "&oldid=" + oldid; var link = document.createElement( "a" ); link.href = href; link.textContent = oldid; return link; }

/**    * Add the appropriate copyvio-revdel template to the current page. */   function addCvRevdel( urls ) { var deferred = $.Deferred;

var template = "{" + "{copyvio-revdel"; template += urls.map( function ( u, idx ) {                   var num = idx == 0 ? "" : ( idx + 1 );                    return "|url" + num + "=" + u;                } ).join( "" ); var rows = document.querySelectorAll( "#cv-revdel tr" ); var num; for( var i = 1, n = rows.length; i < n; i++ ) { template += "|start" + i + "=" + rows[i].childNodes[0].textContent + ( rows[i].childNodes[2].childNodes[0].checked ? ( "|end" + i + "=" + rows[i].childNodes[1].textContent ) : "" ); }       template = template + "|CopyPatrol="+ document.getElementById("copypatrol-url0").value; template += "}}";

api.postWithToken( "csrf", {           action: "edit",            title: pageName,            summary: SUMMARY,            prependtext: template + "\n"        } ).done( function ( d ) {            if( d && d.edit && d.edit.result && d.edit.result == "Success" ) {                $( "#cv-rd-status" ).text( "Success!" );               deferred.resolve;            } else if( d && d.error ) {                $( "#cv-rd-status" ).html( "Error! Edit failed: " + d.error.info );                console.log( d );                deferred.reject;            } else {                $( "#cv-rd-status" ).html( "Error! Edit failed." );               console.log( d );                deferred.reject;            }        } ).fail( function ( code, result ) {            console.log( code, result );            if( result && result.error && result.error.spamblacklist ) {                $( "#cv-rd-status" ).html( "Error! The following URLs were on the spam blacklist: " + result.error.spamblacklist.matches.join( ", " ) + ". Consider removing the 'https://' or 'http://' from the beginning to make them not links." );           } else {                $( "#cv-rd-status" ).html( api.getErrorMessage( result ) );            }            deferred.reject;        } );

return deferred; }

function addCclean( urls ) { var deferred = $.Deferred, template = "{" + "{subst:cclean|url=" + urls.join( " " ) + "}}", talkNs = mw.config.get( "wgNamespaceNumber" ) | 1, talkNsName = mw.config.get( "wgFormattedNamespaces" )[ talkNs ], talkPage = talkNsName + ":" + mw.config.get( "wgTitle" ); api.postWithToken( "csrf", {           action: "edit",            title: talkPage,            summary: SUMMARY_TALK,            appendtext: "\n\n" + template        } ).done( function ( d ) {            if( d && d.edit && d.edit.result && d.edit.result == "Success" ) {                deferred.resolve;            } else {                deferred.reject;                console.log( d );            }        } ).fail( function ( code, result ) {            deferred.reject;            $( "#cv-rd-status" ).append( "Also, while editing " + talkPage + ", this error happened: " + api.getErrorMessage( result ) );           console.log( code, result );        } ); return deferred; }

/**    * Load the main cv-revdel panel and add buttons/other stuff to     * the history UI     */ function load( evt ) { if( evt ) evt.preventDefault;

// Don't load the panel for a second time if it's already there if( document.getElementById( "cv-revdel" ) ) return;

api = new mw.Api;

// Style for the panel mw.util.addCSS(           "#cv-revdel { border: thin solid rgb(197, 197, 197); " +            "box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.25); border-radius: 3px;" +            "padding: 2em; display: inline-block }" +            "#cv-revdel table { margin: 1em 0 }" +            "#cv-revdel td { padding: 0 0.5em }" +            "#cv-revdel a.disabled {color: gray;text-decoration: line-through;font-style: italic;}" +            "#cv-rd-submit { margin-right: 1em }"+            "#cv-rd-urls input { width: 50%; min-width: 30em; }"+            "#cv-rd-urls div { margin-bottom: 0.35em; }"+            "#cv-revdel div.bottom-row { margin-top: 1em; }"+            "#cv-rd-add-range { margin-right: 0.5em; }"        );

// Add the panel itself var panel = document.createElement( "div" ); panel.id = "cv-revdel"; var urlHTML = " " + " URL: "+ "Remove " + " "+           "Add another "; var copyPatrolHTML = "  CopyPatrol URL: "; panel.innerHTML = " Instructions: Select a range of revisions using " + "the radio buttons you would normally use for comparing two " + "revisions, then click 'Add range to revdel template' to add the " + "range to the template. 'Include end?' should be unchecked to tag " + "only the single revision in the 'Start' column. Fill in URLs, and " + "then click 'Submit' to place the template. " + urlHTML + " \n\n "+ copyPatrolHTML + " " + "" + "Add to " + ( ( mw.config.get( "wgNamespaceNumber" ) % 2 ) ? "this" : "talk" ) + " page "+ " Submit " + "<button id='cv-rd-close' class='mw-ui-button mw-ui-quiet'>Close "+ " ";        document.getElementById( "bodyContent" ).insertBefore( panel,            document.getElementById( "mw-content-text" ) );

// Add range-add buttons before each of the buttons // that say "Compare selected revisions" var cmpSelRevsBtns = document.getElementsByClassName( "historysubmit" ); for( var i = 0, n = cmpSelRevsBtns.length; i < n; i++ ) { var rangeBtn = document.createElement( "button" ); rangeBtn.textContent = "Add range to revdel template"; rangeBtn.className = "mw-ui-button + mw-ui-progressive"; rangeBtn.id = "cv-rd-add-range"; cmpSelRevsBtns[i].parentNode.insertBefore( rangeBtn, cmpSelRevsBtns[i] ); rangeBtn.addEventListener( "click", function ( evt ) {               evt.preventDefault;

var oldidStart = document.querySelector( "li.selected.after" ).dataset.mwRevid; var oldidEnd = document.querySelector( "li.selected.before" ).dataset.mwRevid;

// Add new row to ranges table var rangesTable = document.getElementById( "cv-rd-ranges" ).getElementsByTagName( "tbody" )[0]; var newRow = rangesTable.insertRow( rangesTable.rows.length ); newRow.insertCell( 0 ).appendChild( makeOldidLink( oldidStart ) ); newRow.insertCell( 1 ).appendChild( makeOldidLink( oldidEnd ) ); newRow.insertCell( 2 ).innerHTML = "<input type='checkbox' />"; newRow.cells[2].childNodes[0].checked = true; newRow.cells[2].childNodes[0].addEventListener( "click", function {                    this.parentNode.previousElementSibling.childNodes[0].className = this.checked ? "" : "disabled";                } ); var deleteBtn = document.createElement( "button" ); deleteBtn.textContent = "Delete"; deleteBtn.className = "delete"; deleteBtn.addEventListener( "click", function {                    this.parentNode.parentNode.parentNode.removeChild( this.parentNode.parentNode );               } ); newRow.insertCell( 3 ).appendChild( deleteBtn ); } );       }

// Panel submission handler document.getElementById( "cv-rd-submit" ).addEventListener( "click", function {            $( this ).prop( "disabled", true );            $( "#cv-rd-status" ).empty;            var urls = Array.prototype.map.call( document.getElementById( "cv-rd-urls" ).children, function ( e ) { return e.children[1].value; } );           var deferreds = [ addCvRevdel( urls ) ];            if( document.getElementById( "cv-rd-cclean" ).checked ) {                deferreds.push( addCclean( urls ) );            }            $.when.apply( $, deferreds ).then( function  { // Return to content page document.querySelector( "#ca-view a" ).click; }, function { $( this ).prop( "disabled", false ); }.bind( this ) );       } );

// "Add URL" handler document.getElementById( "cv-rd-url-add" ).addEventListener( "click", function {            var numUrls = document.querySelectorAll( "#cv-rd-urls div" ).length;            if( numUrls < 3 ) {                var newDiv = document.createElement( "div" );                newDiv.innerHTML = "<label for='cv-rd-url" + urlCounter + "'>URL: "+                    "<input type='text' id='cv-rd-url" + urlCounter +                    "' class='mw-ui-input mw-ui-input-inline'/>"+                    "<button class='mw-ui-button mw-ui-quiet'>Remove ";                document.getElementById( "cv-rd-urls" ).appendChild( newDiv );                urlCounter++;                this.disabled = numUrls >= 2;            }        } );

// Remove URL handler document.getElementById( "cv-rd-urls" ).addEventListener( "click", function ( e ) {           var numUrls = document.querySelectorAll( "#cv-rd-urls div" ).length;            if( e.target && e.target.nodeType === 1 && numUrls > 1 && e.target.tagName.toLowerCase === "button" ) {               this.removeChild( document.getElementById( e.target.previousElementSibling.getAttribute( "id" ) ).parentNode );                document.getElementById( "cv-rd-url-add" ).disabled = false;            }        } );

// Close handler document.getElementById( "cv-rd-close" ).addEventListener( "click", function {            $( "#cv-revdel" ).remove;            $( ".cv-rd-add-range" ).remove;        } );

document.querySelector( "#cv-rd-urls input" ).focus; }

mw.loader.using( [ "mediawiki.api", "mediawiki.util" ], function {

pageName = mw.config.get( "wgPageName" );

if( mw.config.get( "wgAction" ) == "history" ) { var link = mw.util.addPortletLink( "p-cactions", "#", "Request CV revdel", "pt-cv-revdel" ); link.addEventListener( "click", load ); if( mw.util.getParamValue( "open_cv_revdel" ) === "true" ) { load; }       } else if( mw.config.get( "wgNamespaceNumber" ) >= 0 ) { var historyPage = mw.util.getUrl( pageName, { "action": "history", "open_cv_revdel": "true" } ); var link = mw.util.addPortletLink( "p-cactions", historyPage, "Request CV revdel", "pt-cv-revdel" ); }   } ); } ); // mw.loader.load('/w/index.php?title=User:BrandonXLF/ShowUserGender.js&action=raw&ctype=text/javascript'); // User:BrandonXLF/ShowUserGender.js mw.loader.load( '/w/index.php?title=User:Chlod/Scripts/Deputy.js&action=raw&ctype=text/javascript' ); // Backlink: User:Chlod/Scripts/Deputy.js importScript( 'User:Novem Linguae/Scripts/GANReviewTool.js' ); // Backlink: User:Novem Linguae/Scripts/GANReviewTool.js