diff --git a/background.js b/background.js index e69de29..127a801 100644 --- a/background.js +++ b/background.js @@ -0,0 +1,27 @@ +// chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { +// console.log(request); +// sendResponse({ farewell: "goodbye" }); +// }); + +const bannedSlogansList = document.getElementById("bannedSlogansList"); + +function span(text) { + return "" + text + ""; +} + +//get banned slogans +chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) { + chrome.tabs.sendMessage(tabs[0].id, { action: "getBannedSlogans" }, function( + response + ) { + const resultContent = ""; + + if (response.length == 0) { + resultContent = span("Hooray, no banned words!"); + } else { + response.forEach(slogan => { + resultContent += span(slogan); + }); + } + }); +}); diff --git a/content.js b/content.js index 0f62801..04c8c28 100644 --- a/content.js +++ b/content.js @@ -104,3 +104,11 @@ function checkNodeRecursively(startNode) { checkNodeRecursively(node); }); } +// chrome.runtime.sendMessage(bannedSlogans, function (response) { +// console.log(response.farewell); +// }); +chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { + if (request.action == "getBannedSlogans") { + sendResponse(bannedSlogans); + } +}); diff --git a/manifest.json b/manifest.json index 5c23614..3dcff7b 100644 --- a/manifest.json +++ b/manifest.json @@ -9,8 +9,7 @@ } ], "background": { - "scripts": ["scripts/background.js"], - "persistent": false + "scripts": ["background.js"] }, "browser_action": { "default_popup": "popup.html" diff --git a/popup.html b/popup.html index 844e21f..fac3a95 100644 --- a/popup.html +++ b/popup.html @@ -15,12 +15,16 @@ color: whitesmoke; font-size: 0.8em; } + #bannedSlogansList > span { + display: block; + }