diff --git a/src/contentScript.js b/src/contentScript.js
index 51b767d..f442e38 100644
--- a/src/contentScript.js
+++ b/src/contentScript.js
@@ -143,8 +143,11 @@ function killStickyPseudoElement(element, before) {
function incrementKilledStickiesCount() {
// console.log("incrementKilledStickiesCount");
- AKS.stickiesKilled++;
- chrome.runtime.sendMessage({ newBadgeText: "" + AKS.stickiesKilled });
+ console.log("Hiding stickies: " + AKS.hideKillCount); //DEBUG
+ if (!AKS.hideKillCount) {
+ AKS.stickiesKilled++;
+ chrome.runtime.sendMessage({ newBadgeText: "" + AKS.stickiesKilled });
+ }
}
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
@@ -197,7 +200,12 @@ function startConstantVigilance() {
*/
function beginKillingStickies() {
// console.log("beginKillingStickies");
- if (!window.AKS) window.AKS = { stickiesKilled: 0 };
+ if (!window.AKS) {
+ window.AKS = { stickiesKilled: 0 };
+ }
+ else {
+ window.AKS.stickiesKilled = 0;
+ }
window.requestIdleCallback(() => {
killSticky();
@@ -211,9 +219,16 @@ function beginKillingStickies() {
function initialize() {
// console.log("initialize");
- chrome.storage.local.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => {
+ chrome.storage.local.get([ "matchingPatterns", "exclusionPatterns", "mode", "hideKillCount" ], (result) => {
let shouldKillSticky = checkForShouldKillSticky(result);
updateIcon(shouldKillSticky);
+ const hideKillCount = result.hideKillCount ? true : false;
+ if (!window.AKS){
+ window.AKS = {hideKillCount: hideKillCount};
+ }
+ else {
+ window.AKS.hideKillCount = hideKillCount;
+ }
if (shouldKillSticky) {
if (document.readyState == "loading") {
document.addEventListener("DOMContentLoaded", beginKillingStickies);
diff --git a/src/options.css b/src/options.css
index c1f10c6..3b845f0 100644
--- a/src/options.css
+++ b/src/options.css
@@ -186,6 +186,46 @@ input#whitelist-mode,
border-bottom: 1px solid currentColor;
}
+/*********************/
+/* KILL COUNT TOGGLE */
+/*********************/
+
+input#hide-kill-count {
+ display: block;
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ border: 1px solid #000;
+ font-size: 1rem;
+ height: 2em;
+ width: 4em;
+ margin: 0 6px;
+ background-color: #000;
+ box-shadow:
+ -2em 0 0 1px #fff inset,
+ 0 0 0 3px #fff inset;
+}
+
+input#hide-kill-count:checked {
+ border: 1px solid #fff;
+ background-color: #fff;
+ box-shadow:
+ 2em 0 0 1px #000 inset,
+ 0 0 0 3px #000 inset;
+}
+
+.enable-stickies-killed-count-container {
+ white-space: nowrap;
+ display: flex;
+ align-items: center;
+ align-self: flex-start;
+ border: 1px solid #ddd;
+ padding: 8px 10px;
+ cursor: default;
+ background-color: #fff;
+ margin-top: 15px;
+}
+
+
/******************/
/* WHITELIST MODE */
/******************/
diff --git a/src/options.html b/src/options.html
index 60a11e2..af7e31d 100644
--- a/src/options.html
+++ b/src/options.html
@@ -16,9 +16,9 @@
Whitelist mode
-
- Show killed stickies count
-
+
+ Show killed stickies count
+
Hide killed stickies count
diff --git a/src/options.js b/src/options.js
index 2a6347e..b0ac97b 100644
--- a/src/options.js
+++ b/src/options.js
@@ -15,7 +15,7 @@ function modeSelectorInputReceived() {
/*
* Triggered when a click is received by the kill count display switch
*/
-function showKillCountInputReceived() {
+function hideKillCountInputReceived() {
setButtonsActive(true);
}
@@ -49,6 +49,15 @@ function toggleModeSelectorState(newMode) {
document.querySelector("div#matchingPatterns textarea").disabled = (newMode == "whitelist");
}
+/*
+ * Sets the kill count selector state
+ * Used by resetChanges()
+ */
+function setHideKillCountSelectorState(hideKillCount) {
+ let checkbox = document.querySelector("input#hide-kill-count");
+ checkbox.checked = hideKillCount;
+}
+
/* Saves the entered state in storage.
De-activate the "Reset" and "Save" buttons.
*/
@@ -56,10 +65,13 @@ function saveChanges() {
let matchingPatterns = document.querySelector("#matchingPatterns textarea").value;
let exclusionPatterns = document.querySelector("#exclusionPatterns textarea").value;
let mode = document.querySelector("input#whitelist-mode").checked ? "whitelist" : "blacklist";
+ let hideKillCount = document.querySelector("input#hide-kill-count").checked ? true : false;
+ console.log("In saveChanges, hideKillCount: " + hideKillCount); //DEBUG
chrome.storage.local.set({
"matchingPatterns": matchingPatterns,
"exclusionPatterns": exclusionPatterns,
- "mode": mode
+ "mode": mode,
+ "hideKillCount": hideKillCount
}, () => {
let error = chrome.runtime.lastError;
if (error) {
@@ -74,15 +86,18 @@ function saveChanges() {
discarding the user's changes.
*/
function resetChanges(callback) {
- chrome.storage.local.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => {
+ chrome.storage.local.get([ "matchingPatterns", "exclusionPatterns", "mode", "hideKillCount" ], (result) => {
AKS.matchingPatterns = result.matchingPatterns || "";
AKS.exclusionPatterns = result.exclusionPatterns || ""
AKS.mode = result.mode || "blacklist";
+ AKS.hideKillCount = result.hideKillCount || false;
document.querySelector("#matchingPatterns textarea").value = AKS.matchingPatterns;
document.querySelector("#exclusionPatterns textarea").value = AKS.exclusionPatterns;
toggleModeSelectorState(AKS.mode);
+ setHideKillCountSelectorState(AKS.hideKillCount);
+
// De-activate the "Reset" and "Save" buttons.
setButtonsActive(false);
@@ -184,8 +199,8 @@ function initialize() {
});
//Listener for killcount display switch
- document.querySelector("input#display-kill-count").addEventListener("change", (event) => {
- showKillCountInputReceived();
+ document.querySelector("input#hide-kill-count").addEventListener("change", (event) => {
+ hideKillCountInputReceived();
});
// Listener for open help button.