In the web application where I work, users are automatically logged out after a period of inactivity. Unfortunately, I am unable to control this feature. The code responsible for logging the user out is as follows:
var windoc = window.document;
var timeoutID;
function AlertUser() {
var msg = 'Session expires in 90 seconds. Continue with this session?';
var preConfirmTime = new Date();
if (confirm(msg)) {
var postConfirmTime = new Date();
if (postConfirmTime.getTime() - preConfirmTime.getTime() > 90000) {
alert('Sorry, your session has already expired.');
window.location = '/Logout.aspx';
} else {
var img = new Image(1,1);
img.src = '/Reconnect.aspx';
timeoutID = window.setTimeout('AlertUser()','3510000');
}
} else {
window.location = '/Logout.aspx';
}
}
function ResetTimeout(delay) {
window.clearTimeout(timeoutID);
timeoutID = window.setTimeout('AlertUser()', delay);
}
timeoutID = window.setTimeout('AlertUser()','3510000');
Considering that these sudden logouts disrupt my workflow, I am interested in creating a bookmarklet that will automatically click `OK` when the session is about to expire. My initial idea was to use the following script:
javascript:window.confirm = function(){return true;};
However, this script only runs upon clicking the bookmarklet. Is there a way to make it automatically execute in the active browser tab (especially on IE 10), such as continuously checking for session expiration even when opening a new tab without the need for installing browser extensions? Please note that my primary method of interacting with webpages is through bookmarklets.