How to reload a webpage without the user noticing? - greasemonkey

There is a video streaming webpage that stops playing after X minutes.
To resolve this, we have to reload the webpage with "F5" button.
But: is there any very short, ex.: greasmonkey script that can reload the page in ex.: every 5 minutes, without the user noticing?
The purpose is to send a "hello" to the server that we are still alive, so thinking of to open a tab in background then close the opened tab, without the user really noticing, but don't touch the page that has the focus, that is currently playing the video.

Related

Web browser automation loop and stop (+notification) when some phrase is no more displayed on the page

I'd like to take an appointment on a website, but it keeps showing me that "there is no more places for appointments".
So i would like to run some kind of chrome extension as so:
Connect to a web adress
check some boxes, click on a button
On the next page if the phrase "there is no more places..." is not displayed on the page, that would mean some kind of form is displayed for appointment.
The script stops and send me a notification, if nothing changed then restart from (1) after let's say 5mins.
Any solution for that purpose?

Checking other users are viewing this page in Node Express

I have a NodeJs Express app and when a particular user goes to a page/route would like to identify and display if another user is currently viewing the page as well. So for example it would say "Jerry currently viewing this page" and someone else goes there.
Is there any easy/lightweight way to do this?
First off, with a regular web page, the server only knows who and when a page was requested. It doesn't, all by itself, know whether that user is still viewing that page or not. The user could have closed the browser, typed something else in the URL bar, the computer could have gone to sleep, etc...
Second off, even if the page is still being displayed in the browser, you can't know if someone is actually there at the computer or not. The best you could do is to try to keep track of activity in that web page (last mouse click, recent mouse movements over the web page, etc...).
Then, to even have any idea of the web page is even still open in the browser, you need some way of tracking that notion. There are two possibilities I can think of.
You can have some Javascript in the web page that regularly (say once every few minutes) sends a small little ajax call to your server that basically just says "I'm still here". This wouldn't know immediately when they left the page, but if the server finds that the usual every few minutes ajax call didn't come, then the server can change the status of that user on that page to not there any more.
If that web page makes a webSocket or socket.io connection to the server and keeps that connection alive, then whenever the browser closes or the user closed that tab or navigates to another page, that webSocket or socket.io connection will get automatically closed and the server will be notified that the socket got closed. Using this technique, the server can know pretty much right away when the user leaves the page.

Background Page Doesn't Show as Active User

I added Google Analytics to a Chrome Extension. It is reporting events correctly as well as recording popup page views. When the extension is reloaded it correctly records a view of background.html which I explicitly call.
Problem: Despite the extension having a persistent background.html page, "Active Users" in the Real-Time section of GA shows 0. I would like to be able to see the # of concurrent users of the extension at a given time. Is there a way to do it?
Possible Solution? - When I open the popup it displays an active user for some number of minutes before dropping back down to zero. Do I need to create a heartbeat function of some kind that pings GA every X minutes to keep a user active. It seems a big "chatty" to do that.
Is there a better solution?

Submit a form in the background automatically

I want to create a Google Chrome extension that runs constantly in the background, even when Chrome windows are closed - this is what a Background Page is for, correct? Or should I be looking at something else?
Basically what I wish to do is have a setTimeout() load a page every 5 minutes and if its presented with a login page, automatically logs in with a given username and password, otherwise it does nothing.
This is simply to keep the session alive...
Is this possible to do?

Browser navigation, back button issue

I want to know how you guys deal with back button issues in your web applications.
I can not forbid users to click back button on their browser, but when they hit it, the page code doesn't run. So writing in page_load() makes no sense.
I have searched online and found this link: Disabling Back button on the browser. It does not work for me. Any idea?
There is no way to disable the back button. You can try to open your page/form in a new window so there would be nothing to navigate back to
Normally, If I have a critical or lengthy form, I tend to maintain a dirty-flag and if the user starts entering something, the dirty-flag gets set and on save or submit it gets reset. You can use unload/beforeunload javascript event to see if the dirty-flag is set and ask for confirmation.

Resources