Created
August 20, 2016 17:13
-
-
Save deidyomega/7a79d538cff42076ef6c5da325eef16b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Facebook Ad Killer | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Kill All the Facebook Suggested Posts | |
// @author Matthew Harris | |
// @match https://www.facebook.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
killAd(); | |
// every 3 seconds search and destroy new ads (they load async, as you scroll) | |
window.setInterval(function(){ | |
killAd(); | |
}, 3000); | |
})(); | |
function killAd() { | |
'use strict'; | |
var searchString = 'Suggested Post'; | |
var searchString1 = 'Only you can see this preview until you run this ad'; | |
var elements = document.getElementsByTagName('span'); | |
for (var i = 0; i < elements.length; i++) { | |
if (elements[i].innerHTML === searchString || elements[i].innerHTML === searchString1) { | |
console.log("Found One"); | |
var element = elements[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode; | |
element.parentNode.removeChild(element); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment