Last active
December 13, 2023 20:44
-
-
Save busybox11/d0530e396bd4597a62587032ee55d214 to your computer and use it in GitHub Desktop.
Bring back Twitter's Close Friends feature
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
// ==UserScript== | |
// @name Bring back close friends - twitter.com | |
// @namespace twitter scripts | |
// @match *://*.twitter.com/* | |
// @run-at document-start | |
// @grant none | |
// @version 1.2 | |
// @author @busybox11 | |
// @description 11/3/2023, 1:12:10 AM | |
// @updateURL https://gist.githubusercontent.com/busybox11/d0530e396bd4597a62587032ee55d214/raw | |
// @downloadURL https://gist.githubusercontent.com/busybox11/d0530e396bd4597a62587032ee55d214/raw | |
// ==/UserScript== | |
// v1.1 - Use already existing __INITIAL_STATE__ if possible | |
// v1.2 - Also mutate __INITIAL_STATE__ on get | |
/* | |
* INSTRUCTIONS | |
* | |
* - Install a userscript browser extension | |
* (I used ViolentMonkey https://chrome.google.com/webstore/detail/violentmonkey/jinjaccalgkegednnccohejagnlnfdag, | |
* but you can use any extension you want, such as tampermonkey, it should work fine) | |
* FIREFOX USERS: It seems to work better with TamperMonkey: https://addons.mozilla.org/fr/firefox/addon/tampermonkey/ | |
* - Import the script | |
* On ViolentMonkey, click on the extension icon, then gear icon (Open dashboard) | |
* There should be a plus icon on the top left hand corner, click on it and select Install from URL | |
* Use this URL: https://gist.githubusercontent.com/busybox11/d0530e396bd4597a62587032ee55d214/raw | |
* It should now work and update by itself | |
* | |
*/ | |
// DISCLAIMER: Script heavily inspired by @d1mden's OldTwitter extension | |
// which convinced me something like this was possible. | |
// I was already kind of convinced it was because I managed to make a | |
// manual request from an unupdated client I had offline that I analyzed | |
// though dimden's extension gave me the motivation to actually do | |
// something. | |
// | |
// This was also made possible by hours of digging through Twitter's | |
// source code and feature flags, which at the end of the day are kind of | |
// convenient to work with - see the (surprisingly) small amount of code | |
// below. | |
// YOU'RE FREE TO DO WHATEVER YOU WANT WITH THIS SCRIPT BUT IF YOU DO MAKE SOMETHING | |
// PLEASE MAKE SURE TO MENTION ME SOMEWHERE - I hope you'll understand why :) | |
// Also https://paypal.me/busybox11 because I am (still) broke | |
let __TMP_INITIAL_STATE__ = window.__INITIAL_STATE__ ?? {}; | |
const mutateState = (state) => { | |
state.featureSwitch.user.config = { | |
...state.featureSwitch.user.config, | |
...{ | |
trusted_friends_dash_discovery_enabled: { value: true }, | |
trusted_friends_tweet_creation_enabled: { value: true } | |
} | |
}; | |
return state; | |
}; | |
Object.defineProperty(window, "__INITIAL_STATE__", { | |
get: () => { | |
return mutateState(__TMP_INITIAL_STATE__); | |
}, | |
set: (newData) => { | |
__TMP_INITIAL_STATE__ = mutateState(newData); | |
}, | |
configurable: true, | |
}); |
also if you copy the contents of featureSwitch.user.config into featureSwitch.debug you get the feature switches settings on your settings menu
window.__INITIAL_STATE__.featureSwitch.debug = Object.assign({}, value.featureSwitch.user.config);
i forget the exact name but something card compact layout to false sets the embed cards back to normal
they already fixed it
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
document.cookie="ab_decider=trusted_friends_consumption_enabled=true&trusted_friends_tweet_creation_enabled=true";