Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
uncheck twitter interests
var timer=100;document.querySelectorAll("div > input[type='checkbox']:checked").forEach((interest) => {setTimeout(function(){interest.click()},timer);timer+=2000;});
@eviltester
Copy link
Author

eviltester commented Feb 25, 2020

I've tried this multiple times now, including by removing the line spacing... it just returns a new line saying "undefined" and does nothing when I hit enter to execute it. Am I doing something wrong, or has Twitter changed something?

Why I follow the instructions it shows 'undefined' and then the checkboxes on the GUI start unchecking - seems to be working fine for me.

@Amariithynar
Copy link

Amariithynar commented Feb 25, 2020

@eviltester
Copy link
Author

eviltester commented Feb 25, 2020

All it does is find all the checkboxes that are checked then loops over them and clicks them.

If:

document.querySelectorAll("div > input[type='checkbox']:checked")

returns an array of elements then something is going wrong with the click on your browser.

If it doesn't return an array of elements then either nothing is checked or the html on your GUI of Twitter is different and the selector doesn't match your GUI.

I have only tried this in Chrome.

@TheMetalCode
Copy link

TheMetalCode commented Feb 28, 2020

It's been working for me in Firefox, FYI

@eviltester
Copy link
Author

eviltester commented Feb 28, 2020

Thanks Jason :)

@Amariithynar
Copy link

Amariithynar commented Feb 28, 2020

@eviltester It's not returning an array of elements, though. It just goes to the next line, shows an arrow pointing outwards, and says "undefined".

After experimenting a bit, since @TheMetalCode said it worked for him, I tried disabling GoodTwitter, and that seems to be it; your code is written to only work with the current version of Twitter, and incompatible with the older layout. Interesting, and good to know for future reference; might want to put a note that if someone is using GoodTwitter because they hate the new UI, they'll have to disable it to have it work!

@fernandog
Copy link

fernandog commented Jan 19, 2021

Added the feature to scrolll down so you can see where is unselecting:

var timer=100;
document.querySelectorAll(
"div > input[type='checkbox']:checked"
).forEach((interest) => {
setTimeout(
function(){interest.click(); window.scrollBy(0,50)},timer
);
timer+=2000;
});

@eviltester
Copy link
Author

eviltester commented Jan 20, 2021

@fernandog thanks - the scrolling is a good idea.

var timer=100;
document.querySelectorAll(
"div > input[type='checkbox']:checked"
).forEach((interest) => {
setTimeout(
function(){interest.click(); interest.scrollIntoView()},timer
);
timer+=2000;
});

I amended your scroll a little by using scrollIntoView on the element, because then it handles gaps in the settings list.

Thanks :)

@Goalie41
Copy link

Goalie41 commented Mar 8, 2021

this worked like a charm!

@KSBolton
Copy link

KSBolton commented Mar 30, 2021

Genius! Thank you!

@baz1414
Copy link

baz1414 commented Apr 19, 2021

thanks for this script.

@KyodaiKen
Copy link

KyodaiKen commented May 8, 2021

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.

@amalic
Copy link

amalic commented May 9, 2021

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');

@KyodaiKen
Copy link

KyodaiKen commented May 13, 2021

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

eviltester commented Jun 17, 2021

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

That's great. Thanks. :)

@rhoughton
Copy link

rhoughton commented Jul 14, 2021

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

@mckayanhder
Copy link

mckayanhder commented Aug 13, 2021

@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

liamness commented Aug 18, 2021

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

Amariithynar commented Aug 18, 2021

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

Amariithynar commented Sep 5, 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

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

adigrateles commented Dec 7, 2021

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

AlexMnrs commented Jan 18, 2022

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

djlank630 commented Feb 8, 2022

@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

RobinFrcd commented Feb 19, 2022

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

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