Last active
August 14, 2025 21:23
-
-
Save zImPatrick/f7108000136bb3705cb816acfc0c7170 to your computer and use it in GitHub Desktop.
override twitter feature flags
This file contains hidden or 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 FeatureFlipper | |
| // @namespace https://patriick.dev | |
| // @match https://x.com/* | |
| // @grant none | |
| // @version 1.0 | |
| // @author patriick.dev | |
| // @run-at document-body | |
| // ==/UserScript== | |
| const FEATURE_OVERRIDES = { | |
| // for chaos mode to work correctly | |
| "spaces_conference_enabled": false, | |
| "spaces_conference_opus_dtx_enabled": false, | |
| // bypass age assurance flow | |
| "rweb_age_assurance_flow_enabled": false, | |
| // auto translate posts | |
| "responsive_web_grok_show_grok_translated_post": true | |
| }; | |
| // flips every Boolean switch to true | |
| // before changing this to true: things will break | |
| // and you'll probably need to override some of their | |
| // source code yourself | |
| const CHAOS_MODE = false; | |
| const mutateState = () => { | |
| try { | |
| if (CHAOS_MODE) { | |
| for (const featureKey in _actualState.featureSwitch.user.config) { | |
| const obj = _actualState.featureSwitch.user.config[featureKey]; | |
| if (typeof obj.value == "boolean") obj.value = true; | |
| } | |
| } | |
| for (const [key, value] of Object.entries(FEATURE_OVERRIDES)) { | |
| _actualState.featureSwitch.user.config[key].value = value; | |
| } | |
| } catch (e) { | |
| console.error("[FeatureFlipper] failed flipping switches!", e); | |
| } | |
| }; | |
| // there are cases where we loose the race, so set the initial value | |
| let _actualState = window.__INITIAL_STATE__; | |
| Object.defineProperty(window, "__INITIAL_STATE__", { | |
| get() { | |
| return _actualState; | |
| }, | |
| set(s) { | |
| _actualState = s; | |
| window.state = _actualState; | |
| mutateState(); | |
| return s; | |
| }, | |
| configurable: true | |
| }); | |
| if (_actualState != null) mutateState(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment