Update on tab activate as well as update

This commit is contained in:
Will Bamberg
2017-04-28 11:07:37 -07:00
parent a43eb72e76
commit 06cac5f7a6

View File

@@ -1,12 +1,10 @@
/* Retrieve any previously set cookie and send to content script */
browser.tabs.onUpdated.addListener(cookieUpdate);
function getActiveTab() {
return browser.tabs.query({active: true, currentWindow: true});
}
function cookieUpdate(tabId, changeInfo, tab) {
function cookieUpdate() {
getActiveTab().then((tabs) => {
// get any previously set cookie for the current tab
var gettingCookies = browser.cookies.get({
@@ -22,3 +20,8 @@ function cookieUpdate(tabId, changeInfo, tab) {
});
});
}
// update when the tab is updated
browser.tabs.onUpdated.addListener(cookieUpdate);
// update when the tab is activated
browser.tabs.onActivated.addListener(cookieUpdate);