Last active
October 29, 2024 08:14
-
-
Save padajo/b95b42d5627306e33fb6bade63d90e18 to your computer and use it in GitHub Desktop.
Basic js to untick all twitter ad settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah yes, exactly what I was looking for. Thanks!