Tampermonkey jQuery require not working

Greasemonkey uses the CodeMirror text editor combined with the JSHINT linter.

In order for the JSHINT to recognize global variables declared outside of your code, you need to define them using an inline comment. For example, to tell JSHINT about jquery, use this:

/* globals $ */

See https://jshint.com/docs/#inline-configuration


Since you say it is only in the editor this is probably Tampermonkey's syntax checking not loading required scripts, and using them as part of the code checking process. So it just sees that a variable has not been declared anywhere in the user script itself and shows the warning. The script should still work as expected.

If the messages annoy you, you can clear them by explicitly declaring the $ variable at the top of your script like so:

var $ = window.jQuery;//OR
var $ = window.$;