Greasemonkey @require not working in Chrome

I'm trying to add jQuery using Greasemonkey @require

/ method @include

, but it doesn't work. The following error appears:

Uncaught ReferenceError: $ is not defined (repeated 10 times)


This is my example code:

// ==UserScript==
// @description Bored, really bored.
// @name MatteoSample
// @namespace MatteoSampleNamespace
// @include *
// @include
// ==/UserScript==



How can I fix this?


source to share

2 answers


is not a valid meta-rule, so it is ignored.
Use @require

if you want to load jQuery into your user script.

// ==UserScript==
// @name       Foo
// @namespace  Bar
// @include    *
// @require
// ==/UserScript==


EDIT: In the comments, you said you are using Chrome . Chrome doesn't support the rule @require

. See also:

If you need full Greasemonkey support in Chrome, use Tampermonkey .

Eliminate user scripting confusion in Chrome

Chrome does not natively support GreaseMonkey. Whenever a file is downloaded .user.js

, it is converted to a Chrome extension as a Content script .

For more information on user scripting in Chrome, see this documentation .

The user script is literally copied to the extension directory:

// ==UserScript==
// @name       Foo
// @namespace  Bar
// @include    *
// @require
// ==/UserScript==
alert(typeof $)


A manifest.json

file is created based on the metablock. When a user script contains a rule @include

, his rule matches

will contain https://*/*

also http://*/*

because of a too loose rule @include


The generated content manifest.json

looks like this:

   "content_scripts": [ {
      "exclude_globs": [  ],
      "include_globs": [ "*" ],
      "js": [ "script.js" ],
      "matches": [ "http://*/*", "https://*/*" ],
      "run_at": "document_idle"
   } ],
   "converted_from_user_script": true,
   "description": "",
   "key": "+.... some key ...=",
   "name": "Foo",
   "version": "1.0"




chrome doesn't support greasemonkey scripts, but rather greasemonkey special commands (@require, GM_, etc.)

to get this stuff install the "TamperMonkey" chrome addon



All Articles