-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.