A popular person in our community receives a lot of WhatsApp messages — in thousands — especially during events and he obviously cannot reply or even read all of them. He asked me if there was a way to Mark as Read all messages so I came up with this quick and dirty solution that works in WhatsApp Web.
Just copy and paste the following script in the browser console and wait for it to finish. It marks a message as read every 2 seconds.
const triggerMouseEvent = (node, eventType) => {
var clickEvent = document.createEvent("MouseEvents");
clickEvent.initEvent(eventType, true, true);
node.dispatchEvent(clickEvent);
},
timer = (ms) => {
return new Promise((res) => setTimeout(res, ms));
},
selector = '[aria-label*="unread message"]',
messages = (async () => {
for (const message of document.querySelectorAll(selector)) {
["mouseover", "mousedown", "mouseup", "click"]
.map((event) => triggerMouseEvent(message, event));
await timer(2000);
}
})();
Top comments (0)