
When I googled how to use jQuery in a Greasemonkey script — a script to run on a web page that already loads some other, conflicting, JavaScript framework, like Prototype — I found no script that worked. Not a fucking one. They all contained very wrong bits, and I wander why they're still published. They're still indexed so that people like me can experience more pain. Here's what I came up with after much labor. I believe it is fail-proof.
![[]](/files/greasemonkey_and_jquery.jpg)
// ==UserScript== // @name name // @namespace namespace // @description Does jQuery stuff while playing nice with other JavaScript frameworks // @author Caroline Schnapp // @homepage http://11heavens.com/using-greasemonkey-to-load-and-use-jQuery // @include * // ==/UserScript== // Add jQuery var script = document.createElement('script'); script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'; document.getElementsByTagName('head')[0].appendChild(script); // When jQuery is loaded script.addEventListener('load', function(){ jQuery = unsafeWindow['jQuery']; jQuery.noConflict(); /* You put your jQuery code here, which must use the jQuery namespace. See Note. */ }, false);
My code makes the following assumptions:
jQuery(function {}); construct in your code later on.
Comments
your solution stands out
your solution stands out where no other worked sir.
i am using the $ variable just fine too :)
Special Content!
This is compared to anything else is extra. The other way is not a lot of people have a choice. But this one is special, as well as abnormal.
Honeymoon Destinations in india | Best Honeymoon Destinations in India
When I googled how to use
When I googled how to use jQuery in a Greasemonkey script — a script to run on a web page that already loads some other, conflicting, JavaScript framework, like Prototype — I found no script that worked. Not a fucking one. They all contained very http://e-papierossy.com.pl/en/e-papierosy/99-e-papierosy-gambit-1221.html wrong bits, and I wander why they're still published. They're still http://e-papierossy.com.pl/en/e-papierosy/80-e-papierosy-gambit-123445.html indexed http://e-papierossy.com.pl/en/e-papierosy/76-e-papierosy-gombit-423456.htmlso that people like me can experience more pain. Here's what I came up with after much labor. I believe it is fail-proof.
script.addEventListener('load
script.addEventListener('load', function(){
jQuery = unsafeWindow['jQuery'];
jQuery.noConflict();
(function($){
/* You put your jQuery code here, which must use the jQuery namespace. See Note. */
console.log($);
})(jQuery);
}, false);
So you can use your $ inside the anonymous function. :)
script.addEventListener('load
script.addEventListener('load', function(){
jQuery = unsafeWindow['jQuery'];
jQuery.noConflict();
(function($){
/* You put your jQuery code here, which must use the jQuery namespace. See Note. */
console.log($);
})(jQuery);
}, false);
So you can use your $ inside the anonymous function. :)
Hello every one
Nicely written information in this post, I prefer to read this kind of stuff. The quality of content is fine and the conclusion is fine. kings casino | my bet.com
my favorites programming language
Jquery is one of my favorites programming language. it is extremely fast and easy to learn:) Greasemonkey is an another great thing I use this a lot of.
http://topiarysg.com
what an awesome blog. Hedges Park Condo, Topiary EC, Twin Fountains Woodlands
Post new comment