User:Eejit43/scripts/highlight-homographs.js

// // Note: This script was compiled and minified from TypeScript. For a more readable version, see https://github.com/Eejit43/wikipedia-scripts/blob/main/scripts/highlight-homographs.ts

"use strict";(=>{const n=document.querySelector("#firstHeading");if(!n)return mw.notify("Could not find title element!",{type:"error"});for(const t of n.children)t.textContent&&(t.nodeType===Node.TEXT_NODE?n.replaceChild(document.createRange.createContextualFragment(o(t.textContent)),t):(t.classList.contains("mw-page-title-main")||t.tagName==="I")&&(t.innerHTML=o(t.innerHTML)));function o(t){return[...t].map(e=>/[\u0400-\u052F\u1D2B\u1D78\u2DE0-\u2DFF\uA640-\uA69F]/.test(e)||/[ɑΑΒΕΖΗΙΚΜΝΟΡΤΥΧνο]/.test(e)||/[ԼՏոսօ]/.test(e)||/[ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯ]/i.test(e)?`${e} `:e).join("")}});

// //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc2NyaXB0cy9oaWdobGlnaHQtaG9tb2dyYXBocy50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiKCgpID0+IHtcbiAgICBjb25zdCB0aXRsZSA9IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoJyNmaXJzdEhlYWRpbmcnKTtcblxuICAgIGlmICghdGl0bGUpIHJldHVybiBtdy5ub3RpZnkoJ0NvdWxkIG5vdCBmaW5kIHRpdGxlIGVsZW1lbnQhJywgeyB0eXBlOiAnZXJyb3InIH0pO1xuXG4gICAgZm9yIChjb25zdCBlbGVtZW50IG9mIHRpdGxlLmNoaWxkcmVuKSB7XG4gICAgICAgIGlmICghZWxlbWVudC50ZXh0Q29udGVudCkgY29udGludWU7XG4gICAgICAgIGlmIChlbGVtZW50Lm5vZGVUeXBlID09PSBOb2RlLlRFWFRfTk9ERSkgdGl0bGUucmVwbGFjZUNoaWxkKGRvY3VtZW50LmNyZWF0ZVJh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