Skip to content

Instantly share code, notes, and snippets.

@IanColdwater
Last active November 17, 2024 02:37
Show Gist options
  • Save IanColdwater/88b3341a7c4c0cf71c73ac56f9bd36ec to your computer and use it in GitHub Desktop.
Save IanColdwater/88b3341a7c4c0cf71c73ac56f9bd36ec to your computer and use it in GitHub Desktop.
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
suggest_grouped_tweet_hashtag
suggest_pyle_tweet
suggest_ranked_organic_tweet
suggest_ranked_timeline_tweet
suggest_recap
suggest_recycled_tweet
suggest_recycled_tweet_inline
suggest_sc_tweet
suggest_timeline_tweet
suggest_who_to_follow
suggestactivitytweet
suggestpyletweet
suggestrecycledtweet_inline
@liamengland1
Copy link

In case anyone wants to fully automate entering these in. I took @j6k4m8's snippet and expanded on it.

Doesn't work on old twitter design, sadly

@shstkvch
Copy link

shstkvch commented Jan 25, 2020

@jakebellacera Thank you so much for doing this, so useful. What's the advantage of using Object.getOwnPropertyDescriptor over just setting the value of the field with document.querySelectorAll("[name='keyword']")[0].value = keyword; as in @j6k4m8's snippet ?

@freedmand
Copy link

Expanded on @jakebellacera's script to make it work for my browser. Visit https://twitter.com/settings/add_muted_keyword, open your browser's javascript console, and paste the following script in:

const delayMs = 1000; // change this if you feel like its running too fast

const keywords = `ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
suggest_grouped_tweet_hashtag
suggest_pyle_tweet
suggest_ranked_organic_tweet
suggest_ranked_timeline_tweet
suggest_recap
suggest_recycled_tweet
suggest_recycled_tweet_inline
suggest_sc_tweet
suggest_timeline_tweet
suggest_who_to_follow
suggestactivitytweet
suggestpyletweet
suggestrecycledtweet_inline`.split(/\W+/);

const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;

const addMutedKeyword = keyword => {
  const input = document.querySelector("[name='keyword']");
  nativeInputValueSetter.call(input, keyword);
  input.dispatchEvent(new Event('input', { bubbles: true }));
  document.querySelector("[data-testid='settingsDetailSave']").click();
}

const delay = () => {
  return new Promise(res => setTimeout(res, delayMs));
};

keywords.reduce(async (prev, keyword) => {
  await prev;
  addMutedKeyword(keyword);
  await delay();
  document.querySelector('[aria-label="Add muted word or phrase"]').click();
  return delay();
}, Promise.resolve());

@j6k4m8
Copy link

j6k4m8 commented Jan 25, 2020

You beautiful, wonderful people. Confirmed @jakebellacera's code works for me, latest firefox on 'vanilla' twitter.com. Glad my lines of code found a good home :)

@jakebellacera
Copy link

@shstkvch glad it was useful to someone. 🙂 The main reason why is because Twitter uses React, and the input is a controlled field, so merely mutating the value on the HTML field does nothing because the application state isn’t aware that the input changed (and therefore you cannot submit the form on the page).

@Think4866
Copy link

Thanks for sharing, awesome

@vabruce
Copy link

vabruce commented Jan 25, 2020

Well done, thank you for sharing!

@catarino
Copy link

In case anyone wants to fully automate entering these in. I took @j6k4m8's snippet and expanded on it.

  1. Visit https://twitter.com/settings/muted_keywords
  2. Open your browser's dev tools (note: this does work in Chrome)
  3. Paste the following code in:
const delayMs = 500; // change this if you feel like its running too fast

const keywords = `ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
suggest_grouped_tweet_hashtag
suggest_pyle_tweet
suggest_ranked_organic_tweet
suggest_ranked_timeline_tweet
suggest_recap
suggest_recycled_tweet
suggest_recycled_tweet_inline
suggest_sc_tweet
suggest_timeline_tweet
suggest_who_to_follow
suggestactivitytweet
suggestpyletweet
suggestrecycledtweet_inline`.split(/\W+/);

const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;

const addMutedKeyword = keyword => {
  const input = document.querySelector("[name='keyword']");
  nativeInputValueSetter.call(input, keyword);
  input.dispatchEvent(new Event('input', { bubbles: true }));
  document.querySelector("[data-testid='settingsDetailSave']").click();
}

const delay = () => {
  return new Promise(res => setTimeout(res, delayMs));
};

keywords.reduce(async (prev, keyword) => {
  await prev;
  document.querySelector("a[href='/settings/add_muted_keyword']").click();
  await delay();
  addMutedKeyword(keyword);
  return delay();
}, Promise.resolve());

also works on Safari.

thx for this
@freedmand :)

@apervola
Copy link

great work, much appreciated !

@superherointj
Copy link

Thanks!

@vish0l
Copy link

vish0l commented Jan 25, 2020

thanks

@digisavvy
Copy link

@freedmand's code worked in my case. +1 would buy again! Where can I send a few bucks for you to get a beverage?

@doctoraw
Copy link

Thanks ! 🌈

@evandrix
Copy link

👍

@madaboutcode
Copy link

madaboutcode commented Jan 25, 2020

The fixed delay in the code was not working all the time for me. So I added a wait until the add page returns before clicking on the add button again.

(function(){
  const delayMs = 500; 

  const keywords = `ActivityTweet
  generic_activity_highlights
  generic_activity_momentsbreaking
  RankedOrganicTweet
  suggest_activity
  suggest_activity_feed
  suggest_activity_highlights
  suggest_activity_tweet
  suggest_grouped_tweet_hashtag
  suggest_pyle_tweet
  suggest_ranked_organic_tweet
  suggest_ranked_timeline_tweet
  suggest_recap
  suggest_recycled_tweet
  suggest_recycled_tweet_inline
  suggest_sc_tweet
  suggest_timeline_tweet
  suggest_who_to_follow
  suggestactivitytweet
  suggestpyletweet
  suggestrecycledtweet_inline`.split(/\W+/);

  const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;

  const addMutedKeyword = keyword => {
    const input = document.querySelector("[name='keyword']");
    nativeInputValueSetter.call(input, keyword);
    input.dispatchEvent(new Event('input', { bubbles: true }));
    document.querySelector("[data-testid='settingsDetailSave']").click();
  }

  const delay = () => {
    return new Promise(res => setTimeout(res, delayMs));
  };

  keywords.reduce(async (prev, keyword) => {
    await prev;
    
    // wait till the browser returns to the initial screen before clicking the add button again. 
    while(window.location.href !== 'https://twitter.com/settings/muted_keywords'){
      await delay();
    }
    document.querySelector("a[href='/settings/add_muted_keyword']").click();
    await delay();
    addMutedKeyword(keyword);
    return delay();
  }, Promise.resolve());
            
})()

@julianwieg
Copy link

thank you!

@paaandy
Copy link

paaandy commented Jan 25, 2020

YES thank you so much, always thought it an assault to force my eyes to read that stuff

@mjy
Copy link

mjy commented Jan 25, 2020

@TylerBussel - I think you're right, this does nothing, maybe @IanColdwater can edit this gist so this is not burried.

I had been playing with uBlockOrigin settings at the same time as I was playing with these, and going back and replicating, even taking some time to see if things took a while to take effect- I can't see any effect/replicate what I initially saw. And there is this:

https://twitter.com/TwitterSupport/status/1220872428605317122

Though if you read carefully there is wiggle room- they may have some other effect, but that seems to be grasping at straws.

But, until we get proof (screenshots(?)), this is bogus.

@joshdance
Copy link

I doubt this does anything.

Direct quote from Twitter "Hi Ian, muting these keywords won't actually change the number of suggested Tweets in your timeline. We are exploring ways to improve suggestions to allow you to further customize your timeline. More to come!" source - https://twitter.com/TwitterSupport/status/1220872428605317122

Reason is none of these words actually appear in the tweet body. It is not 'mute meta data about tweets' it is 'mute words' which presumably only are in the tweet body.

@Nerjuz
Copy link

Nerjuz commented Jan 27, 2020

❤️

@GuillaumeRossolini
Copy link

To the people for whom this didn't work: try switching your timeline back to chronological (instead of popular, or however it is called).
@TylerBussel @ronaldKM98 @mjy @joshdance

@heygambo
Copy link

This seems interesting but I'm not 100% sure what it does 😅

@horvaro
Copy link

horvaro commented Jan 27, 2020

❤️

The fixed delay in the code was not working all the time for me. So I added a wait until the add page returns before clicking on the add button again.

(function(){
  const delayMs = 500; 

  const keywords = `ActivityTweet
  generic_activity_highlights
  generic_activity_momentsbreaking
  RankedOrganicTweet
  suggest_activity
  suggest_activity_feed
  suggest_activity_highlights
  suggest_activity_tweet
  suggest_grouped_tweet_hashtag
  suggest_pyle_tweet
  suggest_ranked_organic_tweet
  suggest_ranked_timeline_tweet
  suggest_recap
  suggest_recycled_tweet
  suggest_recycled_tweet_inline
  suggest_sc_tweet
  suggest_timeline_tweet
  suggest_who_to_follow
  suggestactivitytweet
  suggestpyletweet
  suggestrecycledtweet_inline`.split(/\W+/);

  const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;

  const addMutedKeyword = keyword => {
    const input = document.querySelector("[name='keyword']");
    nativeInputValueSetter.call(input, keyword);
    input.dispatchEvent(new Event('input', { bubbles: true }));
    document.querySelector("[data-testid='settingsDetailSave']").click();
  }

  const delay = () => {
    return new Promise(res => setTimeout(res, delayMs));
  };

  keywords.reduce(async (prev, keyword) => {
    await prev;
    
    // wait till the browser returns to the initial screen before clicking the add button again. 
    while(window.location.href !== 'https://twitter.com/settings/muted_keywords'){
      await delay();
    }
    document.querySelector("a[href='/settings/add_muted_keyword']").click();
    await delay();
    addMutedKeyword(keyword);
    return delay();
  }, Promise.resolve());
            
})()

@jimaldon
Copy link

Does this also work on the twitter android client?

@TylerBussell
Copy link

@TylerBussel - I think you're right, this does nothing, maybe @IanColdwater can edit this gist so this is not burried.

I had been playing with uBlockOrigin settings at the same time as I was playing with these, and going back and replicating, even taking some time to see if things took a while to take effect- I can't see any effect/replicate what I initially saw. And there is this:

https://twitter.com/TwitterSupport/status/1220872428605317122

Though if you read carefully there is wiggle room- they may have some other effect, but that seems to be grasping at straws.

But, until we get proof (screenshots(?)), this is bogus.

This has come up several times in the past. We made some changes to the timeline settings + someone released a JS plugin that did some blocking, so it caused some confusion and people thought muting via keyword mute did something.

@am1983
Copy link

am1983 commented Jan 27, 2020

Not all heroes where capes.

@stevetemp7
Copy link

Worked for me. Made twitter usable. Thanks.

@davidawad
Copy link

@madaboutcode's thing worked for me. Thanks!

@maxclark
Copy link

maxclark commented Feb 1, 2020

👏

@heygambo
Copy link

What does this do exactly?

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