User:HaydenWong/common.js

function replaceRecursively(element, from, to) { if (element.childNodes.length) { element.childNodes.forEach(child => replaceRecursively(child, from, to)); } else { const cont = element.textContent; if (cont) element.textContent = cont.replace(from, to); } }

replaceRecursively(document.body, new RegExp("colour", "g"), "color");