diff --git a/background.js b/background.js index 6c1628d..629adbb 100644 --- a/background.js +++ b/background.js @@ -144,16 +144,18 @@ chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) { chrome.tabs.sendMessage(tabs[0].id, { action: "getBannedSlogans" }, function( response ) { - let resultContent = ""; - - if (response.length == 0) { - resultContent = fullDiv("Hooray, no banned words!"); - } else { - response.forEach((slogan, i) => { - resultContent += span(span(i + 1) + span(slogan)); - }); + if (response) { + let resultContent = ""; + + if (response.length == 0) { + resultContent = fullDiv("Hooray, no banned words!"); + } else { + response.forEach((slogan, i) => { + resultContent += span(span(i + 1) + span(slogan)); + }); + } + + bannedSlogansList.innerHTML = resultContent; } - - bannedSlogansList.innerHTML = resultContent; }); }); diff --git a/content.js b/content.js index 156ef9a..17ffc90 100644 --- a/content.js +++ b/content.js @@ -77,15 +77,16 @@ function startScan() { let doc = domParser.parseFromString(text["*"], "text/html"); parseWikiNodes(doc); checkNodeRecursively(body); - const observer = new MutationObserver(callback); - observer.observe(body, { - childList: true, - subtree: true - }); }); } else { checkNodeRecursively(body); } + const observer = new MutationObserver(callback); + observer.observe(body, { + childList: true, + subtree: true + }); + function checkNode(startNode) { if (startNode.nodeType == Node.TEXT_NODE) { const value = startNode.nodeValue.toLowerCase();