Addshore

It's a blog

Quickly clearing out your Facebook advert ‘interests’

Over the past years Facebook have had a few privacy related issues. First came the ‘scandal’ with Cambridge Analytica and more recently a bug (or series of bugs) that apparently affected 50 million accounts allowing peoples access tokens to be stolen. Oh, and there was also the story about Facebook using your 2 factor authentication phone number for targeting advertising.

With all of the goings on recently, as well as the new GDPR (General Data Protection Regulation) in the EU, Facebook have attempted to make the data that they have about an individual easier to see, understand and edit or remove. One such section of this data covers your “ad preferences“.

Screenshot of Facebook ad preferences

What is actually included here?

Starting at the bottom, there are three pretty fine grained tabs “Hide ad topics”, “Ad settings” and “Your information” that provide you with some control controls and in theory limit some of the data that Facebook will use while targeting.

The top two sections are far more general and contain multiple categories and elements within the categories. “Your interests” includes various interests that Facebook has decided that you have and should be targeting using. “Advertisers you’ve interacted with” shows any interaction with advertisers, including website visits, advert clicks, and advertisers manually adding your contact details it would seem.

Having a little scroll through all of the information here can be quite interesting. I struggle to see how Facebook has made some of the links that it has recorded here for my account, but I have been using Facebook for many years. What on earth is “The Suburban Collection” and why am I apparently interested in it?

Usability for removal

The two larger sections definitely look nice, but are they really that useable? No not really.

My interests section is split over 10 separate categories, each with their own tab for access. Each tab also does not display all interests at once, instead the user is forced to repeatedly click the “See more” link and scroll down the page, tens or hundreds of times. And then I have to target a small X in the top right of each interest box to remove it. No, there is no select all. At least there is no confirmation… It’s almost like Facebook doesn’t want to make removing this stuff easy.

A little bit of JavaScript

I figured rather than spending my time clicking on the thousands of elements that I would need to in order to removal all interests and advertisers that I have interacted with I would knock up a little bit of JavaScript.

I worked on a few different iterations but didn’t want to spend too much time on the problem so I ended up with the small functions below.

This code was last updated on 15 October with an alteration from a comment.

NOTE: Please only run this code if you know what you are doing / understand the code below. This code is licensed with the Unlicense.

This can be directly copy and pasted into the developer console while browsing the “Ads interests” page. Then to run one iteration of the code that will click on “See more” once, followed by clicking on all “Remove” buttons currently visible just run the  seeMoreAndClickXs() function with the following:

Of course you will probably have to run this function multiple times. If you run it and still see the “See more” link at the bottom of the section, then run it again!

Whats next?

Of course the developer console is going to warn you about the possibility of XSS attacks. Running things like this in the developer console isn’t ideal for the masses. Please only do things your comfortable with, give https://www.facebook.com/selfxss a read. Maybe I should turn this into a browser extension…

Ideally Facebook would just make their UX a little better. Why isn’t there just a “Remove all” button?

It would also be nice if this could be a single click thing, rather than having to run this function multiple times. But I couldn’t really get that done in the 15 minutes I dedicated to this task.

Interestingly although all of these interests are “Removed”, facebook still has this data about you, as it continues to list all of the removed interests. I wonder if they go away after a period of time? I imagine not. I wonder if GDPR allows for requests for specific information like this to be removed?

I also have no idea if Facebook was actually using this data in the first place, given my “Ad settings” specify that various types of Ads are already not allowed.

12 Comments

  1. Thanks for this. It’s not working however I’ve been looking to do something similar so may adapt this!

    • I imagine the page layout / html has changed since I wrote the post :(
      It could be worth having something like this as a browser extension.

    • Just to let you know, someone posted a new version of the code in a comment below.
      It might be worth you giving that a go if your looking into this still.

  2. I updated the script a bit as it was tossing errors. I changed it to click the link directly and loop until it was done:


    // For more information, please refer to http://unlicense.org/

    // Find and return the position of the element given
    function findPos(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
    do {
    curtop += obj.offsetTop;
    } while (obj = obj.offsetParent);
    return [curtop];
    }
    }

    // Click on the “See more” link
    function clickSeeMore() {
    var found = “”;
    for (var i = 0; i < aTags.length; i++) {
    if (aTags[i].textContent == searchText) {
    found = aTags[i];
    break;
    }
    }
    var seeMore = found;
    //window.scroll(0,findPos(seeMore)-200);
    if( seeMore != “” ) {
    seeMore.click();
    }

    return found;

    }

    // Click on all X / Remove buttons currently on the page
    function clickAllX(){
    var allX = document.evaluate(‘//button[@data-tooltip-content=\’Remove\’]’, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

    for (i=0; i
    }

    // Combination, Click “See more” and then click all “Remove” buttons
    function seeMoreAndClickXs() {
    var found = “something”;
    while( found != “” ) {
    found = clickSeeMore();
    clickAllX()
    }
    }

    Tested on 08/21/19 in Chrome

    • Amazing! It would be great to start a browser extension with a collection of little snippets like this for features that Facebook should really provide.
      I have updated the post to include an edit linking to this comment!

    • This won’t work – it looks like there are pieces missing.

      From what I can tell, the only thing wrong with the original solution is case – changing the string to “See More” fixed it for me.

      I was also able expand the list fully and then click all the X’s at once by adding a loop to clickSeeMore():


      function clickSeeMore() {
      found = true
      while(found == true) {
      var seeMore = document.evaluate('//div[text()=\'See More\']', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
      if(seeMore) {
      window.scroll(0,findPos(seeMore)-200);
      seeMore.click();
      } else {
      found = false;
      }
      }
      }

      • Thanks for this.
        I have just updated the code in the post with a link to the comment and tested it on my account again (all working).

        • Curiously, I found that when clicking all the X’s at once, everything looks OK in my browser, but nothing changes upon page refresh. I seem to have better results just clicking the X’s without expanding the list, but even then it seems unreliable. It’s almost as if they don’t want you to alter your ad preferences…

          Are you seeing the same thing? I don’t understand this behavior but I’m clueless about JS.

  3. Unfortunately I cannot even OPEN MY Interests, let alone close each collectively or individually. Facebook does NOT respond to pleas for help!

  4. Works for me!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2019 Addshore

Theme by Anders NorénUp ↑

%d bloggers like this: