WhatsApp tweaks (dark mode + better use of space)

Enables the official dark mode on WhatsApp Web (by adding the class `dark` to the body) and also removed the dumb space-wasting layout used on displays wider than 1440px.

目前为 2020-05-18 提交的版本。查看 最新版本

// ==UserScript==
// @name         WhatsApp tweaks (dark mode + better use of space)
// @namespace    https://itsad.am
// @version      1.1
// @description  Enables the official dark mode on WhatsApp Web (by adding the class `dark` to the body) and also removed the dumb space-wasting layout used on displays wider than 1440px.
// @author       Adam W
// @match        https://web.whatsapp.com/
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // Make dark mode online when media query matches

    function makeDark(x) {
        let body = document.querySelector('body');
        if (x.matches) { // If media query matches
            body.classList.add('dark');
        } else {
            body.classList.remove('dark');
        }
    }

    var x = window.matchMedia("(prefers-color-scheme: dark)")
    makeDark(x) // Call listener function at run time
    x.addListener(makeDark) // Attach listener function on state changes

    let styles = `
        div.app-wrapper-web:after{
            display: none;
        }

        @media screen and (min-width: 1441px) {
            .app-wrapper-web .app {
                height: 100% !important;
                top: 0 !important;
                width: 100% !important;
            }

            html[dir] .app-wrapper-web .app {
                box-shadow: 0 1px 1px 0 rgba(var(--shadow-rgb),.06),0 2px 5px 0 rgba(var(--shadow-rgb),.2) !important;
                margin: 0 auto !important;
            }

            html[dir] .app-wrapper-web.safari-fix .h70RQ {
                border-radius: 0 !important;
            }
        }
    `
    let styleSheet = document.createElement("style")
    styleSheet.type = "text/css"
    styleSheet.innerText = styles
    document.head.appendChild(styleSheet)
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址