Skip to content

Instantly share code, notes, and snippets.

@autonome
Last active August 29, 2015 14:13
Show Gist options
  • Save autonome/982dda5509122f733846 to your computer and use it in GitHub Desktop.
Save autonome/982dda5509122f733846 to your computer and use it in GitHub Desktop.
/chrome.manifest:
component {a5d89cee-85f4-44ad-b8eb-39ad39170823} components/helloworldapi.js
contract @mozilla.org/helloworld;1 {a5d89cee-85f4-44ad-b8eb-39ad39170823}
category JavaScript-navigator-property helloworld @mozilla.org/helloworld;1
/components/helloworldapi.js:
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
function helloWorld() {
this.wrappedJSObject = this;
}
helloWorld.prototype = {
// this must match whatever is in chrome.manifest!
classID: Components.ID("{a5d89cee-85f4-44ad-b8eb-39ad39170823}"),
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsISupports]),
hello: function() {
return "Hello World!";
}
};
// The following line is what XPCOM uses to create components. Each component prototype
// must have a .classID which is used to create it.
const NSGetFactory = XPCOMUtils.generateNSGetFactory([helloWorld]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment