Skip to content

Instantly share code, notes, and snippets.

@splintor
Last active July 5, 2022 14:10
Show Gist options
  • Save splintor/c56f9ba873ce14d2efc1b6238993de8d to your computer and use it in GitHub Desktop.
Save splintor/c56f9ba873ce14d2efc1b6238993de8d to your computer and use it in GitHub Desktop.
WhatsApp - restore focus to search box
// ==UserScript==
// @name WhatsApp - restore focus to search box
// @namespace https://splintor.github.io/
// @version 0.2
// @description When user clears search box, focus moves to the first entry in the list. It's annoying!
// @author Shmulik Flint
// @match https://web.whatsapp.com/
// @icon https://www.google.com/s2/favicons?sz=64&domain=whatsapp.com
// @downloadURL https://gist.githubusercontent.com/splintor/c56f9ba873ce14d2efc1b6238993de8d/raw
// @updateURL https://gist.githubusercontent.com/splintor/c56f9ba873ce14d2efc1b6238993de8d/raw
// @grant none
// ==/UserScript==
(function() {
'use strict';
document.body.addEventListener('keydown', e => {
if (e.target.classList.contains('selectable-text')) {
setTimeout(() => e.target.focus(), 100);
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment