Skip to content

Instantly share code, notes, and snippets.

@xim
Last active January 1, 2018 19:06
Show Gist options
  • Save xim/ca63b8f8053517fc460b0b67508ed125 to your computer and use it in GitHub Desktop.
Save xim/ca63b8f8053517fc460b0b67508ed125 to your computer and use it in GitHub Desktop.
Facebook sponsored content remover
// ==UserScript==
// @name Facebook remove all sponsored content
// @namespace https://gist.github.com/xim
// @description Removes all sponsored content.
// @include https://www.facebook.com/*
// @version 6
// @downloadURL https://gist.githubusercontent.com/xim/ca63b8f8053517fc460b0b67508ed125/raw/facebook-sponsored-content-remover.user.js
// @grant none
// ==/UserScript==
function removeAds() {
var ads = document.getElementsByClassName('g_xpd3mprlw');
var i = 0;
while (i < ads.length) {
var el = ads[i];
console.log(i);
while (el && el != document && !el.id.startsWith('substream')) {
el = el.parentNode;
}
if (el && el != document) {
el.remove();
} else {
i++;
}
}
setTimeout(removeAds, 3000);
}
removeAds();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment