| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- /***********/
- /* HELPERS */
- /***********/
-
- function checkForShouldKillSticky(result) {
- var shouldKillSticky = false;
-
- let matchingPatterns = result.mode == "whitelist" ?
- [ ".*" ] :
- (typeof result.matchingPatterns != "undefined" ?
- result.matchingPatterns.split("\n") :
- [ ]);
- for (let pattern of matchingPatterns) {
- if (pattern &&
- !pattern.hasPrefix("#") &&
- location.href.match(new RegExp(pattern))) {
- shouldKillSticky = true;
- break;
- }
- }
- let exclusionPatterns = typeof result.exclusionPatterns != "undefined" ?
- result.exclusionPatterns.split("\n") :
- [ ];
- for (let pattern of exclusionPatterns) {
- if (pattern &&
- !pattern.hasPrefix("#") &&
- location.href.match(new RegExp(pattern))) {
- shouldKillSticky = false;
- break;
- }
- }
-
- return shouldKillSticky;
- }
-
- function updateIcon(result) {
- // TODO: code!
- }
-
- /******************/
- /* INITIALIZATION */
- /******************/
-
- function initialize() {
- chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ],
- (result) => {
- let shouldKillSticky = checkForShouldKillSticky(result);
- updateIcon(result);
- window.onload = () => {
- if (shouldKillSticky) killSticky();
- };
- });
- }
- initialize();
|