-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
26 lines (25 loc) · 980 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
chrome.runtime.onInstalled.addListener(function() {
chrome.storage.sync.set({color: '#3aa757'}, function() {
console.log("Hacky times!");
});
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [
new chrome.declarativeContent.PageStateMatcher({})
],
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
});
// don't need if declaratively injecting content script
chrome.runtime.onMessage.addListener(
function(message) { //sender, callback) {
console.log(`background: ${JSON.stringify(message)}`);
// sender example: {"id":"hligmjmffggjjpbnilddcnmmpecgpglc","url":"chrome-extension://hligmjmffggjjpbnilddcnmmpecgpglc/index.html","origin":"chrome-extension://hligmjmffggjjpbnilddcnmmpecgpglc"}
if (message.event == 'parsePage'){
chrome.tabs.executeScript({
file: 'contentScript.js'
});
}
}
);