Submit a form in the background automatically - google-chrome-extension

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?

Related

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.

Is it possible to prompt user with simple html/css from nodejs and return data on submission?

One way is to start whole server open local host page and wait for response. but I was wondering it's possible to create simple popup and read input and send input etc.
Scenario: a web scraper that backs up hacker news comments, you put credentials, it logs in, scrape, and save it. All of this happens locally. Nothing online. Nothing public. Right now user would have to input stuff inside terminal/cmd which is not great experience for non devs.
Or lets say there is some node script that needs human input, quick to categorize data. you type node app.js it runs, opens a popup, you select settings, click next, next.. finally submit.. data gets returned to node script.

How to reload a webpage without the user noticing?

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.

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?

Whats the standard way to detect the window close event in the browser?

Whats the standard way to detect the browser window close event in any standard browser? By standard I mean something that sites like Google or Facebook implement when the "keep me signed in" checkbox is unchecked. I have an interactive website in place where theres an Instant Messaging module and I need to inform the other user that the partner has logged out.
Thanks in advance.
The keep me signed in links are managed via cookies and cookie timeout lengths.
One approach to doing something like this is to have the browser make an async ajax call every (1 minute) to your server so you know they are still logged in. If you dont receive one of these calls within say 90 seconds you can say they are logged out.
This approach would also catch cases where for example their connection went or their computer crashed.

Resources