Skip to content

Instantly share code, notes, and snippets.

@paladique

paladique/README.md

Created Jul 14, 2020
Embed
What would you like to do?
Remove ad interests

Removing ad interests from that one blue site

I appreciate the quality memes and that's mostly what I use it for, but I visited here and was freaked out that this much information was being collected about me. I especially didn't appreciate that I have to click on these one by one to delete em'. PS: There's a browser extension that already does this

What this script does

This script does the clicking and subsequent deleting.

Instructions (Only tested on Chrome)

  1. Go to that first link, make sure you're logged in

  2. Expand the page ("see more") so that the all interests are visible on the page.

  3. Open the console panel. You'll know you're there when you see a big warning (no, this isn't harmful, but use at your own risk).

  4. Paste this into the console:

//Simulates a element click
var simulateClick = function (elem) {
	// Create our event (with options)
	var evt = new MouseEvent('click', {
		bubbles: true,
		cancelable: true,
		view: window
	});
	// If cancelled, don't dispatch our event
	var canceled = !elem.dispatchEvent(evt);
};

//Find the "Xs" - can be identified by the classname (right click on the "x" > inspect to confirm)
var blocs = document.getElementsByClassName(" _2b2n _2b2o")
//We'll need this to stop the loop below
var blocLength = blocs.length

//Loop through each "X" and click them one by one, removing the ad interest
do{
  //Always access the first item (index 0) in the collection because it's always the first visible one "X" on the page
  simulateClick(blocs[0])
  blocLength--
}while(blocLength != 0)

  1. Wait a few seconds, you should see the visible interests removed and greyed out. You will need to do this for every category, and possibly multiple times per category.

Other things

// function from: https://gomakethings.com/how-to-simulate-a-click-event-with-javascript/
//Simulates a element click
var simulateClick = function (elem) {
// Create our event (with options)
var evt = new MouseEvent('click', {
bubbles: true,
cancelable: true,
view: window
});
// If cancelled, don't dispatch our event
var canceled = !elem.dispatchEvent(evt);
};
//Find the "Xs" - can be identified by the classname (right click on the "x" > inspect to confirm)
var blocs = document.getElementsByClassName(" _2b2n _2b2o")
//We'll need this to stop the loop below
var blocLength = blocs.length
//Loop through each "X" and click them one by one, removing the ad interest
do{
//Always access the first item (index 0) in the collection because it's always the first visible one "X" on the page
simulateClick(blocs[0])
blocLength--
}while(blocLength != 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.