Adding APIs to the navigator object
Starting with Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6), you can easily add new APIs to the
This adds a new object,
myApi, to the
window.navigator object. The newly added object is a reference to the component specified by the contract ID
MY_CONTRACT_ID. You can learn more about Contract IDs are unique text identifiers for XPCOM components.
Generate a GUID and replace the "ffff" sections in both the component and contract lines with your GUID.
This adds a new API,
myComponent, to the navigator object, which you can then access as
You can see an example of how this is used in Firefox by taking a look at how the
mozApps API is implemented: