Created
December 28, 2018 04:19
-
-
Save dsc/977cea85423c401eee3940a7d3b4b1c1 to your computer and use it in GitHub Desktop.
Facebook Spam-vertiser Remover
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
/* Facebook Spam-vertiser Remover | |
It looks like fb advertisers can now upload a list of emails to spam with FB ads. I | |
wrote this script -- which blocks them from the ad preferences page -- mostly out of | |
spite and annoyance. It will not reduce the number of ads you see, or really make them | |
better, it will simply penalize the companies who uploaded a big-ass list of emails | |
they bought. For example, I see about 500 car dealerships in my list. I neither have | |
a car nor do I want one. | |
These steps require you to be comfortable with the browser's console. The steps below are for Chrome. | |
1. Go to https://www.facebook.com/ads/preferences/?entry_product=ad_settings_screen | |
2. Open the console; on a Mac it's Cmd+Opt+i -- on Windows I assume it's Ctrl+Alt+i. You'll see a HUGE message about how you shouldn't fuck with this if you don't know what you're doing. Ignore it. | |
3. Run the code below: | |
*/ | |
function removeSpamvertisers(){ | |
var removeBtns = document.querySelectorAll('#interacted ._2b2h._2b2i'); | |
var removable = els.filter((el) => (el.textContent == "Remove")); | |
console.groupCollapsed("Found %d potential assholes to remove...", removable.length); | |
removeBtns.forEach(function(el){ | |
console.log(el.parentNode.parentNode.textContent, el.textContent); | |
if (el.textContent == "Remove"){ | |
el.firstElementChild.click(); | |
} | |
}); | |
console.groupEnd(); | |
} | |
var t, no_more = 0; | |
function letsSeeMoreAssholes(){ | |
var moar = document.querySelectorAll('#interacted ._45yr'); | |
if (moar.length && typeof moar[0].click == "function") { | |
moar[0].click(); | |
no_more = 0; | |
removeSpamvertisers(); | |
} else { | |
if (++no_more > 24) { | |
console.log("No 'More' button found after waiting 6s! Done?"); | |
clearInterval(t); | |
} | |
removeSpamvertisers(); | |
} | |
}; | |
// Expand the Spammy "interacted with" (aka bought my email address) set | |
document.getElementById('interacted').firstElementChild.firstElementChild.click(); | |
// kick off the loop | |
t = setInterval(letsSeeMoreAssholes, 250); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment