Skip to content

Instantly share code, notes, and snippets.

@willh
Created November 20, 2012 21:49
Show Gist options
  • Save willh/4121435 to your computer and use it in GitHub Desktop.
Save willh/4121435 to your computer and use it in GitHub Desktop.
Facebook ads removal UserJS
// ==UserScript==
// @name Facebook Cleanup
// @description Remove ads from your Facebook page
// @author @willhamill
// @include https://facebook.com/*
// @include https://www.facebook.com/*
// @include http://facebook.com/*
// @include http://www.facebook.com/*
// ==/UserScript==
// run after page has loaded delayed by 1 second to allow for ajax bullshit
(setTimeout(function(){
// these ad-panel IDs changes every few weeks
document.getElementById("pagelet_ego_pane_w").style.display = "none"
document.getElementById("pagelet_side_ads").style.display = "none"
function hideElemContaining(matchString) {
var stories = document.getElementsByTagName('li'), i;
for (i in stories) {
var sponsored = stories[i]
if (sponsored.innerHTML.indexOf(matchString) != -1) {
sponsored.style.display = "none"
}
}
}
// currently all sponsored posts contain this HTML, may require updating
hideElemContaining("<a href=\"/about/ads\">")
}, 1000))();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment