Created
August 16, 2012 04:41
-
-
Save chriskillpack/3366970 to your computer and use it in GitHub Desktop.
Example chrome extension that reproduces undefined chrome.tabs
This file contains hidden or 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
chrome.tabs.onUpdated.addListener(function() { | |
window.console.log('updated from background'); | |
}); |
This file contains hidden or 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
chrome.tabs.onUpdated.addListener.addListener( | |
function(tabId, changeInfo, tab) { | |
window.console.log('updated from contentscript'); | |
} | |
); |
This file contains hidden or 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
{ | |
"name": "My test extension", | |
"version": "1", | |
"manifest_version": 2, | |
"background": { | |
"scripts":["background.js"] | |
}, | |
"content_scripts": [ | |
{ | |
"matches": ["http://*/*", "https://*/*"], | |
"js": ["contentscript.js"] | |
} | |
], | |
"permissions": [ | |
"tabs" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.