User:SiBr4/DiffApostrophes.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:SiBr4/DiffApostrophes. |
/*
This script adds 0.1em of padding around apostrophes ('') in
diffs, to ease distinguishing them from quotation marks ("). See
[[Wikipedia:Village pump (technical)/Archive 139#Is there a better way to illustrate a " --> '' change in the diff view?]].
Install by adding the following row to your [[Special:MyPage/common.js]] or [[Special:MyPage/skin.js]]:
importScript('User:SiBr4/DiffApostrophes.js');
*/
function repapos(elem) {
elem.innerHTML = elem.innerHTML.replace(/(?<!<[^>]+)\'/g,"<span style=\"padding:0 0.1em;\">'</span>");
}
var diff = document.getElementsByClassName("diff")[0];
if (diff) {
var del = diff.getElementsByClassName("diff-deletedline");
for (i=0; i<Math.min(del.length,50); i++) {repapos(del[i]);}
var add = diff.getElementsByClassName("diff-addedline");
for (i=0; i<Math.min(add.length,50); i++) {repapos(add[i]);}
var ctx = diff.getElementsByClassName("diff-context");
for (i=0; i<Math.min(ctx.length,50); i++) {repapos(ctx[i]);}
}