[Greasemonkey] replacing a script with my own
jjazz
jvasile at gmail.com
Wed Sep 13 04:59:27 EDT 2006
I frequent a website that loads a script in the head section with
<script type="text/javascript" src="review.js"></script>
I would like Greasemonkey to get in there and replace review.js with another
url-- i.e. one that points to my customized version. I am having trouble
getting in there and making the change. I am doing the following, which
does changes the src of the script tag, but doesn't affect the operation of
the site.
var allScripts = document.evaluate( '//script[@src]', document, null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < allScripts.snapshotLength; i++) {
var thisScript = allScripts.snapshotItem(i);
if (thisScript.src == 'http://url.of.site/review.js') {
thisScript.src = 'http://url.to.my.version/newscript.js';
}
}
I feel like I've missed somethig simple (I have little javascript or DOM
experience). Any hints would be most appreciated.
Thanks.
--
View this message in context: http://www.nabble.com/replacing-a-script-with-my-own-tf2264406.html#a6283229
Sent from the MozDev - greasemonkey forum at Nabble.com.
More information about the Greasemonkey
mailing list