From ec847e814b3da391e1d280d2f4404760cfd77795 Mon Sep 17 00:00:00 2001 From: blackstormx Date: Sat, 1 Aug 2020 07:05:47 +0400 Subject: [PATCH] Update background.js --- background.js | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/background.js b/background.js index 629adbb..49e8a11 100644 --- a/background.js +++ b/background.js @@ -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"); @@ -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() {}); }; @@ -139,6 +145,15 @@ function button(id, text) { return ""; } +function escapeHtml(unsafe) { + return unsafe + .replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); +} + //get banned slogans chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) { chrome.tabs.sendMessage(tabs[0].id, { action: "getBannedSlogans" }, function( @@ -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))); }); }