window.onload = () => { chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ], (result) => { killStickyIfMatch(result); }); }; function killStickyIfMatch(result) { if (typeof result.matchingPatterns == "undefined") return; var killSticky = false; let matchingPatterns = result.mode == "whitelist" ? [ ".*" ] : 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' || getComputedStyle(element).position === 'sticky') { element.remove(); } }); }