From a46d1f335e742a42d6276043e31bfe35febad9fa Mon Sep 17 00:00:00 2001 From: Danielle <29378233+DanielleMiu@users.noreply.github.com> Date: Mon, 1 May 2023 00:27:19 -0400 Subject: [PATCH] v0.2.3 Long-Lived Branch (#38) * bump manifest versions to 0.2.3 * revert firefox manifest to v2 * add block interval timeout config and slider * update makefile zip commands to not be single line and more readable * fix slider thumb on chrome * stop processing queue when the user is logged out * add a logstr to the start of every log --- .gitignore | 2 + firefox-manifest.json | 28 +++++------- makefile | 28 +++++++++++- manifest.json | 2 +- options.js | 50 +++++++++++++------- popup.html | 15 +++++- script.js | 32 ++++++------- service_worker.js | 13 +++++- shared.js | 104 +++++++++++++++++++++++++++++------------- style.css | 61 ++++++++++++++++++++++--- 10 files changed, 239 insertions(+), 96 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ff0e62b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# built package files +*.zip diff --git a/firefox-manifest.json b/firefox-manifest.json index dba490f..1efac3e 100644 --- a/firefox-manifest.json +++ b/firefox-manifest.json @@ -1,27 +1,23 @@ { - "manifest_version": 3, + "manifest_version": 2, "name": "Blue Blocker", - "version": "0.2.2", + "version": "0.2.3", "description": "Blocks all Twitter Blue verified users on twitter.com", "icons": { "128": "assets/icon-128.png" }, "web_accessible_resources": [ - { - "resources": [ - "script.js", - "shared.js", - "inject.js" - ], - "matches": [ - "*://*.twitter.com/*", - "*://twitter.com/*" - ] - } + "script.js", + "shared.js", + "inject.js" ], - "action": { - "default_popup": "popup.html", - "default_icon": "assets/icon.png" + "browser_action": { + "browser_style": true, + "default_icon": { + "128": "assets/icon-128.png" + }, + "default_title": "Blue Blocker", + "default_popup": "popup.html" }, "permissions": [ "storage" diff --git a/makefile b/makefile index 903adc8..536ea79 100644 --- a/makefile +++ b/makefile @@ -9,7 +9,19 @@ firefox: mv manifest.json chrome-manifest.json mv firefox-manifest.json manifest.json - zip "blue-blocker-firefox-${VERSION}.zip" manifest.json LICENSE readme.md popup.html style.css inject.js main.js options.js script.js service_worker.js shared.js assets/* + zip "blue-blocker-firefox-${VERSION}.zip" \ + manifest.json \ + LICENSE \ + readme.md \ + popup.html \ + style.css \ + inject.js \ + main.js \ + options.js \ + script.js \ + service_worker.js \ + shared.js \ + assets/* mv manifest.json firefox-manifest.json mv chrome-manifest.json manifest.json @@ -18,4 +30,16 @@ chrome: # ifneq (,$(wildcard blue-blocker-chrome-$(VERSION).zip)) # rm "blue-blocker-chrome-${VERSION}.zip" # endif - zip "blue-blocker-chrome-${VERSION}.zip" manifest.json LICENSE readme.md popup.html style.css inject.js main.js options.js script.js service_worker.js shared.js assets/* + zip "blue-blocker-chrome-${VERSION}.zip" \ + manifest.json \ + LICENSE \ + readme.md \ + popup.html \ + style.css \ + inject.js \ + main.js \ + options.js \ + script.js \ + service_worker.js \ + shared.js \ + assets/* diff --git a/manifest.json b/manifest.json index f1d5447..ce6606c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "Blue Blocker", - "version": "0.2.2", + "version": "0.2.3", "description": "Blocks all Twitter Blue verified users on twitter.com", "icons": { "128": "assets/icon-128.png" diff --git a/options.js b/options.js index e6d38af..0fd95f5 100644 --- a/options.js +++ b/options.js @@ -10,6 +10,8 @@ document.addEventListener("DOMContentLoaded", () => { document.getElementById("skip-affiliated").checked = items.skipAffiliated; document.getElementById("skip-1mplus").checked = items.skip1Mplus; document.getElementById("block-nft-avatars").checked = items.blockNftAvatars; + document.getElementById("block-interval").value = items.blockInterval; + document.getElementById("block-interval-value").innerText = items.blockInterval.toString() + "s"; }); }); @@ -19,18 +21,18 @@ api.storage.local.get({ BlockCounter: 0, BlockQueue: [] }).then(items => { document.getElementById("blocked-user-queue-length").innerText = commafy(items.BlockQueue.length); }); api.storage.local.onChanged.addListener(items => { - if (items.hasOwnProperty('BlockCounter')) { + if (items.hasOwnProperty("BlockCounter")) { document.getElementById("blocked-users-count").innerText = commafy(items.BlockCounter.newValue); } - if (items.hasOwnProperty('BlockQueue')) { + if (items.hasOwnProperty("BlockQueue")) { document.getElementById("blocked-user-queue-length").innerText = commafy(items.BlockQueue.newValue.length); } // if we want to add other values, add them here }); -document.getElementById("mute-instead-of-block").addEventListener("input", () => { +document.getElementById("mute-instead-of-block").addEventListener("input", e => { api.storage.sync.set({ - mute: document.getElementById("mute-instead-of-block").checked, + mute: e.target.checked, }, () => { // Update status to let user know options were saved. const status = document.getElementById("mute-instead-of-block-status"); @@ -39,9 +41,9 @@ document.getElementById("mute-instead-of-block").addEventListener("input", () => }); }); -document.getElementById("block-following").addEventListener("input", () => { +document.getElementById("block-following").addEventListener("input", e => { api.storage.sync.set({ - blockFollowing: document.getElementById("block-following").checked, + blockFollowing: e.target.checked, }, () => { // Update status to let user know options were saved. const status = document.getElementById("block-following-status"); @@ -50,9 +52,9 @@ document.getElementById("block-following").addEventListener("input", () => { }); }); -document.getElementById("block-followers").addEventListener("input", () => { +document.getElementById("block-followers").addEventListener("input", e => { api.storage.sync.set({ - blockFollowers: document.getElementById("block-followers").checked, + blockFollowers: e.target.checked, }, () => { // Update status to let user know options were saved. const status = document.getElementById("block-followers-status"); @@ -61,9 +63,9 @@ document.getElementById("block-followers").addEventListener("input", () => { }); }); -document.getElementById("skip-verified").addEventListener("input", () => { +document.getElementById("skip-verified").addEventListener("input", e => { api.storage.sync.set({ - skipVerified: document.getElementById("skip-verified").checked, + skipVerified: e.target.checked, }, () => { // Update status to let user know options were saved. const status = document.getElementById("skip-verified-status"); @@ -72,9 +74,9 @@ document.getElementById("skip-verified").addEventListener("input", () => { }); }); -document.getElementById("skip-affiliated").addEventListener("input", () => { +document.getElementById("skip-affiliated").addEventListener("input", e => { api.storage.sync.set({ - skipAffiliated: document.getElementById("skip-affiliated").checked, + skipAffiliated: e.target.checked, }, () => { // Update status to let user know options were saved. const status = document.getElementById("skip-affiliated-status"); @@ -83,9 +85,9 @@ document.getElementById("skip-affiliated").addEventListener("input", () => { }); }); -document.getElementById("skip-1mplus").addEventListener("input", () => { +document.getElementById("skip-1mplus").addEventListener("input", e => { api.storage.sync.set({ - skip1Mplus: document.getElementById("skip-1mplus").checked, + skip1Mplus: e.target.checked, }, () => { // Update status to let user know options were saved. const status = document.getElementById("skip-1mplus-status"); @@ -94,9 +96,9 @@ document.getElementById("skip-1mplus").addEventListener("input", () => { }); }); -document.getElementById("block-nft-avatars").addEventListener("input", () => { +document.getElementById("block-nft-avatars").addEventListener("input", e => { api.storage.sync.set({ - blockNftAvatars: document.getElementById("block-nft-avatars").checked, + blockNftAvatars: e.target.checked, }, () => { // Update status to let user know options were saved. const status = document.getElementById("block-nft-avatars-status"); @@ -104,3 +106,19 @@ document.getElementById("block-nft-avatars").addEventListener("input", () => { setTimeout(() => status.textContent = null, 1000); }); }); + +const blockIntervalValueElement = document.getElementById("block-interval-value"); +document.getElementById("block-interval").addEventListener("input", e => { + blockIntervalValueElement.innerText = e.target.value.toString() + "s"; +}); + +document.getElementById("block-interval").addEventListener("change", e => { + api.storage.sync.set({ + blockInterval: parseInt(e.target.value), + }, () => { + // Update status to let user know options were saved. + const status = document.getElementById("block-interval-status"); + status.textContent = "saved"; + setTimeout(() => status.textContent = null, 1000); + }); +}); diff --git a/popup.html b/popup.html index d147fe6..254836e 100644 --- a/popup.html +++ b/popup.html @@ -1,6 +1,7 @@ - + + Blue Blocker @@ -67,7 +68,7 @@

🅱️lue Blocker

-
+