WhatsApp Web Archived Remover

Remove the Archived row from WhatsApp Web

当前为 2023-08-12 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         WhatsApp Web Archived Remover
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Remove the Archived row from WhatsApp Web
// @author       Dequei
// @match        https://web.whatsapp.com/
// @icon         https://web.whatsapp.com/img/favicon/1x/favicon.png
// @grant        none
// @license      MIT
// ==/UserScript==
(function() {
    'use strict';


    function removeArchivedRow() {

        console.info('Archived row remove: start');

        const archivedRow = document.getElementById('pane-side');

        if (archivedRow) {

            const buttonArchived = document.getElementById('pane-side').children[0];

            if (document.getElementById('pane-side').children[0]?.innerText.toLowerCase().includes('archiv')) {

                document.getElementById('pane-side').children[0].style.display = 'none';

                console.info('Archived row remove: done');
            }


        } else {
            failedInfo();
        }
    }

    function waitForElement(querySelector, timeout) {
        return new Promise((resolve, reject) => {
            var timer = false;
            if (document.querySelectorAll(querySelector).length) return resolve();
            const observer = new MutationObserver(() => {
                if (document.querySelectorAll(querySelector).length) {
                    observer.disconnect();
                    if (timer !== false) clearTimeout(timer);
                    return resolve();
                }
            });
            observer.observe(document.body, {
                childList: true,
                subtree: true
            });
            if (timeout) timer = setTimeout(() => {
                observer.disconnect();
                reject();
            }, timeout);
        });
    }

    function failedInfo() {
        console.info('Archived row remove: failed');
    }

    waitForElement("#pane-side", 60000).then(function() {
        removeArchivedRow();
    }).catch(() => {
        failedInfo();
    });



})();