Remove New Posts Button On X

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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());
})();