Last active
December 29, 2023 06:27
-
-
Save bluetidepro/bfa60c1d63925180daf3dd53e5ff48ea to your computer and use it in GitHub Desktop.
Auto click "remove" on all facebook advertisers and Twitter interests
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
// 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) | |
// This finds all the "remove" buttons in all the ads | |
var fbook_ads = document.getElementsByClassName('_2b2p _4jy0 _4jy3 _517h _51sy _42ft'); | |
console.log(fbook_ads.length, 'The number of advertisers listed! YIKES.'); | |
// Loop the list of buttons | |
Array.prototype.forEach.call(fbook_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' || e.getAttribute('data-tooltip-content') === 'Hide all ads from this advertiser') { | |
// click the button and remove them | |
e.click(); | |
console.log('Removed!'); | |
} else { | |
// Skip ones that you have already removed | |
console.log('Skipped!'); | |
} | |
}) | |
// For Twitter | |
// Go to https://twitter.com/settings/your_twitter_data/twitter_interests | |
// Run this below to uncheck all the interests | |
var twitter_interests = document.getElementsByTagName("input"), | |
twitter_interests_count = 0; | |
Array.prototype.forEach.call(twitter_interests, (e) => { | |
if (e.type === "checkbox" && e.checked === true) { | |
var interest_label = e.parentNode.parentNode.getElementsByTagName("span")[0].innerText; | |
// click the checkbox and remove them | |
e.click(); | |
console.log('Removed "' + interest_label + '"!'); | |
twitter_interests_count++; | |
} | |
}) | |
if (twitter_interests_count === 0) { | |
console.log('horray, no interests!'); | |
} else { | |
console.log(twitter_interests_count, 'The number of interests listed! YIKES.'); | |
} |
It looks like Facebook have updated the page, so your code doesn't work fully. You now need another selector:
document.querySelectorAll("[data-tooltip-content='Remove'],[data-tooltip-content='Hide all ads from this advertiser']").forEach(function (element) { element.click(); })
@freeAgent85 Good call, I updated it!
Update: looks like this no longer works because of the dark patterns that Facebook has updated/changed on that page. Ugh.
Yup, the new section for "Who Uploaded a List With Your Information" is awful. They don't even do users the courtesy of indicating which companies they've previously blocked until they click "View Controls" on the entry. And the list is randomly sorted, not in alphabetical or chronological order. This move pushed me ever-closer to simply closing my Facebook account and being done with it entirely.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dougwebb yeah, def. The only benefit I found personally with finding the ones skipped was it's good to see the the full list, if you needed.