Fix & debloat WhatsApp Web's interface
当前为
// ==UserScript==
// @name WhatsApp Web - Clean UI
// @description Fix & debloat WhatsApp Web's interface
// @author Gamba
// @version 1.1
// @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
// ==/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;
}
`;
const style = document.createElement("style");
style.textContent = css;
document.head.appendChild(style);
}