Skip to content

Commit

Permalink
Update background.js
Browse files Browse the repository at this point in the history
  • Loading branch information
blackstormx committed Aug 1, 2020
1 parent 1ac9610 commit ec847e8
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@

let customSlogans = [];

chrome.storage.sync.get("savedCustomSlogans", function(items) {
if (items.savedCustomSlogans) {
customSlogans = items.savedCustomSlogans;
updateUserBannedList("");
}
});

const userBannedSlogansList = document.getElementById("userBannedSlogansList");

const bannedSlogansList = document.getElementById("bannedSlogansList");
Expand All @@ -28,6 +21,19 @@ const set = document.getElementById("set");

const parseWiki = document.getElementById("parseWiki");

function sleep(seconds) {
var e = new Date().getTime() + seconds * 1000;
while (new Date().getTime() <= e) {}
}

chrome.storage.sync.get("savedCustomSlogans", function(items) {
if (items.savedCustomSlogans) {
customSlogans = items.savedCustomSlogans;

// updateUserBannedList("");
}
});

parseWiki.onchange = () => {
chrome.storage.sync.set({ parseWiki: parseWiki.checked }, function() {});
};
Expand Down Expand Up @@ -139,6 +145,15 @@ 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 @@ -151,7 +166,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(slogan));
resultContent += span(span(i + 1) + span(escapeHtml(slogan)));
});
}

Expand Down

0 comments on commit ec847e8

Please sign in to comment.