views:

251

answers:

2

My employer is blocking the Google CDN domain that provides the jQuery file to so many websites:

http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js

I want to use GreaseMonkey to provide that jQuery reference from a different domain. Is this possible? Can I use a GreaseMonkey script to tell a page to load it's jQuery reference from this URL instead?:

http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js
+1  A: 

You could have GreaseMonkey add it's own javascript reference, but the problem will likely be that your jQuery code will have already run before jQuery is loaded. Is it possible to call the jQuery code after your GreaseMonkey script loads jQuery again? It seems that you'd have to restart execution of the jQuery code on the page in order for this to get the results you're looking for.

spig
Good point. The affected page will just be throwing "`$` is undefined" errors left and right before any greasemonkey script has a chance to fix the situation.
Crescent Fresh
A: 

Greasemonkey acts when the DOM has already loaded. You can try to rewrite the code before it gets rendered with a full fledged browser extension. Look into LiveHttpHeaders. I think it may be useful because it intercepts the page before getting to the browser. Based on that, you can then rewrite the source to suit your needs

Victor