From 893b080b5ced025fbb6b423208839aa7cd1493ee Mon Sep 17 00:00:00 2001 From: blackstormx Date: Wed, 29 Jul 2020 13:19:56 +0400 Subject: [PATCH] Update background.js --- background.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/background.js b/background.js index f63738c..4c4a948 100644 --- a/background.js +++ b/background.js @@ -2,6 +2,7 @@ // console.log(request); // sendResponse({ farewell: "goodbye" }); // }); + let customSlogans = []; chrome.storage.sync.get("savedCustomSlogans", function(items) { @@ -39,10 +40,27 @@ function updateUserBannedList(filter) { userBannedSlogansList.innerHTML = ""; customSlogans.forEach((slogan, i) => { if (slogan.includes(filter)) { - let sloganDOM = span(span(i + 1) + span(slogan) + button(i, "-")); + let sloganDOM = span( + span(i + 1) + span(slogan) + button("removeSlogan-" + i, "-") + ); userBannedSlogansList.innerHTML += sloganDOM; } }); + setTimeout(() => { + for (let i = 0; i < customSlogans.length; i++) { + let button = document.getElementById("removeSlogan-" + i); + button.name = i; + button.addEventListener("click", e => { + customSlogans.splice(i, 1); + chrome.storage.sync.set( + { savedCustomSlogans: customSlogans }, + function() { + updateUserBannedList(customSloganTextbox.value); + } + ); + }); + } + }); } page2btn.onclick = () => {