Skip to content

Instantly share code, notes, and snippets.

@MoritzGiessmann
Last active February 10, 2018 20:06
Show Gist options
  • Save MoritzGiessmann/f7f01b1eb1de599c04d6922a49665ee8 to your computer and use it in GitHub Desktop.
Save MoritzGiessmann/f7f01b1eb1de599c04d6922a49665ee8 to your computer and use it in GitHub Desktop.
Hide Twitter Light "somebody likes that" and sponsored posts (German) Tampermonkery script
// ==UserScript==
// @name Twitter Light Debullcrappifier
// @namespace https://mobile.twitter.com/home
// @version 0.1
// @description Hide Twitter Light "somebody likes that" and sponsored posts (German) Tampermonkery script
// @author @MoritzGiessmann
// @match https://mobile.twitter.com/*
// @grant none
// ==/UserScript==
(function() {
function deepText(node){
var A= [];
if(node){
node= node.firstChild;
while(node!= null){
if(node.nodeType== 3) A[A.length]=node;
else A= A.concat(deepText(node));
node= node.nextSibling;
}
}
return A;
}
function hideTwitterCrap () {
var likes = 0;
var ads = 0;
var allTextNodes = deepText(document.querySelector('body'));
allTextNodes.forEach(function(el){
if (el.textContent.includes('gefällt das') || el.textContent.includes('Gesponsert von')) {
likes++;
el.parentElement.closest('[role="article"]').parentElement.parentElement.style.display ="none";
}
});
console.log(`Hid ${likes} like posts!`);
console.log(`Hid ${ads} ads posts!`);
}
var observer = new MutationObserver(function(mutations){
hideTwitterCrap();
});
observer.observe(document.querySelector('body'), {
childList: true,
subtree: true
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment