WhatsApp Deleted Messages Viewer

Alert when a message is deleted in WhatsApp Web.

当前为 2024-04-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         WhatsApp Deleted Messages Viewer
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Alert when a message is deleted in WhatsApp Web.
// @author       Yusuf Sameh
// @match        https://web.whatsapp.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to handle incoming messages
    function handleNewMessages(mutationsList) {
        mutationsList.forEach(mutation => {
            if (mutation.type === 'childList') {
                mutation.addedNodes.forEach(node => {
                    if (node.nodeType === Node.ELEMENT_NODE && node.classList.contains('message-in')) {
                        const message = node.querySelector('.message-in .selectable-text');
                        if (message && message.textContent === 'This message was deleted') {
                            alert('A message was deleted.');
                        }
                    }
                });
            }
        });
    }

    // Select the target node
    const targetNode = document.querySelector('#pane-side');

    // Options for the observer (which mutations to observe)
    const config = { childList: true, subtree: true };

    // Check if targetNode exists before observing mutations
    if (targetNode) {
        // Create an observer instance linked to the callback function
        const observer = new MutationObserver(handleNewMessages);

        // Start observing the target node for configured mutations
        observer.observe(targetNode, config);
    } else {
        console.error('Target node not found.');
    }
})();