-
-
Save lanrat/e6693ec6d29cd2726bd28db616bc74fc to your computer and use it in GitHub Desktop.
Auto click "remove" on all facebook advertisers
This file contains hidden or 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
// I did this in Chrome... | |
// | |
// Go to https://www.facebook.com/ads/preferences/ | |
// Click the "Advertisers" section to open it up. | |
// Click "See more" once | |
// Before doing anything else, just keep clicking space bar to trigger the "see more" button | |
// Do this for a bit until all the advertisers are loaded | |
// then run this below in the dev tools console... | |
// (It will take a few minutes, depending how many you have, and your browser may lock up, but once it's done you will see it auto clicked the "remove" X in the top right for all of them) | |
// click "see More" 100 times... | |
for (var i = 0; i<100; i++) { | |
console.log("Expanding to Ads page ", i); | |
document.querySelector('#interacted > div > div._2qor._2pic > div:nth-child(1) > div._dfo > div._45yq._5946 > div > div').click() | |
} | |
// This finds all the "remove" buttons in all the ads | |
var ads = document.getElementsByClassName('_2b2p _4jy0 _4jy3 _517h _51sy _42ft'); | |
console.log(ads.length, 'The number of advertisers listed! YIKES.') | |
// Loop the list of buttons | |
Array.prototype.forEach.call(ads, (e) => { | |
// Check if you have removed the advertiser already (sometimes ones you have already removed still show/load) | |
if (e.getAttribute('data-tooltip-content') === 'Remove') { | |
// click the button and remove them | |
e.click(); | |
console.log('Removed!'); | |
} else { | |
// Skip ones that you have already removed | |
console.log('Skipped!'); | |
} | |
}) | |
// alternativly | |
// document.querySelectorAll("[data-tooltip-content='Remove']").forEach(function (element) { element.click(); }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment