Timer var - - is INLINE Javascript modifiable via Tampermonkey?

Script exchange and development requests
Post Reply
Rexie
Posts: 1
Joined: 20.01.18 21:48:35

Timer var - - is INLINE Javascript modifiable via Tampermonkey?

Post by Rexie » 21.01.18 02:55:22

I am on a website which requires users to spend a long time on each page.
I have the following code INLINE javascript in the HEAD of the page:

<!-- COUNTDOWN TIMER -->
<script language=JavaScript type=text/javascript>
<!--
var sec=96;
function countDown() {sec--;time=sec+' sec ';
if (document.getElementById){document.getElementById('Timer').innerHTML=time; } SD=window.setTimeout('countDown();', 1000);
if ( sec == 00) { sec = 00; window.clearTimeout(SD); }} window.onload = countDown;
// -->
</script>

I have tried setting the var to 1.

I have tried this function via Tampermonkey:

const oldTimeout = window.setTimeout;
window.setTimeout = function(cb, time) {
'use strict';
if (cb === 'countDown();') {
time = 0;
}
return oldTimeout(cb, time);
};

Is the issue that INLINE Javascript cannot be modified with Tampermonkey?
Is the issue that I need to have special code to inject into this webpage somehow?
I want to get around the timer or at least have the timer be less than ten seconds so I can move to the next page quickly.
I am just getting started with Tampermonkey and want to make sure it is the right tool for the job.
Thanks in advance,
Rexie

User avatar
derjanb
Site Admin
Posts: 2368
Joined: 20.01.06 02:16:15
Contact:

Re: Timer var - - is INLINE Javascript modifiable via Tampermonkey?

Post by derjanb » 15.02.18 21:09:54

Please overwrite unsafeWindow.setTimeout.

If this doesn't work you may have to set "Inject Mode" to "Instant" to make it work (-> change "Config Mode" to "Advanced" first).
ImageIf you like what I'm doing, please consider a donation here. Image

Post Reply