-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
26 lines (23 loc) · 896 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.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: {hostEquals: 'www.amazon.co.uk'},
})
],
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
});
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.type == "checkUrl") {
const url = new URL(sender.tab.url)
var code = url.searchParams.get("code");
var state = url.searchParams.get("state");
if (state == "multi-trakt" && code) {
sendResponse({code: code});
}
}
});
// https://developer.chrome.com/docs/extensions/mv3/messaging/