-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
52 lines (51 loc) · 1.62 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
chrome.commands.onCommand.addListener(command => {
if (command === "highlight_text") {
chrome.tabs.query({ active: true }, tab => {
chrome.tabs.executeScript(tab.id, { file: "injection_script.js" }, _ => {
let e = chrome.runtime.lastError;
if (e !== undefined) {
console.log(tabId, _, e);
}
});
chrome.tabs.executeScript(tab.id, { file: "comment_script.js" }, _ => {
let e = chrome.runtime.lastError;
if (e !== undefined) {
console.log(tabId, _, e);
}
});
chrome.tabs.insertCSS(tab.id, { file: "style.css" }, _ => {
let e = chrome.runtime.lastError;
if (e !== undefined) {
console.log(tabId, _, e);
}
});
});
}
if (command === "clear_storage") {
chrome.tabs.query({ active: true }, tab => {
chrome.tabs.executeScript(tab.id, { file: "clear_storage.js" });
});
}
});
// chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
// if (changeInfo.status == "complete") {
// chrome.tabs.executeScript(tab.id, { file: "injection_script.js" }, _ => {
// let e = chrome.runtime.lastError;
// if (e !== undefined) {
// console.log(tabId, _, e);
// }
// });
// chrome.tabs.executeScript(tab.id, { file: "comment_script.js" }, _ => {
// let e = chrome.runtime.lastError;
// if (e !== undefined) {
// console.log(tabId, _, e);
// }
// });
// chrome.tabs.insertCSS(tab.id, { file: "style.css" }, _ => {
// let e = chrome.runtime.lastError;
// if (e !== undefined) {
// console.log(tabId, _, e);
// }
// });
// }
// });