|
|
|
|
|
|
|
|
/* HELPERS */ |
|
|
/* HELPERS */ |
|
|
/***********/ |
|
|
/***********/ |
|
|
|
|
|
|
|
|
|
|
|
/* Given the result of a query to storage (for the matching and exclusion |
|
|
|
|
|
pattern lists, and the current mode - whitelist or blacklist), this function |
|
|
|
|
|
determines whether stickies should be killed on the currently loaded page. |
|
|
|
|
|
|
|
|
|
|
|
Stickies are killed if the following is true: |
|
|
|
|
|
|
|
|
|
|
|
(blacklist mode is active, AND |
|
|
|
|
|
at least one matching pattern matches the URL of the current page, AND |
|
|
|
|
|
zero exclusion patterns match the URL of the current page) |
|
|
|
|
|
OR |
|
|
|
|
|
(whitelist mode is active, AND |
|
|
|
|
|
zero exclusion matters match the URL of the current page) |
|
|
|
|
|
*/ |
|
|
function checkForShouldKillSticky(result) { |
|
|
function checkForShouldKillSticky(result) { |
|
|
var shouldKillSticky = false; |
|
|
var shouldKillSticky = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* If whitelist mode is active, then the matching patterns list is treated |
|
|
|
|
|
as containing a single pattern which will match all possible URLs. |
|
|
|
|
|
Patterns that are empty strings (i.e., blank lines in the patterns |
|
|
|
|
|
lists) are ignored, as are any patterns that begin with a pound sign (#) |
|
|
|
|
|
(this allows for comments in the patterns lists). */ |
|
|
let matchingPatterns = result.mode == "whitelist" ? |
|
|
let matchingPatterns = result.mode == "whitelist" ? |
|
|
[ ".*" ] : |
|
|
[ ".*" ] : |
|
|
(typeof result.matchingPatterns != "undefined" ? |
|
|
(typeof result.matchingPatterns != "undefined" ? |
|
|
|
|
|
|
|
|
return shouldKillSticky; |
|
|
return shouldKillSticky; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* This function sends a message to the background script (background.js), |
|
|
|
|
|
which then updates the page action icon (i.e., the browser toolbar icon) |
|
|
|
|
|
to reflect whether killing stickies is enabled on the current page. |
|
|
|
|
|
*/ |
|
|
function updateIcon(shouldKillSticky) { |
|
|
function updateIcon(shouldKillSticky) { |
|
|
chrome.runtime.sendMessage({ "killingStickies" : shouldKillSticky }); |
|
|
chrome.runtime.sendMessage({ "killingStickies" : shouldKillSticky }); |
|
|
} |
|
|
} |