sindresorhus / refined-twitter

Browser extension that simplifies the Twitter interface and adds useful features
MIT License
1.31k stars 89 forks source link

Remove "More Tweets" widget on single tweet page #196

Closed ahmetb closed 3 years ago

ahmetb commented 4 years ago

Twitter just added a very confusing More Tweets section to individual tweet pages, showing "similar" tweets. Totally useless. Let's refine.

e.g. screenshot from https://twitter.com/stroughtonsmith/status/1237037972526071808 image

sindresorhus commented 4 years ago

Agreed. PR welcome :)

ahmetb commented 4 years ago

I definitely lack the JS skills to do that.

FoxxMD commented 4 years ago

Yo this would be amazing

imkaihao commented 4 years ago

Find a userscript from Reddit that works.

// ==UserScript==
// @name    RIP "More Tweets"
// @version 1.0.0
// @grant   none
// @run-at  document-start
// @match   *://*.twitter.com/*/status/*
// ==/UserScript==

//https://stackoverflow.com/a/12222317
var cssPath = function(el) {
    if (!(el instanceof Element))
        return;
    var path = [];
    while (el.nodeType === Node.ELEMENT_NODE) {
        var selector = el.nodeName.toLowerCase();
        if (el.id) {
            selector += '#' + el.id;
            path.unshift(selector);
            break;
        } else {
            var sib = el,
                nth = 1;
            while (sib = sib.previousElementSibling) {
                if (sib.nodeName.toLowerCase() == selector)
                    nth++;
            }
            if (nth != 1) {
                // Build "n+X" directly here
                if (path.length === 0) {
                    selector += ":nth-of-type(n+" + nth + ")";
                } else {
                    selector += ":nth-of-type(" + nth + ")";
                }
            }
            path.unshift(selector);
            el = el.parentNode;
        }
        return path.join(" > ");
    }
}

function rmMo() {
    var moTweets = [...document.querySelectorAll('span')].find(el => el.innerHTML === "More Tweets");
    if (moTweets) {
        var moContainer = moTweets.parentNode.parentNode.parentNode.parentNode.parentNode;
        pt = cssPath(moContainer);
        var sheet = window.document.styleSheets[0];
        sheet.insertRule(`${pt} { display: none; }`, sheet.cssRules.length);
        window.clearInterval(intval);
    }
}
intval = window.setInterval(rmMo, 200);

Source: https://www.reddit.com/r/uBlockOrigin/comments/faqqxx/remove_more_tweets_from_a_tweet_opened_in_a_new/flrhjh2/

sindresorhus commented 3 years ago

Closing as this extension is now deprecated: https://github.com/sindresorhus/refined-twitter/commit/8dd9df749d3a4e82c95b2bd6628c8d65f0f72e6c