MozillaZine

UserChrome.js

From MozillaZine Knowledge Base

userChrome.js in the chrome folder is a JavaScript file that can be used to change the way Mozilla applications work.

Mozilla applications do not support userChrome.js by default. You must install the userChrome.js extension to add support for the file.

The file does not exist in a new profile. The extension creates it automatically, or you can create it manually.

Contents

The userChrome.js extension

The extension works in Firefox, Thunderbird, SeaMonkey, and other applications (Mozilla Suite, Netscape Browser, Flock, NVU and Sunbird).

For information about the extension, and a download link, see this forum thread: userChrome.js

Finding userChrome.js

To find the file, go to your profile folder. Then go to the chrome folder there, where you should find the file userChrome.js.

If the file is not there, create it manually as a plain text file.

Notes: 

  • If you have more than one profile, then each of your profiles has a separate userChrome.js file.
  • There is another chrome folder where Thunderbird's code is installed. Do not create a userChrome.js file there—it will not work.

Editing userChrome.js

This file is designed to be manually edited using a text editor. Anything valid in a JavaScript file is valid in this file. To make the changes take effect, you must restart the application.

For sample scripts, see the forum thread: userChrome.js, and also these pages here:

  • General scripts for all Mozilla applications
  • Mail scripts for Thunderbird and SeaMonkey
  • Browser scripts for Firefox and SeaMonkey

To make your own scripts, you need technical knowledge of Mozilla applications and JavaScript programming. The DOM Inspector extension can be useful for revealing the structure of the application.

Instead of editing the file directly, you can use the ChromEdit Plus extension to work with it.

Moving and copying userChrome.js

You can move or copy userChrome.js to a different profile. If it imports or references other files, then you must also move or copy these other files. To make the changes take effect, you must restart the application.

Deleting userChrome.js

You can delete userChrome.js to get rid of any user scripts defined there. To make the change take effect, you must restart the application.

If the extension is still installed, it will create a new empty userChrome.js file. You can disable or uninstall the extension in the normal way.

Troubleshooting

Only open the file with a suitable editor. Do not open it with any other application (for example, Microsoft JScript).

You can use a plain text editor, or an editor that provides special support for JavaScript files. Do not use an editor that saves the file in a wordprocessing format, or in Unicode.

For some information about common problems, see: Editing configuration – Troubleshooting

Related files and folders

See also

External links