From 9f546163b4b11d0de78d0bd01d52729821594d1a Mon Sep 17 00:00:00 2001 From: blackstormx Date: Sat, 1 Aug 2020 07:07:35 +0400 Subject: [PATCH] n --- background.js | 11 +---------- content.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/background.js b/background.js index 49e8a11..570e37f 100644 --- a/background.js +++ b/background.js @@ -145,15 +145,6 @@ 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( @@ -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)); }); } diff --git a/content.js b/content.js index 17ffc90..3789e62 100644 --- a/content.js +++ b/content.js @@ -15,6 +15,15 @@ const url = format: "json" }); +function escapeHtml(unsafe) { + return unsafe + .replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); +} + function chromeStorage(sKey) { return new Promise(function(resolve, reject) { chrome.storage.sync.get(sKey, function(items) { @@ -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) {