0

I use a site run by my company that has a session timer. Any interaction with the server resets it, or it can be manually triggered. I multitask a lot and keep getting signed out, losing my progress, so I need a solution.

Initially I tried inserting a JavaScript function via a Chrome extension (e.g. Injector) to just automatically reset the timer. That worked great, but obviously there are security issues with doing it automatically.

What I want is something that, after a certain amount of time of not interacting with the site, will alert me either by sound or visually (something focus-grabbing and not merely on that tab). I've tried using extensions that throw up an alarm every n minutes, but that only works if I remember to reset it after my last interaction on that page. So I'm wondering, is there some JavaScript that I can put in the code injector extension that will flash my screen or make noise after so many minutes of not interacting? Is there already an extension existing that can handle such things that I just can't find?

Dogulas
  • 45
  • 1
  • 8
  • `obviously there are security issues with doing it automatically` Assuming you're not leaving your PC unattended and unlocked, I'm not sure what security issues this causes. – DBS Apr 01 '19 at 15:21
  • They aren't afraid of the right things we try to do, but the ones we might at some point forget to do. – Dogulas Apr 01 '19 at 16:01

1 Answers1

1

The Injector plugin will work so long that you don't need to access any specific chrome API because the injected script only has access to a subset of the chrome API.

I do not have a complete solution but I hope the following will help you somehow, here is how I would go about this:

create a browserAction extension.

set the permission in Manifest.json
"*://*/*" will allows javascript to be injected in any pages

  "permissions": [
     "tabs",
     "*://*/*" 
   ],

in popup.js

  • have an injector button that will make a call to your background to start the timer for the current tab
  • onClick -> sendMessage to background - 'StartTimer' and the current tabId

in background.js

  • listen for 'StartTimer' message from popup
  • start a recursive timer (setTimeout)
  • every X minutes:
    • query the tab instance by the tabId
    • check url match what you are expecting.
      • highlight that tab
      • bring that window forward
      • inject some css opacity effect to the body
      • play a sound()

I hope this helps :)a

MimiEAM
  • 2,505
  • 1
  • 26
  • 28