Firefox gets a User Scripts API

0
158

by Martin Brinkmann on March 27, 2019 in Firefox – 1 comment

Mozilla is working on implementing a UserScripts WebExtensions API in the organization’s Firefox web browser.

Firefox, just like Google Chrome and many other web browsers, supports so-called user scripts. These scripts are executed on page load to add, remove, or change functionality on the page that gets loaded.

User scripts exist for numerous purposes: from adding download options on video sites to changing how  web page looks.

Mozilla addresses several issues related to user scripts with the upcoming User Scripts API:

  • Performance issues — better isolation of scripts thanks to efficient methods.
  • Reliability issues — issues during page load and race conditions between the page loading and script injection.
  • Security issues — the use of sandboxes for individual user scripts reduces the impact that scripts have may have on each other.

The new API runs each user script in its own sandbox to isolate them from one another; this is a different approach to how content scripts are handled from extensions like Greasemonkey or Tampermonkey, as they are executed in the same process.

Support for providing user scripts with a set of functions, e.g. Greasemonkey GM_ functions, is supported as well

Mozilla’s initial plan was to introduce support in Firefox 63 but the introduction has been postponed. The new target is Firefox 68 Stable.

The User Scripts WebExtensions API

firefox user scripts api

Mozilla’s User Scripts API is already available in Firefox. It is enabled by default in Firefox Nightly (version 68), and disabled by default in Firefox Stable (version 66) and Firefox Beta (version 67),

Firefox users may do the following to change the status of the API:

  1. Load about:config in the Firefox address bar.
  2. Confirm that you will be careful if the warning message is displayed.
  3. Search for extensions.webextensions.userScripts.enabled.
  4. Change the status of the preference to True to enable support or to False to disable it.
  5. Restart Firefox.

Extensions such as Greasemonkey or Tampermonkey need to implement the new API before it can be used.

Closing Words

The User Scripts API is finally coming and it should address issues identified when using user scripts in Firefox. It remains to be seen if there are any downsides to the implementation; you can follow the Meta Bug on Mozilla’s bug tracking website to stay in the loop.

Now You: What is your expectation in regards to the user scripts API?