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