Hi everyone,
We have a reception desk with 2 computers and multiple people who use them and nobody was logging out of their mews account, so the first person who logged into mews that morning had every action on their name. What I did is create a code that loges out every x minutes and adds a keyboard shortcut Ctrl + L
I thought I could be handy for more smaller hotels who have multiple employees sharing one pc.
You can run it in Google Chrome using a JS extension like: https://chrome.google.com/webstore/detail/run-javascript/lmilalhkkdhfieeienjbiicclobibjao
// Set the desired logout time in minutes
const LogoutMinutes = 15;
// Calculate the logout time in milliseconds (1 minute = 60000 milliseconds)
const LogoutTime = LogoutMinutes * 60000;
// Initialize the timer variable
let timer = null;
// Add an event listener for 'keydown' events
document.addEventListener('keydown', e => {
// Reset the timer on any key press
resetTimer();
// If 'Control' key is held down and the 'l' key is pressed, log out
if (e.ctrlKey && e.key === 'l') {
// Prevent the default behavior of the 'l' key
e.preventDefault();
// Call the logout function
logout();
}
}, false);
// Add an event listener for 'mousemove' events
document.addEventListener('mousemove', () => {
// Reset the timer on any mouse movement
resetTimer();
}, false);
// Define the logout function
function logout() {
// Click the user avatar
const avatar = document.querySelector('ldata-test-id="user-menu-avatar"]');
avatar.click();
// Click the "Lock Account" option after a short delay
setTimeout(() => document.querySelector('lvalue="Lock Account"]').click(), 100);
}
// Define the resetTimer function
function resetTimer(newT = LogoutTime) {
// Clear the existing timer
clearTimeout(timer);
// Set a new timer with the specified timeout
timer = setTimeout(logout, newT);
}
// Call resetTimer to start the initial timer
resetTimer();