Upgrade "𝕏" logo to Wayland

to get ahead of the inevitable migration, this replaces the 𝕏 logo with the Wayland logo

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Upgrade "𝕏" logo to Wayland
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  to get ahead of the inevitable migration, this replaces the 𝕏 logo with the Wayland logo
// @author       Eli T. Drumm
// @license      MIT
// @match        https://twitter.com/*
// @match        https://x.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant        GM_addElement
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    const url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/99/Wayland_Logo.svg/399px-Wayland_Logo.svg.png?20210508213124'

    // Create a new MutationObserver instance
    var observer = new MutationObserver(function(mutations) {
        // For each mutation
        mutations.forEach(function(mutation) {
            // If new nodes are added
            if(mutation.addedNodes) {
                // Find the first h1 tag
                var h1 = document.getElementsByTagName("h1")[0]

                if(h1) {
                    // Get the first child of h1
                    var firstChild = h1.childNodes[0]

                    if(firstChild) {
                        // Get the first child of the first child of h1
                        var firstGrandchild = firstChild.childNodes[0]

                        if(firstGrandchild) {
                            // Remove the first child of the first child of the first h1 tag
                            firstChild.removeChild(firstGrandchild)
                        }


                        GM_addElement(firstChild, 'img', {
                            src: url,
                            height: '60px',
                            style: 'margin-top: 10px; margin-left: 10px;'
                        })

                        // Disconnect the observer when we've found and manipulated the h1
                        observer.disconnect()
                    }
                }
            }
        })
    })

    // Configuration of the observer
    var config = { childList: true, subtree: true }

    // Pass in the target node (in this case, the whole document) and the observer options
    observer.observe(document, config)
})();