Content deleted Content added
←Created page with '// Category:Wikipedia scripts // <nowiki> $(function() { if(mw.config.get("wgAction") !== "edit") return; window.rc_refsCrunched = false; window.rc_refs...' |
mNo edit summary |
||
(18 intermediate revisions by the same user not shown) | |||
Line 5:
if(mw.config.get("wgAction") !== "edit") return;
window.rc_refs = [];▼
if(debug) console.log("Running");
rc_refs = [];
// Add key handler.
window.addEventListener("keydown", e =>
{
if(e.ctrlKey && e.altKey && e.which == 82)
{
run();
if(window.rc_refsCrunched)▼
{▼
uncrunchRefs();▼
▲ window.rc_refsCrunched = false;
}▼
else▼
{▼
crunchRefs();▼
}▼
}
});
function run()
{
if(debug) console.log("Activate");
}
function crunchRefs()
Line 34 ⟶ 42:
var counter = 0;
text = text.replace(/(<ref.*?\/>)|(<ref.*?>(.|\s)*?<\/ref>)/g,
{
rc_refs.push(match);
return `{ref#${counter++}}`;▼
});
txtarea.value = text;
return true;
}
Line 50 ⟶ 62:
var text = txtarea.value;
text = text.replace(/
{
if(debug) console.log(match);
return window.rc_refs.pop(Number(p1));▼
});
txtarea.value = text;
return false;
}
});
|