-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbackground.js
31 lines (29 loc) · 952 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
27
28
29
30
31
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
// changeInfo object: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/onUpdated#changeInfo
// status is more reliable (in my case)
// use "alert(JSON.stringify(changeInfo))" to check what's available and works in your case
if (changeInfo.status === 'complete') {
chrome.tabs.sendMessage(tabId, {
message: 'TabUpdated',
url: tab.url
});
}
})
/*
var uid = null
chrome.runtime.onMessage.addListener(
function(message, sender, sendResponse) {
switch(message.type) {
case "setUID":
uid = message.uid;
break;
case "getUID":
if(uid){
sendResponse(uid);
}
break;
default:
console.error("Unrecognised message: ", message);
}
}
);*/