168

Instead of "installing" User-Scripts I found many tutorials on the web to add it manually. All of them told me to do the same steps:

  • Make the directory C:\Users\Blabla\AppData\Local\Google\Chrome\User Data\Default\User Scripts
  • Place a .js file there, which contains the User-Script
  • Start Chrome with the parameter --enable-user-scripts

I did so - but my demo script does not do anything:

// ==UserScript==
// @name           Test
// @description    Test
// @include        http://example.com/*
// @version        1.0
// ==/UserScript==

alert(0);

What am I doing wrong?

YMMD
  • 3,730
  • 2
  • 32
  • 43
  • 2
    User script directory support was removed in 2011. See Does the User Scripts directory still work with Chrome 13.0?: [http://stackoverflow.com/questions/6968469/does-the-user-scripts-directory-still-work-with-chrome-13-0#comment8333680_6979021](http://stackoverflow.com/questions/6968469/does-the-user-scripts-directory-still-work-with-chrome-13-0#comment8333680_6979021). – XP1 Dec 27 '15 at 11:35

5 Answers5

247

The best thing to do is to install the Tampermonkey extension.

This will allow you to easily install Greasemonkey scripts, and to easily manage them. Also it makes it easier to install userscripts directly from sites like OpenUserJS, MonkeyGuts, etc.

Finally, it unlocks most all of the GM functionality that you don't get by installing a GM script directly with Chrome. That is, more of what GM on Firefox can do, is available with Tampermonkey.


But, if you really want to install a GM script directly, it's easy a right pain on Chrome these days...

Chrome After about August, 2014:

You can still drag a file to the extensions page and it will work... Until you restart Chrome. Then it will be permanently disabled. See Continuing to "protect" Chrome users from malicious extensions for more information. Again, Tampermonkey is the smart way to go. (Or switch browsers altogether to Opera or Firefox.)

Chrome 21+

Chrome is changing the way extensions are installed. Userscripts are pared-down extensions on Chrome but. Starting in Chrome 21, link-click behavior is disabled for userscripts. To install a user script, drag the *.user.js file into the Extensions page (chrome://extensions in the address input).

#Older Chrome versions:

Merely drag your *.user.js files into any Chrome window. Or click on any Greasemonkey script-link.

You'll get an installation warning:
Initial warning

Click Continue.


You'll get a confirmation dialog: ![confirmation dialog][8]

Click Add.


Notes:

  1. Scripts installed this way have limitations compared to a Greasemonkey (Firefox) script or a Tampermonkey script. See Cross-browser user-scripting, Chrome section.

Controlling the Script and name:

By default, Chrome installs scripts in the Extensions folder1, full of cryptic names and version numbers. And, if you try to manually add a script under this folder tree, it will be wiped the next time Chrome restarts.

To control the directories and filenames to something more meaningful, you can:

  1. Create a directory that's convenient to you, and not where Chrome normally looks for extensions. For example, Create: C:\MyChromeScripts\.

  2. For each script create its own subdirectory. For example, HelloWorld.

  3. In that subdirectory, create or copy the script file. For example, Save this question's code as: HelloWorld.user.js.

  4. You must also create a manifest file in that subdirectory, it must be named: manifest.json.

For our example, it should contain:

    {
        "manifest_version": 2,
        "content_scripts": [ {
            "exclude_globs":    [  ],
            "include_globs":    [ "*" ],
            "js":               [ "HelloWorld.user.js" ],
            "matches":          [   "https://stackoverflow.com/*",
                                    "https://stackoverflow.com/*"
                                ],
            "run_at": "document_end"
        } ],
        "converted_from_user_script": true,
        "description":  "My first sensibly named script!",
        "name":         "Hello World",
        "version":      "1"
    }

The manifest.json file is automatically generated from the meta-block by Chrome, when a user script is installed. The values of @include and @exclude meta-rules are stored in include_globs and exclude_globs, @match (recommended) is stored in the matches list. "converted_from_user_script": true is required if you want to use any of the supported GM_* methods.

  1. Now, in Chrome's Extension manager (URL = chrome://extensions/), Expand "Developer mode".

  2. Click the Load unpacked extension... button.

  3. For the folder, paste in the folder for your script, In this example it is: C:\MyChromeScripts\HelloWorld.

  4. Your script is now installed, and operational!

  5. If you make any changes to the script source, hit the Reload link for them to take effect:

Reload link




1 The folder defaults to:

Windows XP:
  Chrome  : %AppData%\..\Local Settings\Application Data\Google\Chrome\User Data\Default\Extensions\
  Chromium: %AppData%\..\Local Settings\Application Data\Chromium\User Data\Default\Extensions\

Windows Vista/7/8:
  Chrome  : %LocalAppData%\Google\Chrome\User Data\Default\Extensions\
  Chromium: %LocalAppData%\Chromium\User Data\Default\Extensions\

Linux:
  Chrome  : ~/.config/google-chrome/Default/Extensions/
  Chromium: ~/.config/chromium/Default/Extensions/

Mac OS X:
  Chrome  : ~/Library/Application Support/Google/Chrome/Default/Extensions/
  Chromium: ~/Library/Application Support/Chromium/Default/Extensions/

Although you can change it by running Chrome with the --user-data-dir= option.

Laurel
  • 5,965
  • 14
  • 31
  • 57
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • Sorry, seems as if I didn't point out my problem exactly. I am not having problems installing Userscripts the usual way. I want to make these scripts by myself and I don't want to treat them as an extension. The possibility which I always found on the internet, which tells me to put them in the "User Scripts"-directory simply doesn't work. And I'm trying to find a solution for that. – YMMD Mar 10 '11 at 12:22
  • No, that is not what I intend to do. In the past I developed some userscripts using Firefox, at the moment I prefer surfing with Chrome and for that reason I would like to test them in Chrome. When installing an empty userscript and editing it the way I want it to work the "Extensions"-directory rapidly becomes full of folders with cryptic names and it will always take time to look for the folder which actually contains the file which i'd like to edit. That's all. – YMMD Mar 10 '11 at 22:51
  • One thing to note about the tampermonkey extension is that user scripts running within the tampermonkey are *not* extensions - that's probably apparent, but it has implications if you're sending messages from the user script to another extension, which you can do if you install the user script as an extension, but not if you're running it under tampermonkey. – cori Sep 12 '11 at 13:59
  • 1
    Great answer - updated to reflect the new Chrome "web store only" policy. You can only drag .user.js files into the Extensions window. – crb Jul 09 '12 at 20:31
  • @crb, are you sure about that? That page seems to be mainly talking about extensions hosted on websites. I tested the latest released version (20.0.1132.47 m), and drag-and-drop still works the same as always. Also, clicking on script links from other sites still installs as always (tested on userscripts.org). – Brock Adams Jul 10 '12 at 09:47
  • @BrockAdams The information regarding supported methods is slightly incorrect. See [Greaspot: Cross browser userscripting](http://wiki.greasespot.net/Cross-browser_userscripting#Google_Chrome) for the correct information (I've tested and edited that wiki a while back, so it's correct. It's still correct in Chrome 20). – Rob W Jul 10 '12 at 10:55
  • Thanks for the detail Brock. One question - you write "You must also create a manifest file" but then shortly afterwards you write "The manifest.json file is automatically generated from the meta-block by Chrome". So which must I do? – Colonel Panic Dec 18 '12 at 00:03
  • @ColonelPanic, If you want to install a script with a sensible name and location (and more easily updatable), follow the directions and create the manifest as indicated. The text was just explaining that if a plain userscript is installed (that is, drag a `*.user.js` file into the `chrome://chrome/extensions` page), then that process would result in an auto-generated manifest. It's easier but without the benefits of the controlled method. – Brock Adams Dec 18 '12 at 00:18
  • Great! That means I can use the auto-generated manifest as a starting copy and just tweak as necessary. Thanks again. – Colonel Panic Dec 18 '12 at 00:26
  • 2
    @ColonelPanic, Sadly, no you can't. The auto generated manifest is currently not compatible with the extension process! It doesn't use `"manifest_version": 2`, which is now required. Use the example in the answer as your starting copy (or at least don't forget the `"manifest_version": 2`). ... Google is setting up all "normal" userscripts to fail in a pending release, unless they change the auto-manifest process soon. – Brock Adams Dec 18 '12 at 00:34
  • This extension requires access to all my data on all websites, which access I'm not willing to provide so the second answer is better. – Bjorn Aug 28 '13 at 19:07
  • @BjornTipling, If you mean this sample extension, then you are Wrong. If you mean Tampermonkey, then so what? Tampermonkey is a safe and thoroughly vetted extension, and you can inspect the source code yourself. ... As for the second answer, it's just a repeat of a small part of this answer, without options or explanation. It's also a short term solution, the worst of both worlds -- none of the power of either Tampermonkey or a full extension and none of the ease and compatibility of Tampermonkey. – Brock Adams Aug 29 '13 at 00:14
  • 1
    @brock I just dragged and dropped my userscript into the extensions window like the second answer and now I don't have to worry about the vetting of Tampermonkey. It just worked. :) – Bjorn Aug 29 '13 at 01:27
  • @BjornTipling, good for you. See *note 2*, above. `"...drag the *.user.js file into the Extensions page..."` – Brock Adams Aug 29 '13 at 01:58
  • 2
    @brock I know you have that, but given your recommendation to use Tampermonkey, an extension that requires access to all of your banking sites information, your facebook, everything, the second answer is better. And as for 'vetted' there's absolutely nothing anyone can do to vet a chrome extension as you can update them automatically to do bad things anytime, and then update them again to hide this. You'd have to vet every change every time. It's permissions to everything. Everything. – Bjorn Aug 30 '13 at 14:53
  • @BjornTipling Absolutely. However I solve this, I had to put my trust in someone, that the permissions are properly enforced. The first solution requires me to put my trust in Tapermonkey (and Chromium by extension), the second one into Chromium itself. I do not know which is better, for one, I am able to go through Tapermonkey source and review it. I cannot do the same for Chrome. Now I do it the drag `.user.js`, after first reading the script and looking for constructs I do not understand. (If there are any, I do not install) – user7610 Mar 13 '14 at 09:35
  • You can evaluate Chromium's source. Chromium is open source and mostly developed by Google which has no interest in stealing your banking data. Any change to Chromium is reviewed by a community in the open. Extensions like Tapermonkey are just some things out there some dude you don't know can edit to add malicious stuff. They can add it one day, and remove it the next without anyone ever knowing. You wouldn't want your friend standing over you while you type your password for your bank website, but you'd give everything to strangers who made your extensions? – Bjorn Mar 13 '14 at 12:29
  • Also you're already giving your trust to Google by using Chromium in the first place. If you don't trust Google don't use Chrome, use Firefox or don't go online (your only other option is Opera which uses Blink which is developed by Google engineers). – Bjorn Mar 13 '14 at 12:32
  • @BrockAdams, Are the scripts that we install using "load unpacked extension" able to call the Chrome-specific browser functions? (as opposed to normal Javascript functions) – Pacerier Apr 18 '15 at 13:27
  • @Pacerier, See the Chrome docs. Scripts loaded that way can call many additional, but not all, `chrome.*` API's. – Brock Adams Apr 18 '15 at 13:49
  • @BrockAdams : I just [updated chrome](http://blog.chromium.org/2015/05/continuing-to-protect-chrome-users-from.html), and it disabled all my user scripts because it said the extensions weren't on the chrome web store. – user2284570 Jun 10 '15 at 23:05
  • dragging and dropping the user script in chrome doesn't include Jquery as standard so I'm going to use TamperMonkey. – Joshua Duxbury Apr 27 '16 at 16:08
  • I tried to just drag and drop the js script but chrome automatically banned the script please help! – marshmellooooooos Nov 28 '16 at 03:51
  • 1
    @marshmellooooooos, still works for me (Chrome 54.0.2840.99 m). If you can't get it to work, either install Tampermonkey or open a new question with **EXACT** details of what you tried. – Brock Adams Nov 28 '16 at 04:03
  • I tried to post questions multiple times but no one seemed to answer. [Click here](http://stackoverflow.com/questions/40833397/problems-with-js-script-and-chrome) to see my stack Or [this one](http://stackoverflow.com/questions/40796949/how-to-add-user-script-js-file-as-a-chrome-extension) – marshmellooooooos Nov 28 '16 at 04:20
  • @marshmellooooooos, Ah. I see and I just answered one of those Q's. Plus, you got some spot-on advice on [this other Q of yours](http://stackoverflow.com/questions/40725545/running-your-custom-java-script-when-visiting-a-website). Take it. As for why people might not respond to your Q's; the [faq] covers that, plus you might want to consider your voting and accepting rate. – Brock Adams Nov 28 '16 at 05:20
  • Indeed, but the new headless chrome. How would one get around this as extensions are disabled. – Tetora Nov 02 '17 at 09:54
  • May I ask why you recommend that people switch browsers to Firefox or Opera? It seems to me that you still need to install an extension to get userscripts to work. And switching browsers seems to be a drastic step to get userscripts to work. – Cave Johnson Jan 25 '19 at 17:48
  • @KodosJohnson, the recommendation was one of **3**: Tampermonkey, or Firefox, or Opera. The first does not involve switching browsers. Also there are other options, like Violentmonkey, now. – Brock Adams Jan 25 '19 at 18:16
53

Update 2016: seems to be working again.

Update August 2014: No longer works as of recent Chrome versions.


Yeah, the new state of affairs sucks. Fortunately it's not so hard as the other answers imply.

  1. Browse in Chrome to chrome://extensions
  2. Drag the .user.js file into that page.

Voila. You can also drag files from the downloads footer bar to the extensions tab.

Chrome will automatically create a manifest.json file in the extensions directory that Brock documented.

<3 Freedom.

Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
  • 15
    be sure that the file name is like .user.js, otherwise chrome doesn't recognize it as extension – Paco Dec 31 '12 at 12:09
  • 1
    @AlexTracer It works for me on Chromium 33. Maybe you are doing something wrong. – user7610 Mar 13 '14 at 09:37
  • 5
    Doesn't work anymore in Chrome 36. User scripts added this way come with the message: "this extension is not listed in the Chrome Web Store and may have been added without your knowledge", and the enable-checkbox is disabled. – Protector one Aug 12 '14 at 18:28
  • 1
    But it _does_ work when you launch Chrome using the `--enable-easy-off-store-extension-install` parameter like Joey says! – Protector one Aug 30 '14 at 19:35
  • 2
    This works for me in Chrome 51, and I'm not using any command line parameters. Maybe they changed it back again? – Miscreant Jun 10 '16 at 08:09
  • 7
    I just tried this (Chrome 60) and was sent to [a page](https://support.google.com/chrome/answer/2811969) which says "Extensions that have not been published on the Chrome Web Store are grayed out and you won't be able to turn them back on." Sounds like the August 2014 behavior. Not sure if they re-disabled this or it's just me missing something. – Pops Sep 01 '17 at 05:06
  • chrome 81+ you need to enable Developer mode – user1461607 Apr 14 '20 at 14:10
12

This parameter works for me:

--enable-easy-off-store-extension-install

Do the following:

  1. Right click on your "Chrome" icon.
  2. Choose properties
  3. At the end of your target line, place these parameters: --enable-easy-off-store-extension-install
  4. It should look like: chrome.exe --enable-easy-off-store-extension-install
  5. Start Chrome by double-clicking on the icon
Yar
  • 7,020
  • 11
  • 49
  • 69
joeytwiddle
  • 29,306
  • 13
  • 121
  • 110
  • I got that from http://superuser.com/questions/450893/how-to-install-a-private-user-script-in-chrome-21 – joeytwiddle Jul 26 '12 at 05:49
  • 1
    Administrators can also create a policy for all users, with allowed URLs whitelisted by pattern: http://www.chromium.org/administrators/policy-list-3#ExtensionInstallSources – joeytwiddle Jul 26 '12 at 06:06
  • Do I really need to delete the old script and install it completely new by dragging it into the browser again when I edited stuff? Or is there an easier way? – YMMD Aug 16 '12 at 21:28
  • To update a script, I navigate to it on filesystem or webserver, and click to install; Chrome overwrites the old version. If you are developing a script and don't want to keep installing it, try a bookmarklet/userscript hybrid: http://stackoverflow.com/questions/1810885/easier-bookmarklet-development/4488511 – joeytwiddle Sep 28 '12 at 10:59
  • Mmmm yeah it looks like they have disabled side-loading on purpose: https://blog.chromium.org/2018/06/improving-extension-transparency-for.html – joeytwiddle Apr 14 '20 at 14:34
2

Share and install userscript with one-click

To make auto-install (but mannually confirm), You can make gist (gist.github.com) with <filename>.user.js filename to get on-click installation when you click on Raw and get this page:

Installation page

How to do this ?

  1. Name your gist <filename>.user.js, write your code and click on "Create".
    Make file on gist

  2. In the gist page, click on Raw to get installation page (first screen).
    Raw button

  3. Check the code and install it.

user2226755
  • 12,494
  • 5
  • 50
  • 73
  • Nice idea. But in dec 2020, Chrome is giving this message: Apps, extensions and user scripts cannot be installed from this website. – Rehmat Dec 21 '20 at 03:57
0

April 2020 Answer

In Chromium 81+, I have found the answer to be: go to chrome://extensions/, click to enable Developer Mode on the top right corner, then drag and drop your .user.js script.

user1461607
  • 2,416
  • 1
  • 25
  • 23
  • 8
    In Chrome (not Chromium) this doesn't work for me. It says it's not from the chrome web store and forces it to be disabled. – Kyle Pittman Apr 27 '20 at 15:37