A page I use a lot has a mildly useless timeout feature, such that after one hour it will automatically log the user out. I'm trying to write an extension for chrome that would extend this timeout period to ten hours, however as I have never written an extension before I'm running into problems. I know content scripts cannot influence page variables directly, however I have been trying to use Method 2 on this page which I haven't been able to get to work.
The code in the website for the timeout is basic:
var x = 3600
var y = 1;
var z = 300
x = x-y
setTimeout("startClock()", 1000)
function startClock(){
x = x-y
setTimeout("startClock()", 1000)
if(x==z){
alert("Your Session is about to expire. After a period of inactivity (60 minutes), all current session information is removed and you will be required to log in again.");
} else if (x==0) {
document.location.href = "content?module=home&page=homepg&logoutFinal=1";
}
I wrote a basic manifest file for the extension that uses content_scripts
to call contentscript.js
, which is virtually the same as what was given in the Method 2 example.
var actualCode = ['var x = 36000'].join('\n');
var script = document.createElement('script');
script.textContent = actualCode;
(document.head||document.documentElement).appendChild(script);
script.parentNode.removeChild(script);
My current desire is to have an extension that automatically resets the value of x to 36000 seconds, or 10 hours upon the page refresh.