Skip to main content

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();

 

Nice one @Dirkjan, this is great. 

We’ve considered doing this across our group. I’ll be looking to see if we can implement it by way of group policy. 

Thank you for sharing!


Thank you Dirkjan, such amazing recommendations are exactly why we started our community. Really love how you solved this challenge. 


This is such an awesome solution, Dirkjan! 🤩 Thank you so much for sharing it with the community. 
 
Would you mind terribly if our Mews Support Team documented your recommendation in our public help center? We would, of course, give you all the credit for your hard work! 💪🏽


@wendy.batkova No problem at all. 
Would be even better if you implemented it directly into Mews. It would take me literally less than 5 minutes. 🤷🏻

I have a ton of small improvements that I could implement within a day if I could get into the room with one of the developers. 

  1. Sortable tables 
  2. auto export to PDF, plain email or print
  3. showing ‘confirmed’ availability blocks in the timeline
  4. Be able to set a total price including products etc. 

Hey @Dirkjan Thanks for the input. 💚 We’re always striving to make Mews the best it can be and we have more exciting features in the pipeline. I can see you’ve voted on these improvements that you’ve mentioned in our Feature Request site so stay tuned for updates from the product team. 
We’re working on introducing more community-led product discussions too so when we plan to have the next one, I’ll be sure to let you know. 


Hi there! Great script and great idea, ideed!
There might have been an update in the meantime, so the script above does not work for me any more, because the DOM identifier of the lock session element has changed.
However, it’s easy to amend, just
replace

setTimeout(() => document.querySelector('(value="Lock Account"]').click(), 100);

with

setTimeout(() => document.querySelector('(data-test-textkey="LockSession"]').click(), 100);

:-)

BTW: in Firefox the https://addons.mozilla.org/en-US/firefox/addon/violentmonkey add-on is available, for example, but it’s a beta-version, so take care ;-)


Hello everybody!

Short update - we are using the tampermonkey browser extension to install the user script. This extension is available accross all browsers.

For the script (see above) we are using the following header:

// ==UserScript==
// @name Lock Session in mews.com
// @match https://app.mews.com/Commander/*
// @grant none
// @version 1.0
// @author -
// @description 20.1.2024, 23:15:48
// @require https://cdn.jsdelivr.net/npm/[email protected]/HackTimer.min.js
// ==/UserScript==

It also loads (@require …. ) the external module HackTimer (https://github.com/turuslan/HackTimer ), which should allow the timer to run also in backgrounded browser tabs. I have not verified that third party module - so use at your own risk and evaluation - but it looks to be rather simple and harmless to me.

Regards,

JP.


For all thos using Chrome - look at the following post by a mews employee (@CharlieDelamare) who made a custom chrom extension that solves that very elegantly.

 


Reply