Created
February 18, 2019 18:15
-
-
Save dccampbell/1ff8ef37db3acf22e85650042f968449 to your computer and use it in GitHub Desktop.
A script for selectively batch removing advertisers from your Facebook preferences.
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
// https://www.facebook.com/ads/preferences/ | |
function loadAllAdvertisers() { | |
if(!document.querySelector('#interacted ._45ys')) { | |
document.querySelector('#interacted div[role=button]').click(); | |
} | |
window.interactedInterval = setInterval(function() { | |
var moreBtn = document.querySelector('#interacted ._45yr'); | |
if(moreBtn) { | |
document.querySelector('#interacted ._45yr').click(); | |
} else { | |
clearInterval(interactedInterval); | |
console.log('All advertisers loaded.'); | |
} | |
}, 800); | |
} | |
loadAllAdvertisers(); | |
function killAdvertiser() { | |
for(var ad of document.querySelectorAll('#interacted ._2b2e')) { | |
for(var i=0; i < arguments.length; i++) { | |
if(ad.textContent.includes(arguments[i]) && ad.textContent.includes("Remove")) { | |
ad.querySelector('button').click(); | |
} | |
} | |
} | |
} | |
// Usage Examples: | |
// killAdvertiser('Auto', 'Motors', 'Truck', 'BMW', 'Volks', 'Toyota', 'Kia', 'Hyundai', 'Nissan', 'Honda'); | |
// killAdvertiser('Ford', 'Mazda', 'Dodge', 'Subaru', 'Land Rover', 'Benz', 'Acura', 'Buick', 'Chevy', 'Lexus'); | |
// killAdvertiser('Realtor', 'Realty', 'Real Estate', 'Homes', 'Houses'); | |
// killAdvertiser(''); // remove all (may be extremely slow or even crash if too many) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment