I’m trying to make a script that adds a chat to a webpage. I’m running the chat through a node.js server with socket.IO.
The chat works, but my problem is:
On reload or when I change a page the old connection(session) and data are lost and the script starts fresh on the new page.
This takes time to set the connection up and transfer past data(chat log) each time a new page is opened.
I was wondering if it is possible to keep the connection and data between reloads (page changes). In other words to keep the chat “unaffected” when the page changes.
Without seeing details, we can only answer in general terms.
So, yes, Greasemonkey can preserve sessions.
Use cookies to preserve session state with your server. Note that
GM_xmlhttpRequest()sends the same cookies that a normal Firefox request would.Rather than fetch the chat history from the server, you can keep it on the local drive using
localStorage.