Skip to content

Instantly share code, notes, and snippets.

@ShoGinn
Last active April 16, 2020 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShoGinn/f29418397e6bc9062d2b0a91169a6bf0 to your computer and use it in GitHub Desktop.
Save ShoGinn/f29418397e6bc9062d2b0a91169a6bf0 to your computer and use it in GitHub Desktop.
Facebook Advertiser and Business List Dis-Allow
// This script removes you from advertisers' target lists on Facebook.
// They probably added you to their advert targeting list by uploading a contact list that includes
// your contact information like your email address or phone number.
// Comment below if this doesn't work for you
// *Instructions*
// 1. Go to https://www.facebook.com/ads/preferences
// 2. Open the Console in the Developer Tools
// (Mac: Alt+Cmd+K on Firefox, Alt+Cmd+J on Chrome; Windows/Linux: Control+Shift+K on Firefox, Control+Shift+J on Chrome)
// 3. Ignore the warnings from Facebook in the Console.
// I've annotated the script to help you understand it but sorry at some point you'll just have to trust me! :-)
// 4. Paste in this script below.
////////
// This just enforces certain bits of best practice in Javascript (the language this script is written in)
"use strict";
// Expands the "Advertisers you've interacted with" dropdown
var interactedList = document.getElementsByClassName("_2qoe _2qof")[1];
interactedList.click();
// Clicks the "Show more" buttons until all the advertisers are revealed
// You may have to adjust the class name for "Show More" buttons if Facebook changes them
var showMoreButton = document.getElementsByClassName("_45yq _5946")[0];
while (showMoreButton) {
showMoreButton.click();
var showMoreButton = document.getElementsByClassName("_45yq _5946")[0];
}
// Clicks into each of the interest areas one-by-one
var advertiser = Array.from(document.getElementsByClassName("_4ik4 _4ik5"));
var timeout = 500
advertiser.forEach((name, i) => {
setTimeout(() => {
if (name.textContent == "View Controls") {
name.click();
console.log("Opening Interest");
}
setTimeout(() => {
// You may have to adjust the class names for "Remove" buttons if Facebook changes them
var removeButtons = Array.from(document.getElementsByClassName("_271k _271m _1qjd _7tvm _7tv2 _7tv4"));
// Clicks the remove button on each of the advertisers
removeButtons.forEach((removeButton) => {
if (removeButton.textContent == "Don't Allow") {
removeButton.click();
console.log("Click Don't Allow");
}
});
}, i * timeout);
setTimeout(() => {
var DoneButtons = Array.from(document.getElementsByClassName("_271k _271m _1qjd _7tvm _7tv2 _7tv4"));
DoneButtons.forEach((DoneButton) => {
if (DoneButton.textContent == "Done") {
DoneButton.click();
console.log("Click Done");
}
});
}, i * timeout);
}, i * timeout);
});
@ShoGinn
Copy link
Author

ShoGinn commented Apr 16, 2020

@ShoGinn
Copy link
Author

ShoGinn commented Apr 16, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment