Skip to content

Instantly share code, notes, and snippets.

@karolmajta
Created March 12, 2014 07:19
Show Gist options
  • Save karolmajta/9502296 to your computer and use it in GitHub Desktop.
Save karolmajta/9502296 to your computer and use it in GitHub Desktop.
How to track
var current = null;
chrome.tabs.query({active: true}, function (tabs) {
current = tabs[0].id;
})
chrome.tabs.onCreated.addListener(function(t) {
current = t.id;
console.log(current);
});
chrome.tabs.onActivated.addListener(function(t) {
current = t.tabId;
console.log(current);
});
{
"manifest_version": 2,
"name": "One-click Kittens",
"description": "This extension demonstrates a browser action with kittens.",
"version": "1.0",
"permissions": [
"tabs"
],
"browser_action": {
"default_icon": "favicon.png",
"default_popup": "popup.html"
},
"background": {
"scripts": ["background.js"]
},
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
}
<!doctype html>
<html>
<head>
</head>
<body>
<script src="popup.js"></script>
</body>
</html>
document.write(chrome.extension.getBackgroundPage().current);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment