diff --git a/contentScript.js b/contentScript.js index 489dcdf..1ba196b 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1,21 +1,32 @@ window.onload = () => { - chrome.storage.sync.get("patterns", (result) => { - killStickyIfMatch(result.patterns); + chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns" ], (result) => { + killStickyIfMatch(result); }); }; -function killStickyIfMatch(patterns) { - if (typeof patterns == "undefined") return; +function killStickyIfMatch(result) { + if (typeof result.matchingPatterns == "undefined") return; - patterns = patterns.split("\n"); var killSticky = false; - for (let pattern of patterns) { + let matchingPatterns = result.matchingPatterns.split("\n"); + for (let pattern of matchingPatterns) { if (location.href.match(new RegExp(pattern))) { killSticky = true; break; } } + let exclusionPatterns = (typeof result.exclusionPatterns != "undefined" && + result.exclusionPatterns != "") ? + result.exclusionPatterns.split("\n") : + [ ]; + for (let pattern of exclusionPatterns) { + if (location.href.match(new RegExp(pattern))) { + killSticky = false; + break; + } + } if (!killSticky) return; + console.log("Killing all stickies!"); document.querySelectorAll('body *').forEach(element => { if (getComputedStyle(element).position === 'fixed' || diff --git a/manifest.json b/manifest.json index 8fb4436..7813cfe 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "AlwaysKillSticky", - "version": "0.1", + "version": "0.2", "description": "Get rid of sticky elements on websites - permanently!", "permissions": [ "activeTab", "storage" ], "content_scripts": [ diff --git a/options.html b/options.html index b4a2dbe..9838549 100644 --- a/options.html +++ b/options.html @@ -20,25 +20,61 @@ padding: 10px; font-size: 1rem; } + body > div { + border: 1px solid #ddd; + padding: 30px 15px 15px 15px; + position: relative; + } + body > div + div { + margin: 2.5em 0 0 0; + } + h1 { + border-bottom: 1px solid #ddd; + } + h2 { + margin: 0; + background-color: #fff; + padding: 10px 15px; + position: absolute; + top: calc(-1 * (0.625em + 10px)); + left: 10px; + border: inherit; + } textarea { - min-height: 400px; - border: 1px solid #bbb; + border: 1px solid #aaa; font-family: Inconsolata, Courier, monospace; font-size: 1.125rem; + width: 100%; + } + #matchingPatterns textarea { + min-height: 300px; + } + #exclusionPatterns textarea { + min-height: 150px; } form { text-align: right; + margin: 0 0 1em 0; + display: flex; + justify-content: flex-end; + align-items: center; } button { -webkit-appearance: none; -moz-appearance: none; - border: 1px solid #99; - font-size: 1.5rem; + border: 1px solid #bbb; color: #fff; - margin: 1em auto; padding: 10px 16px; - background-color: #16e; cursor: default; + margin: 0 0 0 0.5em; + } + button.save-button { + background-color: #16e; + font-size: 1.5rem; + } + button.reset-button { + background-color: #d3453d; + font-size: 1rem; } button:active { transform: scale(0.95); @@ -47,16 +83,27 @@ outline: none; } button:disabled { - filter: saturate(0); + background-color: #777; opacity: 0.5; }
Enter a list of regular expression patterns to match URLs, one per line. Stickies will be killed on pages matching those patterns.
- - + +Kill stickies on web page URLs matching the following regular expressions (one per line):
+ +Do not kill stickies on web page URLs matching the following regular expressions (one per line):
+ +