My Script To Refresh and Stay Alive

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

// ==UserScript==

// @name Auto Refresh Website without Navigation or Logout


// @description Automatically refreshes the website every 30 seconds and prevents
navigation/logout
// @version 1.0
// @match https://algeria.blsspainvisa.com/*
// @grant none
// ==/UserScript==

(function() {
'use strict';

// Save the current session ID


var sessionID = '';

// Save the current URL


var currentURL = window.location.href;

// Get the session ID from the cookie


function getSessionID() {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
if (cookie.startsWith('PHPSESSID=')) {
sessionID = cookie;
break;
}
}
}

// Auto refresh every 30 seconds


setInterval(function() {
// Get the session ID if it hasn't been obtained yet
if (sessionID === '') {
getSessionID();
}

// Restore the session ID


document.cookie = sessionID;

// Check if the current URL has changed


if (window.location.href !== currentURL) {
// Redirect back to the original page
window.location.href = currentURL;
} else {
// Refresh the page
location.reload();
}
}, 30000);
})();

You might also like