Change Telegram web page elements

Move the Telegram chat bubble to the left and hide the "All Chats" button

目前為 2023-09-10 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Change Telegram web page elements
// @namespace    https://greasyfork.org/zh-CN/users/737511
// @description  Move the Telegram chat bubble to the left and hide the "All Chats" button
// @version      0.2
// @icon         https://files.codelife.cc/user-website-icon/20230808/ErvslN5_TO_7idq_Lw1kQ3143.svg
// @author       Kaede
// @match        https://web.telegram.org/k/*
// @grant        GM_addStyle
// @license      MIT
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    function moveChatElementsOnce() {
        GM_addStyle('.chat-input, .bubbles-date-group { transform: translateX(-95px); }');

        // Wait for the "All Chats" button to appear, then hide it
        const hideAllChatsButton = () => {
            const allChatsButton = document.querySelector('.active.rp.menu-horizontal-div-item');
            if (allChatsButton && allChatsButton.textContent.trim() === "All Chats") {
                allChatsButton.style.display = "none";

                // Auto switch to the second element in .menu-horizontal-div
                const secondMenuItem = document.querySelector('div.rp.menu-horizontal-div-item:nth-of-type(2)');
                if (secondMenuItem) {
                    secondMenuItem.click();
                }
            } else {
                requestAnimationFrame(hideAllChatsButton);
            }
        };

        // Start the process to hide "All Chats"
        hideAllChatsButton();
    }

    // Execute the function immediately when the script is loaded
    moveChatElementsOnce();
})();