Skip to content

Instantly share code, notes, and snippets.

@erkantaylan
Forked from sajirdalas/Tutorial 10
Last active August 29, 2015 14:20
Show Gist options
  • Save erkantaylan/68577c642770b74ad9ff to your computer and use it in GitHub Desktop.
Save erkantaylan/68577c642770b74ad9ff to your computer and use it in GitHub Desktop.
//main.js
var cm = require("sdk/context-menu");
var item = cm.Item({
label: "Search on google",
data: "MyId",
//context: cm.PageContext()
//context: cm.URLContext(["*.mozilla.org","*.reddit.com"])
//context: cm.SelectionContext()
//context: cm.SelectorContext("#header-img")
contentScriptFile: "./CMcontentScript.js",
onMessage: function(payload){
tabs.open(payload);
}
});
//CMcontentScript.js
self.on("click",function(node,data){
console.log(node.href);
self.postMessage(node.href);
});
self.on("context",function(node){
if(typeof node.href != "undefined"){
return true;
}
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment