User:452/editHelper

//<!-- /* This is 452's autoreplacement script. It all started when Wikia neglected to strip newlines from edit summaries, meaning that when "enter" was pressed, there was an "enter" recorded in the edit summary. so 452 wrote a snippet of javascript to strip newlines on submit. Sometime later, 452 expanded that JS snippet into a semi-automated bot. After approving several hundred bot edits, 452 realised that it would save on bot edits later if the automated edits were just done during normal editing, and converted the script to perform the same replacements every time the edit page was opened Some feature-creep later, and you're looking at the end result. I take full responsibility for all edits made by this script. All auto-replacements made by this scripts are still edits made by me. If I have made any error when editing, please inform me and I will fix all occurrences of the error. Features: * Auto-replacement for HTML entities * Strip lrm and nbsp characters * Remove whitespace from ends of lines * Auto-replacements for common things to replace * Warnings about other content that needs to be replaced manually * Displays list of words to avoid in articles * Automatic removal of underscores in links * A drop-down list of all piped links * Refresh detected issues list to see remaining issues * Automatically show changes on submit if the page has been changed. * Automatically add "+auto" to edit summary, if auto-replacements have been made. (Note: this is not to "excuse" bad edits may by the autoreplacement script.) */ window.EditHelperActive = 1; if (mw.util.getParamValue('noauto')) window.EditHelperActive = 0; if (mw.util.getParamValue("nulledit")) window.EditHelperActive = 0; if (mw.config.get("wgPageName").indexOf('.js') != -1) window.EditHelperActive = 0; if (mw.config.get("wgPageName").indexOf('.css') != -1) window.EditHelperActive = 0; if (mw.config.get("wgPageName").indexOf('editHelper') != -1) window.EditHelperActive = 0; if (mw.config.get("wgPageName").indexOf("Saints_Row_Wiki:Sandbox") == 0) window.EditHelperActive = 0; //Only run on edit pages, and not on nulledits, and not on javascript pages

if (mw.config.get("wgPageName").indexOf('.js') != -1) { if ($("#wpTextbox1").val.indexOf("var debugversion = '") != -1) $("#wpTextbox1").val($("#wpTextbox1").val.replace(new RegExp(/var debugversion = '\d+';/, 'g'), "var debugversion = '"+(new Date).getTime+"';")); if ($("#wpTextbox1").val.indexOf("var debugcolour = '") != -1) { do { debugcolor = ["red", "blue", "yellow", "pink", "orange", "purple", "green"][Math.floor((Math.random*7))]; } while($("#wpTextbox1").val.indexOf("var debugcolour = '"+debugcolor) != -1); $("#wpTextbox1").val($("#wpTextbox1").val.replace(new RegExp(/var debugcolour = '\w+';/, 'g'), "var debugcolour = '"+debugcolor+"';")); } }

if (window.EditHelperActive) { debug452("editHelper active 2020-1");

window.editHelperDirty = false; // editHelperDirty is used to determine whether potentially problematic changes have been made without viewing the diff.

RegExp.escape = function(text) { return text.replace(/[-[\]{}*+?.,\\^$|#\s]/g, "\\$&"); };

Obj_pageContents = function(pageContents) { var page = pageContents; this.contents=function(replaceWith) { if (replaceWith == null) return page; else page = replaceWith; }      this.removeTrailingWhitespace=function { page = page.replace(/[^\S\r\n]+$/gm, ""); //remove trailing spaces from each line }      this.removeCaptionStop=function { page = page.replace(/(\|caption.*)\.\n/g, "$1\n"); }      this.pipedLinks=function { return page.match(/\[\[.[^\]]*\|[^\]]*]]/g); }      this.allLinks=function { return page.match(/\[\[.[^\]]*]]/g); }      this.allCats=function { return page.match(/\[\[.ategory:.[^\]]*]]/g); }      this.allFields=function { return page.match(/\n\|.[^=\n\|]*=/g); }      this.find=function(findStr, preserveCase) { if (preserveCase) { if (page.indexOf(findStr) !== -1) return true; } else { if (page.toLowerCase.indexOf(findStr.toLowerCase) !== -1) return true; }	 return false; }      this.replaceReg=function(find, repl, ignoredirty) { var temppage = page.replace(new RegExp(find, 'g'), repl); if (!ignoredirty && (page !== temppage)) { window.editHelperDirty = true; //console.log("page is now dirty after: "+find+" -> "+repl); }	 page = temppage; delete temppage; }      this.replaceAll=function(find, repl, ignoredirty) { var temppage = page.replace(new RegExp(RegExp.escape(find), 'g'), repl); if (!ignoredirty && (page !== temppage)) { //	 debug452("' "+find+" ' has been replaced with ' "+repl+" '"); window.editHelperDirty = true; //console.log("page is now dirty after: "+find+" -> "+repl); }	 page = temppage; delete temppage; };      this.removeBotSigs=function { var temppage = page .replace(/\(last edited: \[\[user:WikiaBot\|WikiaBot]], .*Z\)/g, "") .replace(/\(last edited: \[\[user:Wikia\|Wikia]], .*Z\)/g, "") .replace(/\(last edited: \[\[user:GlitchBot\|GlitchBot]], .*Z\)/g, "") .replace(/\/g, "") ;	 if (page !== temppage) { window.editHelperDirty = true; //	  console.log("page is now dirty after: remove bot sigs"); }	 page = temppage; delete temppage; }      this.removeLoop=function(searchstart, searchend) { //page = $("#mw-content-text").html; debug452("Before removing "+searchstart+" : "+page.length); var incr = 0; while((f2 = f1 = page.toLowerCase.indexOf(searchstart)) != -1) { do { f2 = page.toLowerCase.indexOf(searchend, f2+searchend.length); if (f2 == -1) { f2 = f1; break; } //failsafe for infinite loop caused by imbalance. if (++incr > 500) break; //failsafe for infinite loop caused by imbalance. } while(page.substring(f1, f2+searchend.length).split(searchstart).length != page.substring(f1, f2+searchend.length).split(searchend).length); page = page.replace(page.substring(f1, f2+searchend.length), ""); }

debug452("After removing "+searchstart+" : "+page.length); }      this.removeTemplate=function(template) { this.removeLoop(""); }      this.removeLinks=function { this.removeLoop("", ""); }      this.doGalleryReplacements=function(iteration) {		  //{ galleryArray = page.match(/{{gallery.[^\}]*}}/g); // problem: references. if (galleryArray) { $.each( galleryArray, function(k, v) { 	    /* Copy/pasted filenames may have URL encoded characters */ 	     if(v.search(/%\d\d/) != -1) {	       window.editHelperDirty = true; //console.log("page is now dirty after galleryreplacements 1");	       galleryArrayReplaced = decodeURIComponent(v);	       page = page.replace(RegExp(RegExp.escape(v),"g"),galleryArrayReplaced);	       v = galleryArrayReplaced;	     }

/* Automatically use filename as caption */ var lines = v.split("\n").slice(1,-1); $.each(lines, function(j, line) {	      if (!line.length) return;	       if(line.indexOf("|") == -1) {		 window.editHelperDirty = true; //console.log("page is now dirty after galleryreplacements 2");		 caption = line.slice(0, line.lastIndexOf("."));		 page = page.replace(RegExp(RegExp.escape("\n"+line+"\n"),"g"),"\n"+line+"|"+caption+"\n");	       }	       if(line.indexOf("|Saints Row variants - ") != -1) {		 newline = (line.replace("|Saints Row variants - ", "|")+" in Saints Row")			.replace(" - front right in Saints Row", " variant - front right in Saints Row")			.replace(" - front left in Saints Row", " variant - front left in Saints Row")			.replace(" - rear right in Saints Row", " variant - rear right in Saints Row")			.replace(" - rear left in Saints Row", " variant - rear left in Saints Row");		 page = page.replace(RegExp(RegExp.escape(line),"g"),newline); }	      if(line.indexOf("|Map in Saints Row 2 - ") != -1) { newline = (line.replace("|Map in Saints Row 2 - ", "|")+" Map in Saints Row 2"); page = page.replace(RegExp(RegExp.escape(line),"g"),newline); }	    });

galleryArrayReplaced = v				    .replace(/.jpg.jpg/g,".jpg")		 /* duplicate extension when copy/pasting */ .replace(/.png.png/g,".png")		 /* duplicate extension when copy/pasting */ .replace(/_/g," ")			  /* replace _ with space */ .replace(/\.\n/g,"\n")		      /* remove unnecessary. from caption */ .replace(/Saints Row\n/g,"Saints Row\n") /* italicise game names in captions */ .replace(/Saints Row 2\n/g,"Saints Row 2\n") .replace(/Saints Row The Third\n/g,"Saints Row: The Third\n") .replace(/Saints Row The Third\n/g,"Saints Row: The Third\n") .replace(/Saints Row IV\n/g,"Saints Row IV\n") .replace(/SR2 variant screenshot\n/g,"variant in Saints Row 2\n") .replace(RegExp(RegExp.escape("|"+mw.config.get('wgTitle')+"\n"),"gi"), "\n") ;	    page = page.replace(RegExp(RegExp.escape(v),"g"),galleryArrayReplaced); v = galleryArrayReplaced; /* update current gallery */

});	  if (iteration == 0) this.doGalleryReplacements(1);	 }       }       this.autoReplacements=function {	 if (mw.config.get("wgSiteName") != "Saints Row Wiki") return;	 if(mw.config.get("wgNamespaceNumber")==mw.config.get("wgNamespaceIds")["mediawiki"]) return; // never autoreplace in mediawiki namespace.

if (!window.editHelperDirty) var oldPage = this.contents;

if (typeof htmlentities == "undefined") alert("no htmlentities"); else this.contents(htmlentities.encode(this.contents)); //race condition, called earliest from ready function

if (mw.config.get("wgNamespaceNumber") != 0) { //Restore DPL-related characters this.replaceAll("&sup2;", "²"); this.replaceAll("&brvbar;", "¦"); this.replaceAll("&laquo;", "«"); this.replaceAll("&raquo;", "»"); }	 if (typeof oldPage == "string") if (oldPage != this.contents) addIssue("replaced html entities", 1); //Replace non-standard quotes with standard quotes this.replaceAll("&#039;", "'"); this.replaceAll("&rsquo;", "'"); this.replaceAll("&lsquo;", "'"); this.replaceAll("&rdquo;", "\"");	 this.replaceAll("&ldquo;", "\"");

if (this.find("&lrm;")) addIssue("lrm removed", 1); if (this.find("&rlm;")) addIssue("rlm removed", 1); this.replaceAll("&lrm;", ""); this.replaceAll("&rlm;", ""); this.replaceAll("&#x9;","     ");

if (this.find(" ") && (mw.config.get("wgNamespaceNumber")==0)) { //only remove in main addIssue("nbsp removed", 1); this.replaceAll(" ", " "); }	 if (this.find("&ZeroWidthSpace;") && (mw.config.get("wgNamespaceNumber")==0)) { //only remove in main addIssue("ZeroWidthSpace removed", 1); this.replaceAll("&ZeroWidthSpace;", " "); }	 this.replaceAll("|Gameplay from the mission.", "", 1); this.replaceAll("|Gameplay from the mission", "", 1); this.replaceAll("\nFile:", "\n"); //remove File: prefix in galleries this.replaceAll("\nfile:", "\n"); //remove file: prefix in galleries this.doGalleryReplacements(0); this.replaceAll("User452", "user452", 1); this.replaceAll("User:452", "user:452", 1); this.replaceAll("|user452]]", "|452]]", 1); this.replaceAll(":user452", ":452", 1); this.replaceAll("/user452", "/452", 1);

this.replaceAll("[[Help:Cite", "[[Help:Refs", 1);

this.replaceAll("[[Message Wall:", "[[User talk:", 1);	 this.replaceAll("[[Message_Wall:", "[[User talk:", 1);

this.replaceAll(" ", "[[");	 this.replaceAll(" ", "]]"); //	 this.replaceAll(",\"", "\",");

this.replaceAll("	 this.replaceAll(" this.replaceAll("

if (this.find("to-do blogheader")) { addIssue("updating header", 1); this.replaceAll("to-do blogheader", "to-do forumheader", 1); }

this.replaceAll("[[Category:Nav Templates", "[[Category:Navboxes", 1);										 this.replaceAll("[[Category:Nav_Templates", "[[Category:Navboxes", 1);

this.replaceAll(":", ":");

this.removeBotSigs;

this.removeTrailingWhitespace; this.removeCaptionStop;

/* Italicise links, incorrect formatting can cause issues. */	 this.replaceAll("Saints Row", "Saints Row"); this.replaceAll("Saints Row 2", "Saints Row 2"); this.replaceAll("Saints Row: The Third", "Saints Row: The Third"); this.replaceAll("Saints Row IV", "Saints Row IV"); this.replaceAll("'Saints Row'", "Saints Row"); this.replaceAll("'Saints Row 2'", "Saints Row 2"); this.replaceAll("'Saints Row: The Third'", "Saints Row: The Third"); this.replaceAll("'Saints Row IV'", "Saints Row IV");

/* Anything that may result in dirty with no change should go above here */

if (typeof oldPage == "string") if (oldPage == this.contents) window.editHelperDirty = false;

if(mw.config.get("wgNamespaceNumber")%2!=0) { this.replaceAll("452<"+"!"+"> ", "452 "); }	 if(mw.config.get("wgNamespaceNumber")==mw.config.get("wgNamespaceIds")["user_talk"]) { addIssue("Hey dipshit, since you keep fucking forgetting: INCLUDE THE USERNAME, AND A DIFF LINK."); }

if(mw.config.get("wgNamespaceNumber") != mw.config.get("wgNamespaceIds")[""]) return;	  // rules after this point are only autoreplaced in the main namespace this.replaceAll("[[:Category:Task Force/", "[[:Category:To-do/",1);	 this.replaceAll("[[:Category:Task_Force/", "[[:Category:To-do/",1);

this.replaceAll("[[Category: ", "[[Category:", 1);	 this.replaceAll(",", ",");	 this.replaceAll(",'", "',");	 this.replaceAll("== ", "==", 1);	 this.replaceAll(" ==", "==", 1);	 this.replaceAll("== ", "==", 1);	 this.replaceAll(" ==", "==", 1);	 this.replaceAll("== Description ==", "==Overview==", 1);	 this.replaceAll("==Description ==", "==Overview==", 1);	 this.replaceAll("==Description==", "==Overview==", 1);

this.replaceAll("saintsrow.wikia.com/wiki/", "saintsrow.wikia.com/", 1); this.replaceAll("	 this.replaceAll(" this.replaceAll("	 this.replaceAll(" this.replaceAll("	 this.replaceAll(" this.replaceAll("	 this.replaceAll(" this.replaceAll("	 this.replaceAll(" this.replaceAll("	 this.replaceAll(" this.replaceAll("	 this.replaceAll(" this.replaceAll("	 this.replaceAll(" this.replaceAll("	 this.replaceAll(" this.replaceAll("	 this.replaceAll(" this.replaceAll("	 this.replaceAll(" this.replaceAll("

this.replaceAll("||\n	 this.replaceAll("||

this.replaceAll("	 this.replaceAll("

this.replaceAll("🇨🇴", "🇨🇴", 1); this.replaceAll("🇨🇴", "🇨🇴", 1); //     this.replaceAll("your garage", "the garage"); this.replaceAll("the player's garage", "the garage");

this.replaceAll("the the ", "the "); this.replaceAll("based off of", "based on"); this.replaceAll("based off", "based on"); this.replaceAll("Loyalty mission", "Loyalty mission"); this.replaceAll("Saints Row (disambiguation)", "Disambiguation:Saints Row"); this.replaceAll("McManus (disambiguation)", "Disambiguation:McManus"); this.replaceAll("Stilwater University (disambiguation)", "Disambiguation:Stilwater University"); this.replaceAll(" ", ""); this.replaceAll(" ", ""); this.replaceAll(" ", ""); //     this.replaceAll("\n", "\n"); this.replaceAll(" ", "$");	 this.replaceAll(" ", "$"); this.replaceAll(" ", ""); this.replaceAll(" ", "");

this.replaceAll("", "", 1); this.replaceAll("", "", 1); this.replaceAll("", "", 1);

this.replaceAll("", "", 1); this.replaceAll("", "", 1); this.replaceAll("", "", 1);

//     this.replaceAll("Image:", "File:"); //replace Image: alias with File: this.replaceAll("\nFile:", "\n"); //remove File: prefix in galleries this.replaceAll("\nfile:", "\n"); //remove file: prefix in galleries this.replaceAll(" =File:", "="); //remove (unsupported) File: prefix in infoboxes this.replaceAll(" = File:", "= "); //remove (unsupported) File: prefix in infoboxes //this has a space because it was also altering "link=File:" in galleries. I'm kinda shocked I hadn't noticed this issue earlier. this.replaceAll("&bull;", "\n*"); this.replaceAll(" &bull;", "\n*"); this.replaceAll("= &bull;", "= *"); this.replaceAll("=&bull;", "= *"); this.replaceAll("= *", "=\n*"); this.replaceAll("=*", "=\n*"); this.replaceAll("	 this.replaceAll(" this.replaceAll("	 this.replaceAll(" //");	 this.replaceAll(":Mods include", ":Mods");	 this.replaceAll("Mods include", ":Mods");	 this.replaceAll(":Paints available are", ":Paints");	 this.replaceAll("\nPaints available are", "\n:Paints");	 this.replaceAll("Paints available are", "\n:Paints");	 this.replaceAll("\nPROS\n", "\n;Pros\n");	 this.replaceAll("\nPROS:\n", "\n;Pros\n");	 this.replaceAll("\n;PROS\n", "\n;Pros\n");	 this.replaceAll("\nCONS\n", "\n;Cons\n");	 this.replaceAll("\nCONS:\n", "\n;Cons\n");	 this.replaceAll("\n;CONS\n", "\n;Cons\n");	 this.replaceAll("Cheat Code", "Cheat");	 this.replaceAll('gallery type="slideshow" style="float:right"', 'gallery type="slideshow" position="right"');	 this.replaceAll(" this.replaceAll("	 this.replaceAll(" this.replaceAll("

this.replaceAll("|nationality =\n", ""); this.replaceAll("| rear_image	=\n", ""); this.replaceAll("| rear_image      =\n", ""); this.replaceAll("| rear_image     =\n", ""); this.replaceAll("| rear_image    =\n", ""); this.replaceAll("| rear_image   = \n", ""); this.replaceAll("| rear_image   =\n", ""); this.replaceAll("\n| ", "\n|",1); this.replaceAll("\n |", "\n|",1); this.replaceAll("|TableData", "|ExtraInfo", 1);

//	 this.replaceAll("|imagewidth", "|size     ");

this.replaceAll("|previous stronghold ", "|previous	   "); this.replaceAll("|next stronghold    ", "|next		"); this.replaceAll("|previous mission ", "|previous	 "); this.replaceAll("|next mission    ", "|next	     ");

/*	 if (this.find(".\n|caption")) { this.replaceAll(".\n|caption", "\n|caption"); addIssue("dot caption"); }	 if (this.find(".\n|games")) { this.replaceAll(".\n|games", "\n|games"); addIssue("dot caption"); }	 if (this.find("{{activity") && this.find("\n|objective") && !this.find("\n|vehicle")) { //}} this.replaceAll("\n|objective", "\n|vehicle = \n|objective"); addIssue("added infobox fields", 1); }	 if (this.find("{{activity") && this.find("\n|reward") && !this.find("\n|location")) { //}} this.replaceAll("\n|reward", "\n|location    = \n|reward"); addIssue("added infobox fields", 1); }	 if (this.find("{{DLC") && this.find("\n|size") && !this.find("\n|filesize")) { //}} this.replaceAll("\n|size", "\n|filesize"); addIssue("replaced infobox fields", 1); }	 if (this.find("{{DLC") && this.find("\n|links ")) { //}} addIssue("removing retired link field", 1); this.replaceAll("\n|links	=", ""); this.replaceAll("\n|links      =", ""); this.replaceAll("\n|links     =", ""); this.replaceAll("\n|links    =", ""); this.replaceAll("\n|links   =", ""); this.replaceAll("\n|links  =", ""); this.replaceAll("\n|links =", ""); this.replaceAll("\n|links =", ""); }	 if (this.find("{{DLC") && this.find("\n|vehicle ") && !this.find("\n|vehicles")) { //}} this.replaceAll("\n|vehicle ", "\n|vehicles"); addIssue("replaced infobox fields", 1); }	 if (this.find("{{DLC") && this.find("\n|imagewidth") && !this.find("\n|size")) { //}} this.replaceAll("\n|imagewidth", "\n|size     "); addIssue("replaced infobox fields", 1); }	 if (this.find("{{neighborhood") && this.find("\n|imagewidth")) { //}} this.replaceAll("\n|imagewidth", "\n|size     "); addIssue("replaced infobox fields", 1); }	 if (this.find("{{neighborhood") && this.find("\n|region")) { //}} this.replaceAll("\n|regions ", "\n|territories"); addIssue("replaced infobox fields", 1); }	 if (this.find("{{neighborhood") && this.find("\n|activities") && !this.find("\n|buildings")) { //}} this.replaceAll("\n|activities", "\n|buildings = \n|activities"); addIssue("added infobox fields", 1); }	 if (this.find("{{neighborhood") && this.find("\n|games") && !this.find("\n|nearby")) { //}} this.replaceAll("\n|games", "\n|nearby      = \?\n|games"); addIssue("added infobox fields", 1); }	 if (this.find("{{building") && this.find("\n|imagewidth")) { //}} this.replaceAll("\n|imagewidth", "\n|size     "); addIssue("replaced infobox fields", 1); }	 if (this.find("{{building") && this.find("\n|enterable") && !this.find("\n|missions")) { //}} this.replaceAll("\n|enterable", "\n|missions= \n|enterable"); addIssue("added infobox fields", 1); }	 if (this.find("{{building") && this.find("\n|hood") && !this.find("\n|owner")) { //}} this.replaceAll("\n|hood", "\n|owner= \n|hood"); addIssue("added infobox fields", 1); }	 if (this.find("{{building") && this.find("\n|owner") && !this.find("\n|type")) { //}} this.replaceAll("\n|owner", "\n|type= \?\n|owner"); addIssue("added infobox fields", 1); }	 if (this.find("{{vehicle") && this.find("\n|areas") && !this.find("\n|missions")) { //}} this.replaceAll("\n|areas", "\n|missions= \n|areas"); addIssue("added infobox fields", 1); }	 if (this.find("{{vehicle") && this.find("\n|areas") && !this.find("\n|missions")) { //}} this.replaceAll("\n|areas", "\n|missions= \n|areas"); addIssue("added infobox fields", 1); }	 if (this.find("{{vehicle") && this.find("\n|appearances")) { //}} this.replaceAll("\n|appearances", "\n|games     "); addIssue("replaced infobox fields", 1); }	 if (this.find("{{vehicle") && this.find("\n|front_image")) { //}} this.replaceAll("\n|front_image7", "\n|image7     "); this.replaceAll("\n|front_image6", "\n|image6     "); this.replaceAll("\n|front_image5", "\n|image5     "); this.replaceAll("\n|front_image4", "\n|image4     "); this.replaceAll("\n|front_image3", "\n|image3     "); this.replaceAll("\n|front_image2", "\n|image2     "); this.replaceAll("\n|front_image", "\n|image     "); addIssue("replaced infobox fields", 1); }	 if (this.find("{{weapon") && this.find("\n|imagewidth")) { //}} this.replaceAll("\n|imagewidth", "\n|size     "); addIssue("replaced infobox fields", 1); }	 if (this.find("{{character") && this.find("\n|vehicles") && !this.find("\n|weapons")) { //}} this.replaceAll("\n|vehicles", "\n|weapons = \?\n|vehicles"); addIssue("added infobox fields", 1); }	 if (this.find("{{character") && this.find("\n|voice") && !this.find("\n|games")) { //}} this.replaceAll("\n|voice", "\n|games = \?\n|voice"); addIssue("added infobox fields", 1); }	 if (this.find("{{character") && this.find("\n|occupations") && !this.find("\n|affiliations")) { //}} this.replaceAll("\n|occupations", "\n|affiliations = \?\n|occupations"); addIssue("added infobox fields", 1); }	 if (this.find("{{mission\n") && this.find("\n|objective") && !this.find("\n|type")) { //}} this.replaceAll("\n|objective", "\n|type = \n|objective"); addIssue("added infobox fields", 1); }	 if (this.find("{{mission\n") && this.find("\n|objective") && !this.find("\n|cutscene")) { //}} this.replaceAll("\n|objective", "\n|cutscene = \n|objective"); addIssue("added infobox fields", 1); }	 if (this.find("{{mission\n") && this.find("\n|cutscene") && !this.find("\n|gang")) { //}} this.replaceAll("\n|cutscene", "\n|gang = \n|cutscene"); addIssue("added infobox fields", 1); }	 if (this.find("{{mission\n") && this.find("\n|objective") && !this.find("\n|vehicle ")) { //}} this.replaceAll("\n|objective", "\n|vehicle = \n|objective"); addIssue("added infobox fields", 1); }	 if (this.find("{{mission\n") && this.find("\n|vehicle") && !this.find("\n|homie")) { //}} this.replaceAll("\n|vehicle", "\n|homie = \n|vehicle"); addIssue("added infobox fields", 1); }	 if (this.find("{{mission\n") && this.find("\n|objective") && !this.find("\n|marked_enemies")) { //}} this.replaceAll("\n|objective", "\n|marked_enemies = \?\n|minimum_kills = \?\n|objective"); addIssue("added infobox fields", 1); }	 if (this.find("\n|capacity") && !this.find("\n|convertible ")) { this.replaceAll("\n|capacity", "\n|convertible = \?\n|capacity"); addIssue("added convertible field", 1); }	 if (this.find("\n|capacity") && !this.find("\n|doors ")) { this.replaceAll("\n|capacity", "\n|doors = \?\n|capacity"); addIssue("added doors field", 1); }

if (this.find("\n|obtaining") && ( !this.find("\n|areas") ||!this.find("\n|homies") ||!this.find("\n|gangs") ||!this.find("\n|unlockable") ||!this.find("\n|mission") )) {	  addIssue("added infobox fields", 1); if (!this.find("\n|homies")) this.replaceAll("\n|obtaining", "\n|homies = \n|obtaining"); if (!this.find("\n|gangs")) this.replaceAll("\n|obtaining", "\n|gangs = \n|obtaining"); if (!this.find("\n|unlockable")) this.replaceAll("\n|obtaining", "\n|unlockable = \n|obtaining"); if (!this.find("\n|missions")) this.replaceAll("\n|obtaining", "\n|missions = \n|obtaining"); if (!this.find("\n|areas ")) this.replaceAll("\n|obtaining", "\n|areas = \n|obtaining"); }	 if ($("a[title='Category:Template is missing parameters']").length && $("#wpSummary").val.indexOf("added infobox fields") != -1) { addIssue("update the infobox"); }

this.replaceAll("The Protagonist", "The Protagonist"); this.replaceAll("The Protagonist", "The Protagonist"); this.replaceAll("The Protagonist", "Playa"); this.replaceAll("|Protagonist|", "|Playa|"); this.replaceAll("Protagonist Female", "Playa Female"); this.replaceAll("Protagonist Male", "Playa Male"); this.replaceAll("the Playa", "Playa"); this.replaceAll("The Playa", "Playa"); this.replaceAll("the Playa", "Playa"); this.replaceAll("The Playa", "Playa");

this.replaceAll("Crib", "Crib"); this.replaceAll("Homie", "Homie"); this.replaceAll("Saints", "Saints"); this.replaceAll("http&", ""); this.replaceAll("Http://deckers.die", ""); this.replaceAll("Http://deckers.die", "http://deckers.die"); //     this.replaceAll("Http://deckers.die|", "http://deckers.die"); this.replaceAll("[|http://deckers.die]", ""); /* Italicise headings */ this.replaceAll("=Saints Row=", "=Saints Row="); this.replaceAll("=Saints Row 2=", "=Saints Row 2="); this.replaceAll("=Saints Row: The Third=", "=Saints Row: The Third="); this.replaceAll("=Saints Row IV=", "='Saints Row IV''="); this.replaceAll('border="1" cellpadding="0" cellspacing="0"', ""); this.replaceAll('border="0" cellpadding="0" cellspacing="0"', ""); this.replaceAll('border="0" cellpadding="1" cellspacing="1"', ""); this.replaceAll('style="padding:0px !important;margin:0px !important;text-align:center" class="wikitable sortable popout"', 'class="wikitable sortable popout centertext"'); this.replaceAll('style="padding:0px !important;margin:0px !important;text-align:center;width:100%" class="wikitable sortable"', 'class="wikitable sortable fullwidth centertext"'); this.replaceAll('style="padding:0px;text-align:center;width:100%" class="wikitable sortable"', 'class="wikitable sortable fullwidth centertext"'); this.replaceAll('style="text-align:center" width=100% class="wikitable sortable popout"', 'class="wikitable sortable fullwidth centertext popout"'); this.replaceAll('style="text-align:left" width=100% class="wikitable sortable"', 'class="wikitable sortable fullwidth left"'); this.replaceAll('style="text-align:center" class="wikitable sortable"', 'class="wikitable sortable centertext"'); this.replaceAll('style="text-align:center" class="wikitable sortable"', 'class="wikitable sortable centertext"');

this.replaceAll('cellpadding="3" border="3" style="border-collapse: collapse;"', 'class="article-table"'); this.replaceAll('style="padding:0px;text-align:center" class="wikitable sortable"', 'class="wikitable sortable centertext"'); this.replaceAll('style="text-align:center" width=100% class="wikitable sortable"', 'class="wikitable sortable fullwidth centertext"'); this.replaceAll('style="width:100%;padding:0px;text-align:center" class="wikitable sortable"', 'class="wikitable sortable fullwidth centertext"'); this.replaceAll('style="text-align:center;vertical-align:top;" valign="top" width=100% class="wikitable sortable"', 'class="wikitable sortable fullwidth centertext"');

this.replaceAll("The player can fail the mission by dying, getting busted,","The mission can be failed by getting smoked or busted,"); this.replaceAll("The player can only fail the mission by dying, getting busted,","The mission can be failed by getting smoked or busted,");

this.replaceAll("screen in Saints Row.", "screen"); this.replaceAll("screen in Saints Row 2.", "screen"); this.replaceAll("screen in Saints Row: The Third.", "screen"); this.replaceAll("screen in Saints Row IV.", "screen");

this.replaceAll("newspaper clipping shown upon completion of the mission","newspaper clipping from the completion screen and Newspaper Clipboard"); this.replaceAll("Loading screen shown after ","Loading screen used after completing ");

this.replaceAll("%28", "(", 1);	 this.replaceAll("%29", ")", 1); this.replaceAll("%26", "&", 1); this.replaceAll("%27", "'", 1); this.replaceAll("%22", "\"", 1);	 this.replaceAll("%2C", ",", 1);

if (this.find("{{mission") && !this.find("[\s]*objective[\s]*\=[\s]*([\s\S]*?)\n\|/g;	    match = replaceRx.exec(this.contents);	     if (match && match[1][0] != "|" && match[1].trim != "?") {	       after = before = match[1];	       after = after.replace(/\[\[[^\*?\|([\s\S]*?)\]\]/g, "$1")			      .replace(/\[\[([\s\S]*?)\]\]/g, "$1")			      .replace(/\n/g, "]]\n")+"]]"; index = 1; while(after.match(/\n\*/g) != null) { after = after.replace(/\*[\s]*/, "[[#obj"+index+"|");		  index++;	       }	       after = after.replace(/\[\[#obj/g, "*[[#obj");	       after2 = after.replace(/\]\]/g, "}}").replace(/\*\[\[#obj/g, ";{{a|obj")+"\n";	       this.replaceAll(before, after);	       this.contents(after2+this.contents);	     }	 }	 this.removeTrailingWhitespace;

/* if there are no actual changes, cancel dirty status */ if (typeof oldPage == "string") if (oldPage == this.contents) window.editHelperDirty = false; } // end autoReplacements } //end Obj_pageContents presubmit = function( event ) { $("#wpSummary").val($("#wpSummary").val.replace(/\n/g,"")); //replace newlines in edit summary if (window.skip) return; //Is this still necessary?

edithelper;

if (window.editHelperDirty) { /* if page is dirty, force display of diff */ event.preventDefault; event.stopImmediatePropagation; $("#autoreplacemessage").remove; addIssue("",0,"autoreplacemessage", "color:red;")

$(".modalWrapper").remove; $(".blackout").remove window.setTimeout(function { $("#wpDiff").click;},100); //click "show changes" button. window.editHelperDirty = false; //redundant }    }     replaceAll = function(find, replace, str) { return str.replace(new RegExp(RegExp.escape(find), 'g'), replace); }    addIssue = function(issue, summary, id, style, preformatted) { if (id == "autoreplacemessage") issue = "Auto-replacements have been made, check changes. (noauto?)"; if (!$("#autoIssues").length) { var autoIssues = '  '

if ($("#wpTextbox1")) $("#wpTextbox1").before(autoIssues); else if ($("#wikiPreview").length) $("#wikiPreview").before(autoIssues); //unsure what this line is for. }      if ($("#wpSummary").val.indexOf(issue) != -1 || $("#autoIssues").html.indexOf(issue) != -1) return; if(preformatted == 1) $("#autoIssues ul").append(issue); else $("#autoIssues ul").append(""+issue+""); if (mw.util.getParamValue('section') == "new") return; if (id == "autoreplacemessage" && ($("#wpSummary").val.indexOf("+auto") == -1)) { $("#wpSummary").val($("#wpSummary").val+") (+auto"); } else if (summary == 1) { if ($("#wpSummary").val) $("#wpSummary").val($("#wpSummary").val+", "+issue); else $("#wpSummary").val(issue); }    }     edithelper = function { debug452("editHelper main "); if (!$("#wpTextbox1").length) { debug452("no textarea!"); return; } if (!$("#wpTextbox1").val.length) { debug452("textarea empty!"); return; } if ($("#autoIssues").length) $("#autoIssues").remove;

editPage = new Obj_pageContents($("#wpTextbox1").val); if ($("#wpTextbox1").val !== editPage.contents) addIssue("Something is wrong: No auto-replacements have been made, but the variables don't match."); editPage.autoReplacements; allLinksArray = editPage.allLinks; if(mw.config.get("wgNamespaceNumber") != mw.config.get("wgNamespaceIds")["template"]) { //don't autoreplace underscores in links in template, as they may be parameters. if (allLinksArray) { $.each( allLinksArray, function(k, v) { 	    if (v.toLowerCase.indexOf("[[file") !== -1) return;	     if (v.toLowerCase.indexOf("[[talk") !== -1) return;	     if (v.toLowerCase.indexOf("[[help") !== -1) return;	     if (v.indexOf("_") !== -1) {	       if (v.toLowerCase.indexOf("[[user") !== -1) return;	       editPage.replaceAll(v, v.replace(/_/g, " "));	     }	   });	 }       }       allFieldsArray = editPage.allFields;       if(mw.config.get("wgNamespaceNumber") == mw.config.get("wgNamespaceIds")[""]) {	 if (allFieldsArray) {	   max_field_length = 0;	   $.each( allFieldsArray, function(k, v) { 	     if(max_field_length < v.slice(1,-1).trim.length) max_field_length = v.slice(1,-1).trim.length;	   });	   $.each( allFieldsArray, function(k, v) { 	     if (v.slice(1,-1).length == max_field_length+2) return;	     editPage.replaceAll(v, "\n"+(v.slice(1,-1).substr(0,max_field_length+2))+"=");	   });	 }       }       allCatsArray = editPage.allCats;       if (typeof allCatsArray == "Array") {	 allCatsLen = allCatsArray.length;	 $.unique(allCatsArray);	 if (allCatsLen != allCatsArray.length) addIssue("duplicate categories detected");       }

if (window.editHelperDirty) { addIssue("",0,"autoreplacemessage"); }      editPage.removeTrailingWhitespace; //does not mark as dirty. $("#wpTextbox1").val(editPage.contents); /* End of replacements section. Changes are not saved after this point. */      if(mw.config.get("wgNamespaceNumber")==0 && !editPage.find("

if (editPage.find("index.php")) addIssue("index.php"); if (editPage.find("blog:")) addIssue("blog"); if (editPage.find("ac_metadata")) addIssue("ac_metadata");

if (editPage.find("|'''You")) addIssue("Old style youtube ref found"); if (editPage.find("|'''Image")) addIssue("Old style image ref found"); if (editPage.find("#t=")) addIssue("#t="); //", "original", "official", "third street", "confirm", "indicat", "<span", "<p", "<div", "file", "Image:", "", "& ", "Saints Row 1", " Saints Row", "The Luchadores", "Tera Patrick", "Gameplay from the mission", "the the", "[{", "{[", "]] [[", "mdash", "ndash", "|when?}}", "advised", "stillwater", "off of");

/* remove valid false positives matching avoidwords - this is not saved */ editPage.replaceAll("youtube=", "", 1); //remove false positive, ignore dirty editPage.replaceAll("See http", "", 1); //remove false positive, ignore dirty editPage.replaceAll("William", "", 1); //remove false positive, ignore dirty editPage.replaceAll("Roddy", "", 1); //remove false positive, ignore dirty editPage.replaceAll("De Plane Boss", "", 1); //remove false positive, ignore dirty editPage.replaceAll("Note:", "", 1); //remove false positive, ignore dirty editPage.replaceAll("Cat & Mouse", "", 1); //remove false positive, ignore dirty editPage.replaceAll("Docks & Warehouses", "", 1); //remove false positive, ignore dirty editPage.replaceAll("Hotels & Marina", "", 1); //remove false positive, ignore dirty editPage.replaceAll("Leather & Lace", "", 1); //remove false positive, ignore dirty editPage.replaceAll("Streaking & Flashing", "", 1); //remove false positive, ignore dirty editPage.replaceAll("Streaking & Flashing", "", 1); //remove false positive, ignore dirty editPage.replaceAll("", "", 1); //remove false positive, ignore dirty editPage.replaceAll("", "", 1); //remove false positive, ignore dirty /*      editPage.removeTemplate("quote"); editPage.removeTemplate("dialogue"); editPage.removeTemplate("story"); editPage.removeTemplate("fact"); editPage.removeTemplate("cleanup"); editPage.removeTemplate("reqimage"); editPage.removeTemplate("more"); editPage.removeTemplate("info"); editPage.removeTemplate("rating"); editPage.removeTemplate(""); //all //      editPage.removeLinks; window.test = editPage;

/* check for things which cannot be reliably auto-replaced */ if (editPage.find("\n")) addIssue(" at end of line"); if (editPage.find("<ref")) addIssue("Old style ref found"); if (editPage.find(" ") && !editPage.find(" */       if (editPage.find("addIssue("External link found");       if (editPage.find("[https://saintsrow.wikia")) addIssue("External link found");       if (editPage.find("[[w:")) addIssue("interwiki link found");       editPage.replaceAll("saintsrow.wikia", "", 1); //remove false positive, ignore dirty       if (editPage.find("wikia")) addIssue("wikia found");       if (editPage.find("wikipedia.org")) addIssue("Wikipedia link found");       if (editPage.find("wikipedia:")) addIssue("Wikipedia link found");       if (editPage.find("--")) addIssue("Why is there a --?");       for (var i = 0; i < avoidwords.length; i++) {	 if (!editPage.find(avoidwords[i)) {	    avoidwords.splice(i, 1); //removes words which are *not* found on the page.	    i--; //the array now has one fewer item.	 }       }       /* case-sensitive */       if (editPage.find("protagonist", 1)) avoidwords.push("protagonist");       if (editPage.find("the Protagonist", 1)) avoidwords.push("the Protagonist");       if (avoidwords.length) addIssue("Check: "+avoidwords.join(", "));

editPage = new Obj_pageContents($("#wpTextbox1").val); pipedLinksArray = editPage.pipedLinks; if (pipedLinksArray && pipedLinksArray.length) { var ignoreLinks = new Array(" in saints row","_in_saints_row","[controls|","[category:","[media:","[video:","[special:","[image:","[file:","[message","[user","[talk:","[:file:","[:image:","[:category:","[:template:","[disambig","[saints row wiki","[saints_row_wiki",")|","[#");	 $select = $(' ');	 $.each( pipedLinksArray, function(k, v) { for (i in ignoreLinks) if (v.toLowerCase.indexOf(ignoreLinks[i]) !== -1) return; $select.append($(' ').text(v)); });	 if ($select[0].length != 0) addIssue($(' ').append($select[0].length+" piped links found : ").append($select),"","","",1);      }       $("#autoIssues").prepend("refresh");       $("#editHelperRefresh").click(function { edithelper });       $(window).trigger('resize');

} //end edithelper

debug452("editHelper end"); function editHelperStart { debug452("editHelper start");

if (!$("#wpTextbox1").length) { debug452("no textarea!"); return; } if ($("#EditHelper-style").length) { debug452("!!!! double init!"); };

if (!$("#EditHelper-style").length) $('head').append('#autoIssues ul:empty:before {content: "EditHelper has found no issues";}#autoIssues li {margin: 0;line-height: normal;font-size: 12px;} ');

edithelper;

if (mw.util.getParamValue('showchanges')) { window.editHelperDirty = false; //	  $(window).off('beforeunload'); $("#wpDiff").trigger("click"); }	 if ($("#wpDiff").length) { $("#wpDiff").on("click", function( event ) {		 edithelper;

window.editHelperDirty = false; /* diff has been viewed, clear dirty status */ });	      var events = $._data($("#wpDiff")[0], 'events').click; //do auto-replace first.	       events.unshift(events.pop);

$("#wpDiff").on("click", function( event ) {		 $('body').on('DOMNodeInserted.diffclick', function(event) { if ($("#EditPageDialog header h3").length) $('body').off('.diffclick'); $("#EditPageDialog header h3").append(			$(" ", { id:"diffButton", style:"font-size: 14px;margin:0px 5px;float:right;", html:"Publish" }).click(function{ $("#editform").submit; })		   )		  });		});	     }	     if ($("#wpSubmit").length) {  //for TinyEditor

if (typeof $._data($("#wpSubmit")[0], 'events') != "undefined") { var temp = $(" ").on("click", function( event ) { presubmit(event); }); var tempevent = $._data($(temp)[0], 'events').click; $._data($("#wpSubmit")[0], 'events').click.unshift(tempevent.pop); } else { $("#wpSubmit").on("click", function( event ) { presubmit(event); }); }	    }	     if ($("form#editform").length) { var temp = $(" ").on("submit", function( event ) { presubmit(event); }); var tempevent = $._data($(temp)[0], 'events').submit; $._data($("form#editform")[0], 'events').submit.unshift(tempevent.pop); }    }     function editHelperInit { if (typeof htmlentities != "undefined") editHelperStart; else { debug452("htmlentities not found, edithelper waiting");

$.ajax({	  url: "https://saintsrow.fandom.com/index.php?title=MediaWiki:Common.js/htmlentities.js&action=raw&ctype=text/javascript",	   dataType: 'script',	   cache: true	 }).done(function  {	   debug452("htmlentities now loaded, edithelper starting");	   editHelperStart;	 }); }    }

$(function {      if (typeof window.TinyEditor == "undefined") editHelperInit;     }); }

/*	  var request = { format: 'json', action: 'query', prop: "revisions", titles: mw.config.get('wgPageName'), rvdifftotext: $('#wpTextbox1').val, token: mw.user.tokens.get("editToken") }	  new mw.Api.post(request).done(function(result) {	     diffhtml = result.query.pages[Object.keys(result.query.pages)].revisions[0].diff['*'];	     if (diffhtml.length == 0) diffhtml = "No changes "

SRWpopup("ModalDiff","Diff",diffhtml); });

//-->