Skip to content
Create a gist now

Instantly share code, notes, and snippets.

anonymous /background.html
Created Apr 21, 2011

Message Passing attempt
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(, {greeting: "hello"}, function(response) {
function(request, sender, sendResponse) {
console.log( ?
"from a content script:" + :
"from the extension");
if (request.greeting == "hello")
sendResponse({farewell: "goodbye"});
sendResponse({}); // snub them.
"name": "Test",
"version": "1.0",
"background": "background.html",
"permissions": [
"tabs", "http://*/*"
"content_scripts": [
"matches": ["http://*/*"],
"js": ["content_script.js"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.