2

At our job we're using a communication portal that logs out after a while. Some of my co-workers asked me for a javascript, that disables the autologout. All i could achieve was to reset the displayes timer, but the timer itself keeps running anyway. Here is how the timer is started:

<body class='asam_body' onLoad='window.setTimeout("DsplTime()",1);' >

As you can see, setTimeout is called at onLoad, but there is no reference to the setTimeout-call, so i can't use the clearTimeout() function. I've also tried to call DsplTime() out of my script, but that still doesn't stop the timer. Everything i found doesn't apply to my case, so i gave up my search after two hours. Is there any way to influence this serverside body-definition, e.g. by

  • overriding the onLoad (tried with @document-start)
  • replacing the string for the definition of the body itself (i guess because the server delivers that, its to late for my script to inject, when the line is there)
  • getting a reference to the setTiming-Object retroactively

Here's my rather useless approach, that only resets the displayed time:

 setInterval(CalcTime, 130000);
 setInterval(resetStart, 130000);
 setInterval(DsplTime, 130000);
//resetStart and CalcTime are prefined functions,
// without any impact on the timer itself, unfortunately

Thanks in advance!

P.S.: thats the first time i asked something on stackoverflow, so i hope, i asked appropiately:)

Edit:

I tried the brute force approach from Cancel all Javascript's setTimeouts and setIntervals, with

for (var i = 1; i < 99999; i++) {
        window.clearInterval(i);
        window.clearTimeout(i);
        window.mozCancelAnimationFrame(i); // Firefox
    }

But still i'm logged out after the same amount of time.

This codesnipped leads to the logout after 1440 minutes:

if (absSec >= 1440)
{
    document.location.href = "../project/auth/logout.php";
}

This is part of the function DsplTime() metioned above. Is there any way of manipulating this function, instead of preventing it's call? absSec is out of scope, so i can't change it's value (and i think this wouldn't help anyway?

Edit 2:

So i could manage to stop the timer by

// @run-at document-start
//...
var highestTimeoutId = setTimeout(";");
    for (var i = 0 ; i < highestTimeoutId ; i++) {
        window.clearTimeout(i);
       // window.alert(i);
    }

Unfortunately, the script only works every now and then (in like 80% of the pageloading). Plus, isn't this generating a lot of load for the server? I don't want to be blocked...

snjlscmi
  • 21
  • 3
  • What's adding the JavaScript to the onLoad attribute? Can you not remove this? – pathurs Jan 17 '18 at 07:39
  • 1
    if you doesnt have any other setinterval or timeout then you can use, https://stackoverflow.com/questions/11374131/cancel-all-javascripts-settimeouts-and-setintervals – Aswin Ramesh Jan 17 '18 at 07:42
  • 1
    Possible duplicate of [Cancel all Javascript's setTimeouts and setIntervals](https://stackoverflow.com/questions/11374131/cancel-all-javascripts-settimeouts-and-setintervals) – Bourbia Brahim Jan 17 '18 at 07:46
  • Its unclear what the timer is, do you have the code for the timer? – surajck Jan 17 '18 at 07:50
  • By timer i mean the window.setTimoute call, that leads to the logout finally. Or do you mean the DsplTime() code? – snjlscmi Jan 17 '18 at 07:54
  • As two commenters have already stated, it is possible to stop the `setTimeout` assuming that you can run JavaScript before the onLoad attribute is fired. If you cannot achieve this then you are most likely out of luck. – pathurs Jan 17 '18 at 08:07
  • That call gets called in 1ms, there is not much you can do. Even if you get a handle to the setTimeout, it'll be too late to cancel it. Try to find another point of weakness which you can exploit – surajck Jan 17 '18 at 08:19

1 Answers1

0

Why not just override the javascript function DsplTime() so that it doesn't log you out?

go to the debug console and type something like DsplTime = new function(){}

when the interval is up and DsplTime(), the function will do nothing.

charley
  • 124
  • 1
  • 5
  • I thought of that. But isn't the problem, that this override would be too late, because DsplTime() is already called onLoad? So i could only override a theoretical second call, or am i wrong here? – snjlscmi Jan 17 '18 at 16:19
  • Well, either the server is logging you out server side (in which case, no amount of client side javascript will get around it) or DsplTime() is logging you out. you can check by looking at the definition of DsplTime, or doing something like alert(DsplTime) to see the function definition, if you can't find it elsewhere. – charley Mar 01 '19 at 19:33