Skip to content

Instantly share code, notes, and snippets.

@pascalwhoop
Created February 18, 2017 10:55
Show Gist options
  • Save pascalwhoop/863a7d89ee3ba49a0ea3fb55313e8c66 to your computer and use it in GitHub Desktop.
Save pascalwhoop/863a7d89ee3ba49a0ea3fb55313e8c66 to your computer and use it in GitHub Desktop.
A small script that clicks all the buttons on the Facebook ad preferences screen to hide all ads and remove all interests. Maybe it neutralizes ads on FB and keeps me from being in a filter bubble?
//Instruction:
// 1. go here https://www.facebook.com/ads/preferences/?entry_product=ad_settings_screen
// 2. open dev console
// 3. paste code below and execute expandAll()
// 4. repeat for all categories that aren't shown simulaneously
function expandAll(){
var intr = setInterval(function(){
var btns = document.getElementsByClassName('_45yq'); //the class name of the expand buttons
for(var i=0;i<btns.length;i++){
btns[i].click();
}
if(btns.length == 0){
clearInterval(intr);
clickAllNo();
return;
}
console.log('expanding...')
},200);
}
function clickAllNo(){
var buttons = document.getElementsByClassName('_2b2p') //the class name of the buttons that you click to hide stuff
for(var i = 0;i<buttons.length;i++){
var b = buttons[i];
var bType = b.getAttribute('data-tooltip-content');
if(bType.indexOf('See')>0) continue; //needs to be fine tuned to other languages
if(bType.indexOf('Add')>0) continue;
b.click();
}
console.log('all done!')
}
expandAll();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment