Added option to disable count of blocked elements
Added another toggle to the options page to disable the count of blocked sticky headers. This is modeled off the uBlock origin option which does the same thing.
This commit is contained in:
parent
a6b997b780
commit
49818bf8c2
@ -143,9 +143,12 @@ function killStickyPseudoElement(element, before) {
|
||||
|
||||
function incrementKilledStickiesCount() {
|
||||
// console.log("incrementKilledStickiesCount");
|
||||
console.log("Hiding stickies: " + AKS.hideKillCount); //DEBUG
|
||||
if (!AKS.hideKillCount) {
|
||||
AKS.stickiesKilled++;
|
||||
chrome.runtime.sendMessage({ newBadgeText: "" + AKS.stickiesKilled });
|
||||
}
|
||||
}
|
||||
|
||||
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
/* Full-screen paywalls not only bring up sticky elements, they also make
|
||||
@ -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);
|
||||
|
||||
@ -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 */
|
||||
/******************/
|
||||
|
||||
@ -16,9 +16,9 @@
|
||||
<input type='checkbox' id='whitelist-mode'></input>
|
||||
<span class='whitelist-mode-label'>Whitelist mode</span>
|
||||
</span>
|
||||
<span class='display-stickies-killed-container'>
|
||||
<span class='enable-stickes-killed-count'>Show killed stickies count</span>
|
||||
<input type='checkbox' id='display-kill-count'>
|
||||
<span class='enable-stickies-killed-count-container'>
|
||||
<span class='enable-stickies-killed-count'>Show killed stickies count</span>
|
||||
<input type='checkbox' id='hide-kill-count'>
|
||||
<span class='disable-stickies-killed-count'>Hide killed stickies count</span>
|
||||
</span>
|
||||
<span class='buttons'>
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user