Skip to content

Instantly share code, notes, and snippets.

@eviltester
Last active March 11, 2024 00:05
Show Gist options
  • Save eviltester/11093f0e4c501a41990e227393184eda to your computer and use it in GitHub Desktop.
Save eviltester/11093f0e4c501a41990e227393184eda to your computer and use it in GitHub Desktop.
uncheck twitter interests
var timer=100;document.querySelectorAll("div > input[type='checkbox']:checked").forEach((interest) => {setTimeout(function(){interest.click()},timer);timer+=2000;});
@KyodaiKen
Copy link

This is now all in vain, twitter just gradually replaces interests in that list with new ones that are checked by default. There's nothing you can do.

This man has helped us remove 100s of these interests which will ultimately lead to a cleaner timeline, and you can't be bothered to check your interests and manually uncheck them AND/OR just rerun this script? Holy shit you must be a fun person....

Well I am ranting about Twitter, not about this solution. It's neat, though it seems like Twitter has shady tricks up their sleeves to make it not viable anymore.

@noseratio
Copy link

noseratio commented May 31, 2021

Thank you! I've refactored your script like this:

await async function() {
   const checked = document.querySelectorAll("div > input[type='checkbox']:checked");
   for (let c of checked) {
      await new Promise(r => setTimeout(r, 50));
      c.scrollIntoView(true);
      c.click();
   } 
}();

I don't know why, but this way I've stopped getting those errors 503 from the API requests 😎
To keep it handy in one place, the setting link:
https://twitter.com/settings/your_twitter_data/twitter_interests

Edited, I keep coming back to this, so a self-reminder to block at the beginning and unblock at the end: https://twitter.com/i/api/1.1/account/personalization/p13n_preferences.json
(thanks to many folks who suggested it in this thread)

@eviltester
Copy link
Author

Thank you! I've refactored your script like this:

That's great. Thanks. :)

@rhoughton
Copy link

Just fyi, it works on Edge. Thank you so much for this!!!

@mckayanhder
Copy link

@eviltester thank you! this worked well for the first 20 for me before the 503 err. I removed the timer and in chrome it worked for all of them.

For anyone using it on chrome

document.querySelectorAll( "div > input[type='checkbox']:checked" ).forEach((interest) => { setTimeout( function(){interest.click(); })});

refresh page immediately after it finishes.

if it runs for too long around 10s + the err might show up.

@liamness
Copy link

I think the simplest way to do this is the following:

  • Block https://twitter.com/i/api/1.1/account/personalization/p13n_preferences.json in your browser's devtools
  • Run one of the snippets (probably any, shouldn't really matter) to uncheck everything.
  • Remove the block rule previously created. Check and then uncheck one of the interests

This gets around the rate limiting. The local state of what is checked is remembered, so with the last step you should be able to disable all the interests in one step.

Maybe you want to send all those individual requests though, to give Twitter a hint that they ought to build better controls for handling user data, or allow us to opt out of topics.

@Amariithynar
Copy link

I think the simplest way to do this is the following:

  • Block https://twitter.com/i/api/1.1/account/personalization/p13n_preferences.json in your browser's devtools
  • Run one of the snippets (probably any, shouldn't really matter) to uncheck everything.
  • Remove the block rule previously created. Check and then uncheck one of the interests

This gets around the rate limiting. The local state of what is checked is remembered, so with the last step you should be able to disable all the interests in one step.

This really worked! Just a warning to anyone doing this, though; it appears in "network" tab, and also doesn't necessarily appear immediately. I had to wait a solid minute before it showed up, using the find function or otherwise.

@fernandog
Copy link

fernandog commented Aug 25, 2021

I had to wait a solid minute before it showed up, using the find function or otherwise.

don't need to wait. block something else, edit and past the wanted block URL

update: didn't work here blocking that URL

@Amariithynar
Copy link

I had to wait a solid minute before it showed up, using the find function or otherwise.

don't need to wait. block something else, edit and past the wanted block URL

update: didn't work here blocking that URL

Heh. it's the P13n_preferences.json that matters, and yes you need to wait. It works just like how was written by Liamness, it blocks them afterwards super-quickly. Just gotta make sure you remove the rule, then check and uncheck an interest to get the entire list to accept the changes made afterwards.

@adigrateles
Copy link

Thanks so much for the snippets. Saw my Interests list for the first time and wondered how tf I was going to clear that mountain.

https://twitter.com/i/api/1.1/account/personalization/p13n_preferences.json can also be blocked through uBlock Origin fyi

@cthakker
Copy link

cthakker commented Dec 25, 2021

https://gist.github.com/eviltester/11093f0e4c501a41990e227393184eda#gistcomment-3864878
This is the simplest fix, Just make sure after you unblock p13n_preferences, click and unclick, request to p13n_preferences.json goes through in network tab.

@kissu
Copy link

kissu commented Jan 11, 2022

Nice one!
Is it useful anyhow if we're using Lists too?

@AlexMnrs
Copy link

Not working any of the solutions shared. Even if I uncheck them all, there will show up some new interests inmediately so this is kind of useless. Anyway, thank you all guys!

@djlank630
Copy link

@AlexMnrs Here is how I got it to work just now:
https://gist.github.com/eviltester/11093f0e4c501a41990e227393184eda?permalink_comment_id=4032511#gistcomment-4032511

It's important to block https://twitter.com/i/api/1.1/account/personalization/p13n_preferences.json under the network tab. F12 will also open devtools, or right click and select inspect. Click network tab, towards the bottom you should see "Network request blocking" and then a clickable button that says add pattern. Add p13n_preferences.json url inside there. I saw some other comments say to wait until you can see it in there and then you can just select it. You can copy and paste that as well and it should still work.

Go back to your console tab and add the snippet at the bottom, hit enter then let it process.

Once it finishes, unblock p13n_preferences.json, select an interest and then immediately unselect it. This should allow the changes to be saved. After that I refreshed and every interest was unchecked.

@AlexMnrs
Copy link

AlexMnrs commented Feb 10, 2022

@djlank630 That's actually how I did it. I repeated the process step by step and nothing changes. When I unblock the p13n_preferences.json url, check and uncheck any interest and refresh, everything is checked again. Thanks anyway!

@RobinFrcd
Copy link

Thanks for the gist, here's one to dismiss all topics suggested by twitter on this page: https://twitter.com/YOURUSERNAME/topics

https://gist.github.com/RobinFrcd/8b52224f05db01e7465f67f3598e42d6

@Hizaak
Copy link

Hizaak commented Mar 25, 2022

[ To completely block Twitter's subjects / topics / "You might be interested in" etc. ]
I was looking for a while to find back THIS solution, wich seems to actually be one of the most efficient to prevent this kind of annoying stuff that Twitters shows us : https://twitter.com/JonoHimself/status/1107743787856465921

@tomyvi
Copy link

tomyvi commented Aug 2, 2022

Works like a charm, thanks @eviltester !!

@zhSHUVO
Copy link

zhSHUVO commented Dec 19, 2022

This one works for me in Chrome

  1. Browse to https://twitter.com/settings/your_twitter_data/twitter_interests
  2. Open developer tools and enter following one-liner into your console
$$('input:checked').forEach( (w) => { w.click() } ); console.log('done');

this worked for me quicker then other solutions, i'm using brave browser. thanks.

@kissu
Copy link

kissu commented Dec 19, 2022

Twitter is kinda dead nowadays 💀, I guess we can safely all move toward Mastodon. 👍

@amalic
Copy link

amalic commented Dec 19, 2022

This one works for me in Chrome

  1. Browse to https://twitter.com/settings/your_twitter_data/twitter_interests
  2. Open developer tools and enter following one-liner into your console
$$('input:checked').forEach( (w) => { w.click() } ); console.log('done');

this worked for me quicker then other solutions, i'm using brave browser. thanks.

👍

@jcambien
Copy link

If you have a lot of checked interests, X will start to ignore your requests and return a 503 HTTP error if you uncheck them too fast.
Here is a script that uncheck interests every 2 seconds, just launch it and wait until the counter has reached the end.

var counter = 0;
var wait = 2000;
var interests = $$('input:checked');

interests.forEach( (w) => {
    var current = counter;
    setTimeout(() => {
        console.log(current + '/' + interests.length);
        w.click();
    }, wait * counter);
    counter++;
});

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