[Greasemonkey] Need help fixing a script for GM 0.5

Blake West blakewest at gmail.com
Thu Aug 11 10:32:00 EDT 2005


> Instead of creating a new property on Window.prototype ("_close"), try
> storing the original close method in a script-level global variable.
> 
> var old_close = Window.prototype.close;
> Window.prototype.close = funload;
> 
> ...
> 
> function funload() {
> ...
> if (some condition) {
>   old_close();
> }
> }
> 

Didn't work...

I tried something else to diagnose the problem, and it looks like the
GM script executes after the JS code in the page that closes the
window. The reason for this may be the wretched markup sent to my
innocent browser by Microsoft. Check this out (note that the <head>
element does not get closed:

<script language="Javascript">

function openNewWindow(fileName,windowName,theWidth,theHeight) {
	if (windowName == "newMessageWindow") 
	{
		//generate random window ID

		 windowName = new String(Math.round(Math.random() * 100000));

	}
	window.open(fileName,windowName,"toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width="+theWidth+",height="+theHeight)
}

</script>


<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<script language='javascript'>
    var holdMinutes=5;
    var holdMs=60000 * holdMinutes; //5 min we could get the current
session timeout if we felt like it?
    var L_SessionHasTimedOut_Message = "Your session under this
message has timed out.  You may use this window only to copy any
unsaved work you may have.";

    function holdSession() {
      setTimeout("self.location='commands.asp?command=holding'",holdMs);
    }



function LaunchForm(szFormPath) {
 
  openNewWindow(szFormPath +
"?command=new&obj=79343",'newMessageWindow',640,500);
  parent.close();
}


</script>
<TITLE>Commands</TITLE>
<body text=000000 onLoad="LaunchForm('frmRoot.asp')">
</body>
</HTML>


More information about the Greasemonkey mailing list