-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
33 lines (28 loc) · 916 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var settings;
// load settings from local storage
chrome.storage.local.get(
['allowedDomainsRe', 'notAllowedDomainsRe'],
function _processSettingsFromStorage(res) {
settings = res;
}
);
function isPageAllowedToProcess(pageUrl) {
console.log('page ' + pageUrl + ' allowed to process');
return true;
}
function onPageProcessed(pageData) {
console.log('onPageProcessed', pageData);
}
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (isPageAllowedToProcess(tab.url)) {
console.log(chrome.tabs.executeScript.toSource());
chrome.tabs.executeScript(tabId, {file: 'content.js'}, onPageProcessed);
} else {
// Show PeARS page action if page is not allowed for user to be able to manually process page
chrome.pageAction.show(tab.id);
}
});
chrome.pageAction.onClicked.addListener(function () {
var allowed = false;
console.log('page action clicked');
});