I would like to write an XPCOM component that will display as a javascript object on a web page. Something like Google Gears is what I'm looking for. That is, after installing the Google Gears Firefox extension, the javascript object "google.gears" is available for any web page that wants to use it. I found a lot of mozilla documentation for developing XPCOM, but didn't show anything to the javascript component running on the web page. Is this possible with XPCOM? Do I need to write a Firefox plugin instead of an extension?
I do just that with the new API in Firefox 4 - nsiDOMGlobalPropertyInitializer - which allows you to create a JS object to lazily attach to all windows. This creates a new web console in Firefox 4.
Your component should have the following QI property:
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer]),
Here is an example of a complete implementation in an extension:
https://github.com/daviddahl/domcrypt/blob/master/extension/domcrypt/components/domcrypt.js
SO is basically QI in Ci.nsIDOMGlobalPropertyInitializer, then make sure your manifest has a line, for example:
category JavaScript-global-property crypt @droplettr.com/domcrypt;1
see https://github.com/daviddahl/domcrypt/blob/master/extension/domcrypt/components/domcrypt.manifest
This article seems promising:
, (, -) XPCOM, . , - DOM , , XPCOM . , , , Mozilla, , . nsISecurityCheckedComponent , .
: http://weblogs.mozillazine.org/weirdal/archives/017211.html
3.x - "JavaScript global property". ( 4.x, "JavaScript-global-property", .) nsIClassInfo, , . , , script .
, XPCOM. , , , .
. , - .
You can do this with web extensions, I read and will no longer support
Source: https://habr.com/ru/post/1795301/More articles:Random array allocation in PHP - phpRed5 video quality is awful - javaQCompleter for QTableWidgetItem for auto-collection - c ++Record high-quality video using Flash and Red5 Media Server - flashAccess the list item specified by the iterator - c ++Iterator exception bypass error in Visual C ++ 2010 - iteratorProblem with importing a module and NameError: the global name 'module' is undefined - pythonAndroid Touch listeners? - androidSuggestions for troubleshooting this Perl DBD :: mysql error message? - mysqlSmarty caching (with dynamic content) - phpAll Articles