How to publish a Greasemonkey script as a complement to Firefox?

I recently worked on a script in Greasemonkey and would like to publish it as an add-on for Firefox. What is the easiest way to do this?

+6
source share
2 answers

Just publish the script to userscripts.org 1 OpenUserJS.org (or one of the other userscripts.org user replacements).
Trying to repack it as a supplement is usually more of a problem than it's worth it.


If you really need to, you can use the Greasemonkey script compiler to turn your script into an “add-on”, and then send that add-on to Mozilla through the normal add process .

Please note that Vladimir's answer is better than the Greasemonkey script compiler.



1 Userscripts.org is now long dead .

+4
source

While you can “compile” the GreaseMonkey script (see Brock's answer), this solution is not well supported. A more reliable option would be to use the Add-on SDK and JPM . Your lib/main.js can be very simple ( page-mod module documentation ):

 var data = require("sdk/self").data; var pageMod = require("sdk/page-mod"); pageMod.PageMod({ include: "*.example.com", contentScriptWhen: 'end', contentScriptFile: data.url("contentScript.js") }); 

This is equivalent to the following GreaseMonkey script header:

 // @include http://example.com/* // @include http://*.example.com/* 

And then you add the GreaseMonkey script as data/contentScript.js (the Add-on SDK will ignore the GreaseMonkey header, the information is specified elsewhere) and build the extension. In most cases, it will work unless the GreaseMonkey script uses any special GreaseMonkey API, in which case you will need to find a replacement. unsafeWindow supported (usually the usual warnings apply).

+10
source

Source: https://habr.com/ru/post/921389/


All Articles