Last active
March 18, 2020 16:56
-
-
Save kimuchi1203/5998828 to your computer and use it in GitHub Desktop.
chrome extension to log tabs user watched.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tabToUrl = {}; | |
chrome.tabs.onCreated.addListener( | |
function(tab) { | |
console.log("create "+tab.url); | |
} | |
); | |
chrome.tabs.onUpdated.addListener( | |
function(tabId, changeInfo, tab) { | |
console.log("update "+changeInfo.url); | |
tabToUrl[tabId] = tab.url; | |
} | |
); | |
chrome.tabs.onActivated.addListener( | |
function(activeInfo) { | |
chrome.tabs.get(activeInfo.tabId, function(tab) { | |
console.log("activate "+tab.url); | |
}); | |
} | |
); | |
chrome.tabs.onHighlighted.addListener( | |
function(highlightInfo) { | |
chrome.tabs.get(highlightInfo.tabIds[0], function(tab) { | |
console.log("highlight "+tab.url); | |
}); | |
} | |
); | |
chrome.tabs.onRemoved.addListener( | |
function(tabId, removeInfo) { | |
console.log("delete "+tabToUrl[tabId]); | |
delete tabToUrl[tabId]; | |
} | |
); | |
chrome.tabs.onReplaced.addListener( | |
function(addedTabId, removedTabid) { | |
chrome.tabs.get(addedTabId, function(tab) { | |
console.log("replace "+tab.url); | |
}); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment