I am using jQuery with GM 1.5 and have found I am unable to use .get
I require http://code.jquery.com/jquery.js
and my code is just this
this.$ = this.jQuery = jQuery.noConflict(true);
$(document).ready(function () {
$.get('index.php',function () {
console.log('yay');
console.log($(this).html());
});
});
I am sure I have been able to do this in previous versions, is this something to do with the sandbox changes that were made?
The code in the question works fine. Verified with Greasemonkey 1.5 and Firefox 16 and 17 on Windows XP and Windows 7.
Re:
You don't have to choose. Don't inject jQuery (or most other libraries) use
@require
. Then, with the proper@grant
directives, you can useGM_
functions easily.There is no point in code like
this.$ = this.jQuery = jQuery.noConflict(true);
unless you use@grant none
-- which would shut offGM_
functions.$(document).ready()
is not needed in a Greasemonkey script unless you use@run-at document-start
.So, use code like this: