Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create a bookmark and place the code below in the "url" value. Please note that you should change the values of "sessiontimeout" and "checkinterval". They're both in milliseconds.</p> <pre><code>javascript:(function(){var lastmove = new Date().valueOf(),sessiontimeout=10000,checkinterval=1000;document.onmousemove = function(e){lastmove= new Date().valueOf();};timer = setInterval( function() {var differential = (new Date().valueOf() - lastmove);if (differential &gt; sessiontimeout) {var iframe = document.getElementById("bkmrkiframerefresher");if (iframe) { document.getElementsByTagName("body")[0].removeChild(iframe);} iframe = document.createElement("iframe");iframe.setAttribute("src", "/");iframe.setAttribute("width", 0);iframe.setAttribute("height", 0);iframe.setAttribute("style", "width:0;height:0;display:none;");iframe.setAttribute("id", "bkmrkiframerefresher");document.getElementsByTagName("body")[0].appendChild(iframe);lastmove = new Date().valueOf();} }, checkinterval);})(); </code></pre> <p>This is a bookmarklet that will inject the code below in the page. I tested the bookmarklet in Chrome. It worked on multiple sites except stackoverflow, it seems that they block framing for security reasons. <strong>Before you leave your desk, open the website which session you wanna keep alive, then click the bookmarklet on it.</strong> Once you're back, refresh the page in order to get rid of the running timers.</p> <p>The formatted (and commented) code is:</p> <pre><code>&lt;script type="text/javascript"&gt; // last time the mouse moved var lastmove = new Date().valueOf(); var sessiontimeout=10000; var checkinterval=1000; // reset the last time the mouse moved document.onmousemove = function(e){ lastmove= new Date().valueOf(); } // check periodically for timeout timer = setInterval( function() { var differential = (new Date().valueOf() - lastmove); if (differential &gt; sessiontimeout) { var iframe = document.getElementById("bkmrkiframerefresher"); // iframe already exists, remove it before loading it back if (iframe) { document.getElementsByTagName("body")[0].removeChild(iframe); } // alert("more than 10 secs elapsed " + differential); // create an iframe and set its src to the website's root iframe = document.createElement("iframe"); iframe.setAttribute("src", "/"); iframe.setAttribute("width", 0); iframe.setAttribute("height", 0); iframe.setAttribute("id", "bkmrkiframerefresher"); iframe.setAttribute("style", "width:0;height:0;display:none;"); document.getElementsByTagName("body")[0].appendChild(iframe); // reset counter. lastmove = new Date().valueOf(); } }, checkinterval); &lt;/script&gt; </code></pre> <p>Stefan suggested above that you need no logic besides polling. The edited code is the following:</p> <pre><code>&lt;script type="text/javascript"&gt; var pollInterval=1000; timer = setInterval( function() { var iframe = document.getElementById("bkmrkiframerefresher"); // iframe already exists, remove it before loading it back if (iframe) { document.getElementsByTagName("body")[0].removeChild(iframe); } // create an iframe and set its src to the website's root iframe = document.createElement("iframe"); iframe.setAttribute("src", "/"); iframe.setAttribute("width", 0); iframe.setAttribute("height", 0); iframe.setAttribute("id", "bkmrkiframerefresher"); iframe.setAttribute("style", "width:0;height:0;display:none;"); document.getElementsByTagName("body")[0].appendChild(iframe); } }, pollInterval); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload