Turn userscripts into Firefox extensions

Daniel Pataki
Feb 7, 2008
Updated • Mar 29, 2014
Firefox, Firefox add-ons, userscripts
|
1

I've always loved user scripts because they are easy to install, audit and to manage. If you prefer Firefox add-ons however, you can now compile scripts so that they can be installed just like any other extension of the browser.

Off the top of my head I can think of about 50 reasons this is great. I like it a lot, because I think many people don't try userscripts because it seems a bit more complicated than just click and install, but of course that's not true. It's also probably easier for you to get your scripts back after an uninstall if you just compile them into an add-on.

Last but not least, you can also use extensions to avoid having to use an extension such as Greasemonkey to load them, which may be useful if you encounter issues when you run it on your system or simply do not want it to be installed in the browser.

The way you can create these xpi files is to use the online Greasemonkey Script Compiler. You just input all the data and you're done. You need to download the actual script first, or navigate to the "gm_scripts" folder inside your Firefox profile folder. You should find some javascript (js) files in there, these are what we are looking for.

You need to open the one you want to compile, you can easily to this by renaming it as a text file (txt), and then you just have to copy the appropriate parts from it as the instructions ask you to do.

When you're done, you can just rename it to ".js" again, and you will get back your script as it was. You can alternatively right-click the JavaScript file and select to open it with Notepad. No matter what you do, you still have to paste the code as instructed on the web page into the User script field on the page.

Basically, what you need to paste is the complete ==UserScript== block of the script. You may also want to modify the Firefox max version so that you do not run into any forced compatibility issues later on.

One way of doing that is to enter a very high max version, for instance 99. This prevents that the extension cannot be installed in newer versions of Firefox due to the version limit you set during compilation of the script.

Advertisement

Tutorials & Tips


Previous Post: «
Next Post: «

Comments

  1. avi said on February 7, 2008 at 10:12 pm
    Reply

    greasemonkey scripts are much lighter on resources, and work right away without having to restart firefox. i know its not applicable to most firefox extensions, but what i would really be interested in is a way to covert them into greasemonkey scripts.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.