Collapse WebWhatsapp - whatsapp.com

05/11/2022, 12:39:09

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Collapse WebWhatsapp - whatsapp.com
// @namespace   Violentmonkey Scripts
// @match       https://web.whatsapp.com/
// @grant       none
// @version     1.1
// @author      Luca Frigenti
// @description 05/11/2022, 12:39:09
// @license MIT
// @require https://cdn.jsdelivr.net/npm/@violentmonkey/dom@2
// ==/UserScript==

const disconnect = VM.observe(document.body, () => {
  let collapsed = false;
  let _button = document.createElement("button");
  _button.data = "hi";
  _button.innerHTML = "Chiudi";
  _button.onclick = ok;
  _button.setAttribute(
    "style",
    "padding: 3px; margin: 10px; background-color: #f0f2f5; border-radius: 25px; min-width: 60px;"
  );

  document.getElementById("pane-side").prepend(_button);

  function ok() {
    if (collapsed) {
      document
        .getElementById("side")
        .parentElement.setAttribute("style", "width: 750px");
      _button.innerHTML = "Chiudi";
    } else {
      document
        .getElementById("side")
        .parentElement.setAttribute("style", "width: 75px; flex: none;");
      _button.innerHTML = "Apri";
    }
    collapsed = !collapsed;
  }
  disconnect();
});