I am trying to modify a piece of code I wrote for Grease Monkey to make it compatible with Tampermonkey. Tamper monkey keeps saying '$' is not defined despite my @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js. The require works on Greasemonkey.
The Tampermonkey instaled function(s) overview recognizes the JQuery require.
// ==UserScript==
// @name Function
// @version 1
// @run-at document-end
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// ==/UserScript==
var userIP;
$.ajax({
url: "https://api.ipify.org/?format=json", // Getting user Ip Address
async: false,
dataType: 'json',
success: function(data) {
userIP = data.ip; // Saving user Ip Address
}
});
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 $ */