Skip to content

Commit 7bc0551

Browse files
committed
WhatsApp: Stop WhatsApp from forcing focus into the message list when switching away from the browser tab.
1 parent 5e6f779 commit 7bc0551

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

WhatsAppA11yFixes.user.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// @author James Teh <jamie@jantrid.net>
66
// @copyright 2019-2025 Mozilla Corporation, Derek Riemer, James Teh
77
// @license Mozilla Public License version 2.0
8-
// @version 2025.1
8+
// @version 2025.2
99
// @include https://web.whatsapp.com/
1010
// ==/UserScript==
1111

@@ -254,6 +254,15 @@ function userInit(){
254254
button.click();
255255
}
256256
}, { capture: true });
257+
document.addEventListener("focusout", event => {
258+
// When the tab loses focus, WhatsApp forces focus into the message list,
259+
// regardless of where it was before. Override that absurdity.
260+
setTimeout(() => {
261+
if (!document.hasFocus() && document.activeElement != event.target) {
262+
event.target.focus();
263+
}
264+
}, 50);
265+
});
257266
}
258267

259268
/*** Lights, camera, action! ***/

0 commit comments

Comments
 (0)