Remove New Posts Button On X

Remove the "... posted" button that frequently pops up on on x.com

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Remove New Posts Button On X
// @namespace    https://6942020.xyz/
// @version      1.1
// @description  Remove the "... posted" button that frequently pops up on on x.com
// @author       WadeGrimridge
// @match        https://x.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const timelineSelector = 'main[role="main"] div[aria-label="Home timeline"]';
    const buttonSelector = 'button[aria-label="New posts are available. Push the period key to go to the them."]';

    const removeButton = () => {
        const timeline = document.querySelector(timelineSelector);
        if (timeline) {
            timeline.querySelectorAll(buttonSelector).forEach(button => button.remove());
        }
    };

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', removeButton);
    } else {
        removeButton();
    }

    const observer = new MutationObserver(removeButton);
    observer.observe(document.querySelector(timelineSelector) || document.body, {
        childList: true,
        subtree: true
    });

    window.addEventListener('unload', () => observer.disconnect());
})();