Jump to content

User:Aidan9382/scripts/quickfix-enclose.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Aidan9382 (talk | contribs) at 07:09, 13 May 2022 (Move to seperate page). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* Fun fact about the below script
The mention of enclose=XYZ, without even having a syntaxhighlight tag, gets it put in [[:Category:Pages using deprecated enclose attributes]]
How fun :) */
var ef = document.editform, tb = ef.wpTextbox1, es = ef.wpSummary;
if (tb && tb.style.length == 0 && !(document.title.indexOf(".js") > -1 && document.title.indexOf(" talk:") == -1) && !es.value) {
	if (tb.value && tb.value.search("enclose=") > -1) { //I dont do JS, so lets just be inefficient
		tb.value = tb.value.replaceAll(" enclose=none"," inline");
		tb.value = tb.value.replaceAll("|enclose=none","|inline=1");
		tb.value = tb.value.replaceAll(" enclose=\"none\""," inline");
		tb.value = tb.value.replaceAll("|enclose=\"none\"","|inline=1");
		tb.value = tb.value.replaceAll(" enclose=div","");
		tb.value = tb.value.replaceAll("|enclose=div","");
		tb.value = tb.value.replaceAll(" enclose=\"div\"","");
		tb.value = tb.value.replaceAll("|enclose=\"div\"","");
		tb.value = tb.value.replaceAll(" enclose=pre","");
		tb.value = tb.value.replaceAll("|enclose=pre","");
		tb.value = tb.value.replaceAll(" enclose=\"pre\"","");
		tb.value = tb.value.replaceAll("|enclose=\"pre\"","");
		es.value = "[[Category:Pages using deprecated enclose attributes]]";
	}
}