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:
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).
source share