Skip to content

Instantly share code, notes, and snippets.

@chriskillpack
Created August 16, 2012 04:41
Show Gist options
  • Save chriskillpack/3366970 to your computer and use it in GitHub Desktop.
Save chriskillpack/3366970 to your computer and use it in GitHub Desktop.
Example chrome extension that reproduces undefined chrome.tabs
chrome.tabs.onUpdated.addListener(function() {
window.console.log('updated from background');
});
chrome.tabs.onUpdated.addListener.addListener(
function(tabId, changeInfo, tab) {
window.console.log('updated from contentscript');
}
);
{
"name": "My test extension",
"version": "1",
"manifest_version": 2,
"background": {
"scripts":["background.js"]
},
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["contentscript.js"]
}
],
"permissions": [
"tabs"
]
}
@gany-c
Copy link

gany-c commented Jun 28, 2015

I'm having the same issue; do you have a solution?

@shubham2892
Copy link

Having the same issue.

@pdtran3k6
Copy link

try putting persistent: true under background in your manifest file.

@tophf
Copy link

tophf commented Jul 5, 2017

For anyone who comes across this gist: chrome.tabs is not available in a content script by design. Content scripts can access only 4 chrome API so chrome.tabs is only available in a background/popup or other internal extension page that has chrome-extension://<extension-id>/ URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment