transliterate_page({ "Ĉ": "Cx", "Ĝ": "Gx", "Ĥ": "Hx", "Ĵ": "Jx", "Ŝ": "Sx", "Ŭ": "Ux", "ĉ": "cx", "ĝ": "gx", "ĥ": "hx", "ĵ": "jx", "ŝ": "sx", "ŭ": "ux" })
Ĉiuliteraĵo
Cxiuliterajxo
function transliterate_page(alf) { | |
function tr(input) { | |
var output = input | |
var alf_entries = Object.entries(alf) | |
for (var i = 0; i < alf_entries.length; i++) { | |
var alf_entry = alf_entries[i] | |
output = output.replaceAll(alf_entry[0], alf_entry[1]) | |
} | |
return output | |
} | |
var nodes = document.createNodeIterator(document.documentElement, NodeFilter.SHOW_TEXT), node | |
while (node = nodes.nextNode()) { | |
var tag = node.parentElement ? node.parentElement.tagName.toLowerCase() : "" | |
if (tag === "style" || tag === "script" || tag === "code") { | |
continue | |
} | |
node.nodeValue = tr(node.nodeValue) | |
} | |
} |