User:23W/DecadesInTelevision.js
Appearance
< User:23W
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:23W/DecadesInTelevision. |
if (wgTitle.search(/\d+s in .*? television/i) != -1) {
function fixCategories() {
var textBox = document.getElementById('wpTextbox1').value;
var regExp = /\[\[Category:Years in (.*?) television/i;
var country = textBox.match(regExp)[1];
replaceTextBox = textBox.replace(/\[\[Category:Years in (.*?) television(\|.*?)?\]\]/gi,"\x5B\x5BCategory:Decades in $1 television\x5D\x5D")
.replace(/\[\[Category:(\d+s) in television(\|.*?)?\]\]/gi,"\x5B\x5BCategory:$1 in television\|" + country + "\x5D\x5D")
.replace(/\[\[Category:(\d+s) in (?!television)(.*?)(\|.*?)?\]\]/gi,"\x5B\x5BCategory:$1 in $2|Television\x5D\x5D")
.replace(/\[\[Category:Television in .*?\]\]\n/gi,"")
.replace(/\{\{CatRel/gi,"\x7B\x7BCategory see also")
.replace(/\{\{Cat(egory see also|Pair)\|(.*?\|.*?\}\})/gi,"\x7B\x7BCategory pair|$2");
document.getElementById('wpTextbox1').value = replaceTextBox;
document.getElementById('wpSummary').value = "\x5B\x5BCategory:Years in " + country + " television\x5D\x5D to \x5B\x5BCategory:Decades in " + country + " television\x5D\x5D, fixing keys (\x5B\x5Ben:User:23W/DecadesInTelevision.js|script-assisted\x5D\x5D)"
}
window.onload = fixCategories;
}