Hi All
   This has problably been asked before.  But here goes.  OH and YES I have 
serched for a solution or a reason but nothing has popped up.

   I'd like to open a window (that runs another greasemonkey script) and 
monitor how long it stays open.  The other window somtimes crashes so I'd 
like to reopen it if that happens.

   Here is a little test script I wrote to try and find a solution.
   I think it maybe variable (loss of) scope..THUS the global "win" varable.
   I see both the open and close window messages so I know the script is 
running and the "interval"s are working.

    I'm using the latest Firefox adn greasemonkey.

   I think this is my 3rd or 4th attemtp to do this. please help.

// ==UserScript==
// @name     test of window open/close
// @version  1
// @include             https://www.google.com.au/*
// @grant    none
// ==/UserScript==

var FREQUENCY = 10000; //10 seconds

var myPageTimeOut;
var win;
var timerVar    = setInterval (function() {TestWindowOpen (); }, FREQUENCY);
var timerVar2    = setInterval (function() {TestWindowClose (); }, FREQUENCY
+1000);
//clearInterval(timerVar);

function TestWindowOpen ()
{
  clearInterval(timerVar);
  console.log("open window");
  win = window.open("https://www.w3schools.com";); 
}

function TestWindowClose ()
{
  clearInterval(timerVar2);
  console.log("Close window");
    win.close();   // Closes the new window
}
Enter code here...

 

-- 
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to greasemonkey-users+unsubscr...@googlegroups.com.
To post to this group, send email to greasemonkey-users@googlegroups.com.
Visit this group at https://groups.google.com/group/greasemonkey-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to