Skip to content

Commit

Permalink
n
Browse files Browse the repository at this point in the history
  • Loading branch information
blackstormx committed Aug 1, 2020
1 parent ec847e8 commit 9f54616
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
11 changes: 1 addition & 10 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,6 @@ function button(id, text) {
return "<button id = " + id + ">" + text + "</button>";
}

function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}

//get banned slogans
chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, { action: "getBannedSlogans" }, function(
Expand All @@ -166,7 +157,7 @@ chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
resultContent = fullDiv("Hooray, no banned words!");
} else {
response.forEach((slogan, i) => {
resultContent += span(span(i + 1) + span(escapeHtml(slogan)));
resultContent += span(span(i + 1) + span(slogan));
});
}

Expand Down
11 changes: 10 additions & 1 deletion content.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ const url =
format: "json"
});

function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}

function chromeStorage(sKey) {
return new Promise(function(resolve, reject) {
chrome.storage.sync.get(sKey, function(items) {
Expand Down Expand Up @@ -92,7 +101,7 @@ function startScan() {
const value = startNode.nodeValue.toLowerCase();
if (deepCheck(value)) {
startNode.nodeValue = bannedWord;
bannedSlogans.push(value);
bannedSlogans.push(escapeHtml(value));
}
} else {
if (startNode.nodeType == Node.ELEMENT_NODE) {
Expand Down

0 comments on commit 9f54616

Please sign in to comment.