Last active
June 7, 2023 11:49
-
-
Save shinmai/6f56595a6f116bca91368ea31da6f384 to your computer and use it in GitHub Desktop.
Hide "Discover More" tweets
This file contains hidden or 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 Hide "Discover More" tweets | |
// @namespace rip.aapo.userscripts | |
// @version 0.0.2 | |
// @description install a mutation listener on Twitter pages that looks for added nodes, and removes any tweets that are below a "Discover more" heading | |
// @author @shinmai - https://shinmai.wtf | |
// @match https://twitter.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com | |
// @grant none | |
// @updateURL https://gist.github.com/shinmai/6f56595a6f116bca91368ea31da6f384/raw/shaddap-algorithm.user.js | |
// @downloadURL https://gist.github.com/shinmai/6f56595a6f116bca91368ea31da6f384/raw/shaddap-algorithm.user.js | |
// ==/UserScript== | |
/** | |
* Changelog: | |
* 0.0.1 (230607) - initial version | |
* 0.0.2 (230607) - forgot how the DOM works for a second there | |
*/ | |
(function() { | |
'use strict'; | |
var timeout=-1; | |
const observer = new MutationObserver( | |
ml => { | |
if(timeout>=0) clearTimeout(timeout); | |
timeout=setTimeout(function(){ | |
const headings = document.querySelectorAll('h2[aria-level="2"]'), bs=[] | |
headings.forEach(h=>{if(h.innerText!="Discover more")return;let it=h.parentElement.parentElement.parentElement.parentElement;bs.push(it);while(it.nextElementSibling){const c=it.nextElementSibling;bs.push(c);it=c}}) | |
bs.forEach(el=>el.parentElement.removeChild(el)) | |
}, 750); | |
} | |
) | |
observer.observe(document.body,{attributes:false,childList:true,subtree:true}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment