Skip to content

Instantly share code, notes, and snippets.

@eichin
Created December 5, 2022 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eichin/609932f0808ddc22b9fb4d82be9221e8 to your computer and use it in GitHub Desktop.
Save eichin/609932f0808ddc22b9fb4d82be9221e8 to your computer and use it in GitHub Desktop.
purge the "discover more" appendage that started showing up at the end of thread view.
// ==UserScript==
// @name Discover Less
// @namespace Violentmonkey Scripts
// @match https://twitter.com/*
// @grant none
// @version 1.0
// @author Mark Eichin <eichin@thok.org>
// @description 12/4/2022, 9:41:02 PM
// ==/UserScript==
// Matching on */status/* fails because twitter is a "single page app" and thread views don't actually "load"
// Running every 1.5s *works*. I'd welcome changes that hooked some other event, but I'm not going to
// reverse engineer twitter's "progressive load" mechanism for it.
// Of course this will break if the layout changes, but the css classes are encoded/encrypted so
// I can't actually make it any more robust than that.
function discoverLess(){
var xpath = "//span[text()='Discover more']";
var matchingElement = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (matchingElement.singleNodeValue != null) {
var section = matchingElement.singleNodeValue.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
while (section.nextElementSibling != null) {
section.nextElementSibling.remove();
}
section.remove();
}
}
setInterval(discoverLess, 1500);
@xtreemmasheen3k2
Copy link

Sadly, doesn't seem to work. I'm on Brave Browser.

It removes the "Discover More" element, but the unrelated tweets still show up under it, where they normally would be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment