-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
background.js
30 lines (29 loc) · 1.07 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
(function () {
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (!('action' in request)) {
console.log('No action found in contentHandler.');
return;
}
console.log('Got request: ', request);
if (request.action === 'REMOVE') {
// Begin removing message information.
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, { tabId: tabs[0].id, ...request });
});
} else if (request.action === 'STOP') {
// We can stop by just triggering a reload.
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, {
tabId: tabs[0].id,
action: 'STOP',
});
});
} else if (request.action === 'UPDATE_DELAY') {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, { tabId: tabs[0].id, ...request });
});
} else {
console.log('Unknown action requested: ', request.action);
}
});
})();