Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==UserScript==
// @name Twitter Timeline Declutter
// @namespace twitter-com-timeline-declutter
// @downloadURL https://******************/userscripts/twitter.user.js
// @updateURL https://******************/userscripts/twitter.user.js
// @description Remove "Who to Follow", "While you were away", "You might like" and "Trends" from your timeline stream
// @include https://twitter.com/*
// @include https://twitter.com
// @version 0.0.12.7
// ==/UserScript==
window.addEventListener("load", function() {
// console.log("Starting 2 ...");
function removeElement(el) {
if ( el == null || el == "undefined" ) {
console.log("twitter: removeElement: received invalid element, or element does not exist");
return;
}
/*
if ( el.id != null || el.id != "undefined" ) {
console.log("Removing: " + el.id);
} else {
console.log("Removing object with no ID");
}
*/
el.parentNode.removeChild(el);
}
function doCleanup(){
// console.log("Processing...");
try {
var elements = document.querySelectorAll(".DismissibleModule");
if ( elements != null || elements != "undefined" ) for (x = 0; x < elements.length; x++) {
removeElement(elements[x]);
}
elements = document.querySelectorAll("div.Trends.module.trends");
if ( elements != null || elements != "undefined" ) for (x = 0; x < elements.length; x++) {
removeElement(elements[x]);
}
elements = document.querySelectorAll("div.flex-module");
if ( elements != null || elements != "undefined" ) for (x = 0; x < elements.length; x++) {
removeElement(elements[x]);
}
t = setTimeout(doCleanup, 500);
} catch(e) {
console.log("twitter: exception: " + e.message);
}
}
// console.log("Starting...");
doCleanup();
}, false);
@Korb
Copy link

Korb commented Apr 25, 2022

After installing the script and reloading the twitter.com/home didn't notice any difference.
Mozilla Firefox 99.0.1 (64-bit), Tampermonkey 4.16.6160 (6 April 2022).

@aureq
Copy link
Author

aureq commented Apr 26, 2022

@Korb indeed. The code is 6 years old and I haven't worked on it since. I'm also not using twiiter.com anymore but instead a desktop client named Tweeten.

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