Change Telegram web page elements

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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.4
// @icon         https://gcore.jsdelivr.net/gh/Bush2021/img-hosting@main/Icons/Telegram.svg
// @author       Bush2021
// @match        https://web.telegram.org/k/*
// @grant        GM_addStyle
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const MENU_ITEM_SELECTOR = 'div.menu-horizontal-div-item';

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

    function clickSecondElement() {
        const secondMenuItem = document.querySelector(`${MENU_ITEM_SELECTOR}:nth-of-type(2)`);
        if (secondMenuItem) {
            secondMenuItem.click();
        }
    }

    function hideAllChatsButton() {
        const allChatsButton = document.querySelector(MENU_ITEM_SELECTOR);
        if (allChatsButton && allChatsButton.textContent.trim().startsWith("All")) {
            allChatsButton.style.display = "none";
        }
    }

    function checkAndExecute() {
        const targetElement = document.querySelector(MENU_ITEM_SELECTOR);
        if (targetElement) {
            moveChatElementsOnce();
            clickSecondElement();
            hideAllChatsButton();
        } else {
            setTimeout(checkAndExecute, 10);
        }
    }

    checkAndExecute();
})();