User:Aidan9382/scripts/quickfix-enclose.js
Appearance
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:Aidan9382/scripts/quickfix-enclose. |
/* 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]]";
}
}