Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clean up the Twitter timeline
// Visit https://twitter.com/settings/muted_keywords
// Open Developer tools console
// Paste and run the following code:
(async () => {
const keywords = `ActivityTweet
filter:follows -filter:replies
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
tweet-context with-icn
who_to_follow_entry`;
const delay = (f = 0.5) => new Promise((resolve) => setTimeout(resolve, f * 1000));
const setNativeValue = (element, value) => {
const prototypeValueSetter = Object.getOwnPropertyDescriptor(
Object.getPrototypeOf(element),
"value"
).set;
prototypeValueSetter.call(element, value);
};
await keywords
.split(/\n/)
.reduce(async (previousPromise, keyword) => {
await previousPromise;
console.log({ keyword });
if (document.querySelector("[aria-live='assertive']") === null) {
document.querySelector("a[href='/settings/add_muted_keyword']").click();
await delay();
}
const inputEl = document.querySelector("input[name='keyword']");
setNativeValue(inputEl, keyword);
inputEl.dispatchEvent(new Event("input", { bubbles: true }));
await delay();
document.querySelector("[role='button'][data-testid='settingsDetailSave']").click();
return delay();
}, Promise.resolve());
console.log("Completed!");
})();
@ganta
Copy link
Author

ganta commented May 15, 2022

The following code was used as a reference:
https://gist.github.com/IanColdwater/88b3341a7c4c0cf71c73ac56f9bd36ec

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