How can I use jQuery in Greasemonkey?

Perhaps you don’t have a recent enough version of Greasemonkey. It was version 0.8 that added @require.

// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js 

If you don’t have 0.8, then use the technique Joan Piedra describes for manually adding a script element to the page.

Between version 0.8 and 0.9, @require is only processed when the script is first installed. If you change the list of required scripts, you need to uninstall your script and reinstall it; Greasemonkey downloads the required script once at installation and uses a cached copy thereafter.

As of 0.9, Greasemonkey behavior has changed (to address a tangentially related issue) so that it now loads the required scripts after every edit; reinstalling the script is no longer necessary.

Leave a Comment