Refactored contentScript.js
This commit is contained in:
parent
7d5b68c007
commit
054b06a4cf
@ -1,14 +1,10 @@
|
|||||||
window.onload = () => {
|
/***********/
|
||||||
chrome.storage.sync.get([ "matchingPatterns", "exclusionPatterns", "mode" ],
|
/* HELPERS */
|
||||||
(result) => {
|
/***********/
|
||||||
killStickyIfMatch(result);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function killStickyIfMatch(result) {
|
|
||||||
if (typeof result.matchingPatterns == "undefined") return;
|
|
||||||
|
|
||||||
|
function checkForShouldKillSticky(result) {
|
||||||
var shouldKillSticky = false;
|
var shouldKillSticky = false;
|
||||||
|
|
||||||
let matchingPatterns = result.mode == "whitelist" ?
|
let matchingPatterns = result.mode == "whitelist" ?
|
||||||
[ ".*" ] :
|
[ ".*" ] :
|
||||||
(typeof result.matchingPatterns != "undefined" ?
|
(typeof result.matchingPatterns != "undefined" ?
|
||||||
@ -33,6 +29,26 @@ function killStickyIfMatch(result) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!shouldKillSticky) return;
|
|
||||||
killSticky();
|
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();
|
||||||
Loading…
Reference in New Issue
Block a user