„Benutzer:Lustiger seth/seth-style.js“ – Versionsunterschied
Erscheinungsbild
Inhalt gelöscht Inhalt hinzugefügt
feat: traverse DOM instead of raw innerHTML |
chore: debugging |
||
Zeile 34: | Zeile 34: | ||
} |
} |
||
sethsche_schreibung(); |
//sethsche_schreibung(); |
Version vom 5. April 2023, 23:44 Uhr
// apply lower case style and converted umlauts and sz-ligature on comments of lustiger_seth
// (not tested very well.)
function sethsche_schreibung(){
function lc_replacer(match, offset, string){
return match.toLowerCase();
}
function replaceTextNodes(node, post_id=""){
node.childNodes.forEach(function(el){
if(post_id !== "" && el.nodeType === 3){ // text node
el.nodeValue = el.nodeValue
.replace(/\b[A-ZÄÖÜ][a-zäöüß]+\b/g, lc_replacer)
.replace(/L(ustiger[_ ]seth)/g, "l$1")
.replace(/ä/g, "ae")
.replace(/ö/g, "oe")
.replace(/ü/g, "ue")
.replace(/ß/g, "ss");
}else{ // recurse
if(el.nodeType === 1){
if(post_id === "" && el.id.startsWith("c-Lustiger_seth")){
post_id = el.id;
}else if(typeof(el.dataset.mwThreadId) !== "!undefined" && el.dataset.mwThreadId === post_id){
post_id = "";
}
}
replaceTextNodes(el, post_id);
}
});
}
replaceTextNodes(document.getElementById("mw-content-text")
.getElementsByClassName("mw-parser-output")[0]);
}
//sethsche_schreibung();