diff --git a/src/contentScript.js b/src/contentScript.js index 46c0f35..22a729d 100644 --- a/src/contentScript.js +++ b/src/contentScript.js @@ -62,12 +62,15 @@ function startConstantVigilance() { if (getComputedStyle(mutation.target).position == 'fixed' || getComputedStyle(mutation.target).position == 'sticky') { mutation.target.remove(); - console.log("Killing new sticky!"); + console.log("Killing a sticky!"); + + // Compensate for fullscreen paywalls. + restoreScrollability(); } } }); - observer.observe(document.querySelector("body"), { + observer.observe(document.querySelector("html"), { attributes: true, childList: true, subtree: true @@ -79,17 +82,16 @@ function startConstantVigilance() { /******************/ function initialize() { - chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode", "constantVigilance" ], + chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => { let shouldKillSticky = checkForShouldKillSticky(result); updateIcon(shouldKillSticky); - let constantVigilance = (result.constantVigilance == "false") ? false : true; - window.onload = () => { - if (shouldKillSticky) { + if (shouldKillSticky) { + startConstantVigilance(); + window.onload = () => { killSticky(); - if (constantVigilance) startConstantVigilance(); } - }; + } }); } initialize(); \ No newline at end of file diff --git a/src/functions.js b/src/functions.js index 7edb698..a63a92f 100644 --- a/src/functions.js +++ b/src/functions.js @@ -54,4 +54,15 @@ function killSticky() { element.remove(); } }); + // Compensate for full-screen paywalls. + restoreScrollability(); +} + +/* Full-screen paywalls not only bring up sticky elements, they also make + the page un-scrollable. This ensures that the page remains scrollable. + */ +function restoreScrollability() { + document.querySelectorAll("html, body").forEach(container => { + container.style.setProperty("overflow-y", "auto", "important"); + }); } diff --git a/src/options.css b/src/options.css index 4bb73b8..c1f10c6 100644 --- a/src/options.css +++ b/src/options.css @@ -186,60 +186,6 @@ input#whitelist-mode, border-bottom: 1px solid currentColor; } -/**********************/ -/* CONSTANT VIGILANCE */ -/**********************/ - -.constant-vigilance-container { - border: 1px solid #ddd; - padding: 9px 13px 12px 11px; - display: flex; - align-items: center; - margin: 0 0 0 10px; -} - -.constant-vigilance-container input[type='checkbox'] { - -webkit-appearance: none; - -moz-appearance: none; - border: 1px solid #000; - width: 15px; - height: 15px; - position: relative; - top: 1px; - margin: 3px 5px 0 0; -} -.constant-vigilance-container input[type='checkbox'], -.constant-vigilance-container label { - cursor: pointer; -} -.constant-vigilance-container label { - line-height: 1; - padding: 8px 0 0 0; - border-bottom: 1px solid transparent; - font-size: 0.875rem; -} -.constant-vigilance-container label::selection { - background-color: transparent; -} -.constant-vigilance-container input[type='checkbox']:focus { - outline: none; -} -.constant-vigilance-container input[type='checkbox']:focus + label, -.constant-vigilance-container input[type='checkbox']:hover + label, -.constant-vigilance-container input[type='checkbox'] + label:hover { - border-bottom: 1px dotted #000; -} -.constant-vigilance-container input[type='checkbox']:checked, -.constant-vigilance-container input[type='checkbox']:hover { - box-shadow: 0 0 0 2px #fff inset; -} -.constant-vigilance-container input[type='checkbox']:hover { - background-color: #ccc; -} -.constant-vigilance-container input[type='checkbox']:checked { - background-color: #000; -} - /******************/ /* WHITELIST MODE */ /******************/ diff --git a/src/options.html b/src/options.html index e043d04..2c5f6d1 100644 --- a/src/options.html +++ b/src/options.html @@ -16,10 +16,6 @@ Whitelist mode - - - - @@ -80,9 +76,6 @@

Whitelist mode

In whitelist mode, the matching patterns list is ignored. Stickies are always killed, unless the page matches one of the patterns in the exclusion patterns list.

(In whitelist mode, the behavior of the main button () in the AlwaysKillSticky popup is reversed.)

-

Constant vigilance

-

Some websites add sticky elements after loading, or make existing elements sticky (either on a timer, or based on user actions). CONSTANT VIGILANCE counteracts this behavior, by watching the DOM for mutations, and, if necessary, killing any newly-formed stickies.

-

This feature may slightly impact browser performance on some sites or some computers. If you disable it, stickies will still be killed immediately upon page load, but not thereafter.

Advanced usage

AlwaysKillSticky automatically manages the lists of matching and exclusion patterns. When you enable or disable sticky-killing for a site (by clicking the big button in the AlwaysKillSticky popup), the pattern lists are automatically modified appropriately. There is usually no need to edit the lists yourself.

However, if you prefer more fine-grained control (e.g., if you want to kill stickies on all sites on a domain, or if you want to exclude specific paths of a site), you can edit the pattern lists by hand. The matching and exclusion patterns are regular expressions (a.k.a. “regexps”). (The site RegExr.com is useful if you are not entirely familiar with how regexps work—or even if you are.)

diff --git a/src/options.js b/src/options.js index 0015c20..16336e2 100644 --- a/src/options.js +++ b/src/options.js @@ -49,12 +49,10 @@ 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 constantVigilance = document.querySelector("input#constant-vigilance").checked ? "true" : "false"; chrome.storage.sync.set({ "matchingPatterns": matchingPatterns, "exclusionPatterns": exclusionPatterns, - "mode": mode, - "constantVigilance": constantVigilance + "mode": mode }, () => { setButtonsActive(false); }); } @@ -62,20 +60,16 @@ function saveChanges() { discarding the user's changes. */ function resetChanges(callback) { - chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode", "constantVigilance" ], (result) => { + chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => { AKS.matchingPatterns = result.matchingPatterns || ""; AKS.exclusionPatterns = result.exclusionPatterns || "" AKS.mode = result.mode || "blacklist"; - AKS.constantVigilance = result.constantVigilance || "true"; document.querySelector("#matchingPatterns textarea").value = AKS.matchingPatterns; document.querySelector("#exclusionPatterns textarea").value = AKS.exclusionPatterns; toggleModeSelectorState(AKS.mode); - // Set CONSTANT VIGILANCE! checkbox state. - document.querySelector("input#constant-vigilance").checked = AKS.constantVigilance == "true"; - // De-activate the "Reset" and "Save" buttons. setButtonsActive(false); @@ -175,12 +169,6 @@ function initialize() { }); }); - /* Listener to activate Reset/Save buttons when the CONSTANT VIGILANCE - checkbox is toggled. */ - document.querySelector("input#constant-vigilance").addEventListener("change", (event) => { - setButtonsActive(true); - }); - // Listener for open help button. document.querySelector(".open-help-button").addActivateEvent((event) => { setHelpOverlayVisible(true); diff --git a/src/platform/chrome/manifest.json b/src/platform/chrome/manifest.json index ca3f846..e4cfb5b 100644 --- a/src/platform/chrome/manifest.json +++ b/src/platform/chrome/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "AlwaysKillSticky", - "version": "1.1.3", + "version": "1.2", "description": "Get rid of sticky elements on websites - permanently!", "author": "Said Achmiz", "homepage_url": "https://git.sr.ht/~achmizs/AlwaysKillSticky.git", @@ -12,7 +12,7 @@ }, "content_scripts": [ { "matches": [ "http://*/*", "https://*/*" ], - "run_at": "document_end", + "run_at": "document_start", "js": [ "functions.js", "contentScript.js" ] } ], diff --git a/src/platform/firefox/manifest.json b/src/platform/firefox/manifest.json index a1003e8..a5e4d79 100644 --- a/src/platform/firefox/manifest.json +++ b/src/platform/firefox/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "AlwaysKillSticky", - "version": "1.1.3", + "version": "1.2", "description": "Get rid of sticky elements on websites - permanently!", "author": "Said Achmiz", "browser_specific_settings": { @@ -17,7 +17,7 @@ }, "content_scripts": [ { "matches": [ "http://*/*", "https://*/*" ], - "run_at": "document_end", + "run_at": "document_start", "js": [ "functions.js", "contentScript.js" ] } ],