I'm working on a Chrome extension. I'm injecting a script into pages, and injecting jquery as well to be usable in my script.
I added another extension named Boomerang, and since then, jquery is not defined. What I tried so far :
myJquery = jQuery.noConflict();
Sometimes works, sometimes doesn't. If I check for myJquery
in the console it sometimes exists, sometimes it's undefined - so is $
or JQuery
. Race condition ?
jQuery.noConflict();
in a function waiting for all my assets to be injected (with a `setInterval to check until I find them) works the same - sometimes yes sometimes no.
I'm a little out of ideas. It seems Boomerang is the root of the problem, but if it occured here it could occur with other extensions as well. Is there a way I'm unaware of defining my functions into their own namespace or something like that ?
[EDIT] I decompiled Boomerang's code and found out they're using exactly the same stack as me : Gmail.js and Jquery. Here is in their code what I believe to be faulty here :
function h() {
V = String(document.location);
"undefined" === typeof window.jQuery && 0 > V.indexOf("ContactManager") ? Eb =
setTimeout(h, 500) : (a = ia = window.jQuery.noConflict(!0), window.b4g.$ = a, setTimeout(Lc, 0), setTimeout(z, 0))
}
I don't really understand the meaning of this window.jQuery.noConflict(!0)
but it doesn't look good...