Created
March 21, 2011 22:24
-
-
Save dascgo/880361 to your computer and use it in GitHub Desktop.
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
// load in our tools | |
var tabs = require("tabs"); | |
var data = require("self").data; | |
// when someone goes to a tab: | |
tabs.on('activate', function(tab){ | |
tab.attach({ | |
// attach the tab.js file | |
contentScriptFile: data.url("tab.js"), | |
// and handle messages coming FROM tab.js | |
onMessage: function(data){ | |
if(data.type == "click"){ | |
// do some stuff, then post back to the tab | |
this.postMessage({ | |
"type": "click_complete", | |
"msg": "thanks for clicking the button!" | |
}); | |
}else{ | |
console.log("unknown message from TAB: " + data.toSource()); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment