When I try to load a GM script that makes use of jQuery, it does not work
when the page it is being used on makes use of an older version of jQuery it
has in the code already. For instance, stores running Magento will have a
problem with their login button not working.
I've tried no conflict and it doesn't work.
None-the-less, I still get a "$ is not a function" error on those pages.
I've tried renaming everything in the jQuery library from jQuery to gmQuery
and $ to $gm before including it. This results in the GM code not working at
all but the web page functions as normal.
Any idea how to eliminate this conflict?
My code with the gmQuery mod:
var $gm;
// Add jQuery
(function(){
if (typeof unsafeWindow.gmQuery == 'undefined') {
var GM_Head = document.getElementsByTagName('head')[0] ||
document.documentElement,
GM_JQ = document.createElement('script');
GM_JQ.src = 'http://notarealdomain.com/js/gm/jquery-1.6-gm.js';
GM_JQ.type = 'text/javascript';
GM_JQ.async = true;
GM_Head.insertBefore(GM_JQ, GM_Head.firstChild);
}
GM_wait();
})();
// Check if jQuery's loaded
function GM_wait() {
if (typeof unsafeWindow.gmQuery == 'undefined') {
window.setTimeout(GM_wait, 100);
} else {
$gm = unsafeWindow.gmQuery.noConflict(true);
letsJQuery();
}
}
// All your GM code must be inside this function
function letsJQuery() {
alert($gm); // check if the dollar (jquery) function works
alert($gm().jquery); // check jQuery version
}
--
View this message in context:
http://old.nabble.com/jQuery-conflicts-when-page-has-older-version-of-jQuery-tp32323879p32323879.html
Sent from the GreaseMonkey List mailing list archive at Nabble.com.
--
You received this message because you are subscribed to the Google Groups
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/greasemonkey-users?hl=en.