Last active
December 1, 2022 02:05
-
-
Save mikhailsdv/bd2518c1e1da86fb47e33cb989bea410 to your computer and use it in GitHub Desktop.
Closes dead WhatsApp windows and quickly opens chats by url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name WhatsApp window manager | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description Closes dead WhatsApp windows and quickly opens chats by url | |
// @author mikhailsdv | |
// @match https://*.whatsapp.com/* | |
// @grant window.close | |
// ==/UserScript== | |
(function() { | |
"use strict" | |
const linkToChat = document.querySelector("#fallback_block h4 a[href^='https://web.whatsapp']") | |
if (linkToChat) { | |
setTimeout(() => { | |
location.href = linkToChat.href | |
}, 100) | |
} | |
else { | |
setInterval(() => { | |
const el = document.querySelector("._2Nr6U") | |
if (el && /^Приложение WhatsApp|^WhatsApp is open in another/.test(el.innerText)) { | |
window.close() | |
} | |
}, 2000) | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment