-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackground.js
53 lines (45 loc) · 1.68 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
try {
chrome.runtime.onInstalled.addListener(() => {
// Page actions are disabled by default and enabled on select tabs
chrome.action.disable();
// Clear all rules to ensure only our expected rules are set
chrome.declarativeContent.onPageChanged.removeRules(undefined, () => {
// Declare a rule to enable the action on example.com pages
let exampleRule = {
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: {hostSuffix: '.aws.amazon.com'},
})
],
actions: [new chrome.declarativeContent.ShowAction()],
};
// Finally, apply our new array of rules
let rules = [exampleRule];
chrome.declarativeContent.onPageChanged.addRules(rules);
});
});
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
if (changeInfo.status == "complete") {
chrome.scripting.executeScript({
files: ['contentScript.js'],
target: { tabId: tab.id }
})
}
})
var keys = null;
var imports = null;
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
if (message.method == 'setKeys')
keys = message.keys;
else if (message.method == 'getKeys')
sendResponse(keys);
else if (message.method == 'getImports'){
sendResponse(imports);
imports = null; //Clear imports
}
else if (message.method == 'setImports')
imports = message.import;
});
} catch (error) {
console.log(error)
}