Find/Replace on Javascript Greasemonkey Script not working

Hi,

I’m stuck on a javscript file used as a Greasemonkey script to rewrite some content on a web application I use at work.

Previously posted on http://userscripts.org/topics/97508, but posting here as no reply there since that forum seems to be rarely used and is full of spam.

I’m trying to change the size of a pop up window.

The size is defined in a script tag:

<script language="JavaScript">
...
var temp = window.open('/Sostenuto/Chameleon/Templates/EN/memo_popup.htm','Chameleon','width=400,height=350,status=no,resizable=no,scrollbars=yes,top=200,left=200,alwaysRaised=yes');
...
</script>

I have tried this to do the change (there is only one instance of width=400 so it’s not a global replace):

var cells = document.getElementsByTagName('script');
for (var i = 0; i < cells.length; i++) {
		john = cells[i].innerHTML;
		john = john.replace('width=400', 'width=800');
		alert(john);
		cells[i].innerHTML = john;
}

But the replace is not firing.

I have debugged via the “john” alert and can see it contains the text I want to replace, and when I output the value of “john” I can see that it contains width=800. However, the javascript doesn’t seem to recognise it when the pop up window opens. Is it because javascript needs to have the value hard coded in the HTML so it picks it up when the page loads, and won’t handle it being rewritten in the background via the GM script?

Any advice much appreciated.

Thanks

I’ve never worked with Greasemonkey, so maybe I should be shutting my fat mouth, but it looks like you’re basic premise wouldn’t work. You’re trying to grab the script via a DOM method, but change its contents before it runs. However, if the script is accessible via, say, getElementsByTagName, then the browser has already executed the script, hasn’t it?