0

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.

Community
  • 1
  • 1
Jace230
  • 11
  • 2
  • See @SeanDowney 's answer in http://stackoverflow.com/questions/3847121/how-can-i-disable-all-settimeout-events . The solution is to clear all timeouts as you don't have a handle of the page timeouts and changing `x` might not work because the timeout will most probably be started already as soon as your script runs – devnull69 Aug 20 '14 at 04:59

1 Answers1

0

After troubleshooting for some time, I discovered that the entire problem was an issue in the manifest.json, specifically the matches section. The code given above works, and so do the methods given in the document that I linked to.

Thanks to devnull69 for the quick response, I attempted that method and after solving the problem in manifest.json, it worked to remove the timeout entirely.

Jace230
  • 11
  • 2