TwitterSHB

Twitter Slim Home Bar

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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         TwitterSHB
// @namespace    https://rinrin.me/
// @version      0.2
// @description  Twitter Slim Home Bar
// @author       rin4046
// @match        https://twitter.com/*
// @grant        none
// @license MIT
// ==/UserScript==

{
    const getElementByXPath = (parent, xpath) => {
        return document.evaluate(xpath, parent, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
    };

    const observer = new MutationObserver((muataions, observer) => {
        const wrapper = getElementByXPath(document, "/html/body/div[1]/div/div/div[2]/main/div/div/div/div[1]/div/div[1]/div[1]");

        if (wrapper && window.location.pathname === "/home") {
            const top = wrapper.children[0];
            const bottom = wrapper.children[1];

            const tab = getElementByXPath(wrapper, "div[2]/nav/div/div[2]/div");
            if (!tab.getAttribute("swapped") && tab.children[0].children[0].nodeName === "A") {
                tab.appendChild(tab.children[0]);
                tab.children[0].children[0].click();
                tab.setAttribute("swapped", true);
            }

            wrapper.style.flexDirection = "row";
            bottom.style.flexGrow = 1;

            const { borderBottomWidth, borderBottomStyle, borderBottomColor } = window.getComputedStyle(bottom.children[0]);
            top.style.borderBottomWidth = borderBottomWidth;
            top.style.borderBottomStyle = borderBottomStyle;
            top.style.borderBottomColor = borderBottomColor;
        }
    });
    observer.observe(document.body, { childList: true, subtree: true });
}