Skip to content

Instantly share code, notes, and snippets.

@cb372
Created March 24, 2012 08:06
Show Gist options
  • Save cb372/2179884 to your computer and use it in GitHub Desktop.
Save cb372/2179884 to your computer and use it in GitHub Desktop.
A simple userscript to hide promoted tweets on twitter.com
// ==UserScript==
// @match http://twitter.com/*
// @match https://twitter.com/*
// ==/UserScript==
elems = document.getElementsByClassName('tweet')
for (var i=0; i<elems.length; i++) {
e = elems[i];
if (e.nodeName.toLowerCase() == 'div' &&
e.attributes['data-promoted'] &&
e.attributes['data-promoted'].value == "true") {
// Just hiding the elem doesn't work, as this is
// not actually the elem that gets rendered to screen.
// Twitter's script will later convert it into
// another, visible, element.
//e.style.display = 'none';
e.parentNode.removeChild(e);
console.debug('Deleted a promoted tweet', e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment