Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
blackstormx committed Jul 28, 2020
1 parent c663e23 commit 871127a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
27 changes: 27 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -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 "<span>" + text + "</span>";
}

//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);
});
}
});
});
8 changes: 8 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
3 changes: 1 addition & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
}
],
"background": {
"scripts": ["scripts/background.js"],
"persistent": false
"scripts": ["background.js"]
},
"browser_action": {
"default_popup": "popup.html"
Expand Down
6 changes: 5 additions & 1 deletion popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
color: whitesmoke;
font-size: 0.8em;
}
#bannedSlogansList > span {
display: block;
}
</style>
<body>
<div class="container">
<span class="h">Currently banned slogans: </span>

<div></div>
<div id="bannedSlogansList"></div>
</div>
</body>
<script src="background.js"></script>
</html>

0 comments on commit 871127a

Please sign in to comment.