chrome.storage.local.get("translations", ({ translations }) => {
if (translations) {
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);
let node;
while (node = walker.nextNode()) {
const words = node.nodeValue.split(/\b/);
const newNodeValue = words.map(word => {
const translation = translations[word.toLowerCase()];
if (translation) {
return `*${translation}*`
}
return word;
}).join('');
node.textContent = newNodeValue
}
}});