右上の "makoto" を
"
[email protected]" に変更する
// Replace account name to
[email protected]
bulkReplaceTextInElement("#accountMenu > summary > span", [
{ oldText: "makoto", newText: "
[email protected]" },
]);
function bulkReplaceTextInElement(selector, replacements) {
const element = document.querySelector(selector);
if (element) {
replaceTextRecursivelyBulk(element, replacements);
}
}
function replaceTextRecursivelyBulk(element, replacements) {
for (let node of element.childNodes) {
if (node.nodeType === Node.TEXT_NODE) {
for (const replacement of replacements) {
node.textContent = node.textContent.replace(
replacement.oldText,
replacement.newText
);
}
} else if (node.nodeType === Node.ELEMENT_NODE) {
replaceTextRecursivelyBulk(node, replacements);
}
}
}