WhatsApp Web - Clean UI

Fix & debloat WhatsApp Web's interface

当前为 2025-05-06 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         WhatsApp Web - Clean UI
// @description  Fix & debloat WhatsApp Web's interface
// @author       Gamba
// @version      1.3
// @license      MIT
// @namespace    http://tampermonkey.net/
// @match        https://web.whatsapp.com/*
// @icon         https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://web.whatsapp.com/&size=256
// @grant        none
// @run-at       document-idle
// ==/UserScript==

"use strict";

// Intercept keyboard shortcuts
{
    document.addEventListener("keydown", onKeyboard, true);

    const shortcuts =
    [
        input => input.ctrlKey && input.key == "Delete"
    ];

    function onKeyboard(input)
    {
        for (const shortcut of shortcuts)
        {
            if (shortcut(input))
            {
                input.stopImmediatePropagation();

                break;
            }
        }
    }
}

// Intercept button clicks
{
    document.addEventListener("click", onClick, true);

    function onClick(event)
    {
        let target = event.target.closest("button");

        if (target && target.closest("header"))
        {
            target.blur();

            document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));
        }
    }
}

// Apply CSS
{
    const css =
    `
    /*Viewport*/
    #app > div > div > div[tabindex="-1"]
    {
        top: 0;

        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
    }

    /*Unnecessary tabs*/
    header > div > div > div > div > span > div > div:first-child
    {
        > div:nth-child(3),
        > div:nth-child(4)
        {
            display: none;
        }
    }

    /*Lists*/
    #side > [role="tablist"]
    {
        display: none;
    }

    /*Download WhatsApp for Windows*/
    #side > :last-child[role="button"] *
    {
        display: none;
    }

    #app > div > div > div > div:nth-child(5) > div:not(#main) > div
    {
        > div:nth-child(1),
        > div:nth-child(2)
        {
            display: none;
        }
    }

    /*Separators*/
    #pane-side
    {
        > div.xh8yej3.x150wa6m,
        > div:last-child
        {
            display: none;
        }

        > div:nth-last-child(2) > div > div > div:first-child > div > div > div > div:last-child
        {
            border-top: 0;
        }
    }

    /*Popup tooltips*/
    #wa-popovers-bucket *
    {
        display: none;
    }

    /*Dropdowns arrows*/
    #pane-side > div:nth-last-child(2) > div > div > div > div > div > div:not(:hover) > div:last-child > div:last-child > div:last-child > span:last-child
    {
        display: none;
    }

    /*Scrollbar*/
    *
    {
        scrollbar-width: unset !important;
        scrollbar-color: unset !important;
    }

    div
    {
        ::-webkit-scrollbar
        {
            width: 14px !important;
        }

        ::-webkit-scrollbar-button
        {
            display: none !important;
        }

        ::-webkit-scrollbar-track,
        ::-webkit-scrollbar-track-piece
        {
            background-color: transparent !important;
        }

        ::-webkit-scrollbar-thumb
        {
            height: 50px !important;

            border: 3px solid transparent !important;
            border-radius: 100px;
            background-clip: padding-box !important;

            background-color: rgba(var(--black-rgb), 20%) !important;
        }
    }

    .dark div ::-webkit-scrollbar-thumb
    {
        background-color: rgba(var(--white-rgb), 16%) !important;
    }
    `;

    const style = document.createElement("style");
    style.textContent = css;
    document.head.appendChild(style);
}