Skip to content

Instantly share code, notes, and snippets.

@padajo
Last active April 28, 2024 06:21
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save padajo/b95b42d5627306e33fb6bade63d90e18 to your computer and use it in GitHub Desktop.
Save padajo/b95b42d5627306e33fb6bade63d90e18 to your computer and use it in GitHub Desktop.
Basic js to untick all twitter ad settings
/*
* To untick all the "personalised interests" that are used for ad targeting on twitter
* you go to this page:
*
* https://twitter.com/settings/your_twitter_data/twitter_interests
*
* Go to the inspector and run this code and it should untick all the ticked boxes
* in the list. You can change the interval to less than 650ms. You need a delay
* or the twitter API thinks you're trying to overload it.
*
* Updated after twitter ping to my network... see
*
* https://twitter.com/pauldjohnston/status/1408448277218054152?s=21
*
*/
var checkboxes = [];
// we only really want to find those that are checked/ticked
// so instead of looping over all of them (with an interval)
// only loop over the checked ones, and put them into
// the checkboxes array
document.querySelectorAll('input[type="checkbox"]').forEach((c) => {
if(c.checked) {
checkboxes[checkboxes.length] = c;
}
});
var i = 0;
var loopId = setInterval(() => {
var e = checkboxes[i++];
if(i % 10 == 0) { console.log("Running... (" + i + ")")} // added in to make it give some idea that it's working...
if(e !== undefined) {
if(e.checked) {
console.log(e);
e.parentElement.click();
}
} else {
clearInterval(loopId);
}
}, 650); // seems to be a good interval to not overload the API
@av1d
Copy link

av1d commented Feb 28, 2022

Thanks! This worked perfectly.

@richoux
Copy link

richoux commented Mar 10, 2022

Ah yes, exactly what I was looking for. Thanks!

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