-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
25 lines (23 loc) · 826 Bytes
/
background.js
File metadata and controls
25 lines (23 loc) · 826 Bytes
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
chrome.runtime.onInstalled.addListener(() => {
chrome.action.disable();
chrome.declarativeContent.onPageChanged.removeRules(undefined, () => {
chrome.declarativeContent.onPageChanged.addRules([
{
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { hostContains: 'amazon.' },
})
],
actions: [new chrome.declarativeContent.ShowAction()]
}
]);
});
});
chrome.commands.onCommand.addListener(async (command) => {
if (command === "_execute_action") {
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
if (tab?.url?.includes('amazon.')) {
chrome.action.openPopup();
}
}
});