Some banking and financial sites auto logs out when it thinks you are idle. Is there a way for me to inject a script into the page that can fake that I am not idle?
I tried this: setInterval(() => document.body.click(), 1000 * 60 * 5) // Click every 5 minutes
but it did not work and I still got logged out:
Again, this is not intended for any malicious purpose - I monitor my stock positions on Fidelity by keeping my stock positions screen open in one monitor while I do my work on the other monitor but Fidelity keeps showing an idle warning and logs me out every 30 minutes.
Note, in this particular case, the site is listening to click
, touchstart
, keydown
and scroll
events as well document.visibilityState
:
Some notes:
I cannot simply refresh the page every x minutes because the page has some UI state (e.g. sort order of my positions in a table) that would get lost
I tried a dumb
pyautogui
script that moves my mouse and clicks on the page and that works! So why cannot I do this in chrome?
click
? That's not a built-in browser method, and you only have it defined later down in a different closure. Have you tried inspecting your browser extension and checking the console for errors? – Barimahdocument.body.click()
– Palladiumdocument.body.click()
to see if it reaches that line of code you screenshotted? Then there's always the "dumb" option of refreshing the page or navigating back and forth every so often. – Barimahdocument.body.dispatchEvent(new Event('click', {bubbles: true}))
and I also put a console.log to verify its getting triggered: github.com/pathikrit/chrome_ai/commit/… Still does not work – Palladiumexample.com?_my-reload-extension=TIMESTAMP
or something similar. – Barimahwindow.location.reload()
but this won't work since I would lose state - in this particular case I have my stock positions open sorted by the percent change column. If I refresh the page, it loses that UI state. There must be a way to fake a user presence event no? – Palladiumwindow.addEventListener('click')
and you are triggeringdocument.body.click()
every so often, that should be enough. Your results are telling me there's something else at play. Without looking at Fidelity's code, I can't say why what you're trying isn't working. (Are they using the page visibility API? Are they looking for more than just a click? Mouse move? You'll have to debug this further.) – Barimahdocument.body.click()
does indeed trigger Fidelity'sexpandOrRenewSession
method by setting a breakpoint. Set a timer for 35 minutes, minimized Chrome, ran your snippet (setInterval(() => document.body.click(), 1000 * 60 * 5)
), and sure enough, when I returned I was logged out. Two hunches: (1) Fidelity watches to see if the window gets blurred, or (2) the browser is putting the tab to sleep. Or this method is a total red herring. – Barimahdocument.visibiliyState === 'visible'
– Palladium