Skip to content

Instantly share code, notes, and snippets.

@Vocaned
Last active October 26, 2025 21:29
Show Gist options
  • Select an option

  • Save Vocaned/be68a3926bef82b8c9ec01071ed3525a to your computer and use it in GitHub Desktop.

Select an option

Save Vocaned/be68a3926bef82b8c9ec01071ed3525a to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Youtube Experiment Overrides
// @version 1.1.0
// @description Generic experiment override userscript, configurable via script storage.
// @author voc
// @namespace https://github.com/Vocaned
// @match https://www.youtube.com/*
// @grant GM_getValue
// @grant GM_setValue
// @grant unsafeWindow
// @run-at document-start
// @downloadURL https://gist.github.com/Vocaned/be68a3926bef82b8c9ec01071ed3525a/raw/youtube-experiment-overrides.user.js
// @require https://raw.githubusercontent.com/cyfung1031/userscript-supports/e0f448b8865a96e59f673d481cde2583295123ad/library/ytConfigHacks.js#sha256=fEp1NkJ5HYRTPVSDqcHXKDReJTaGTuMUOFFqXs1hJ/w=
// ==/UserScript==
// Usage:
// Violentmonkey (preferred): Edit experiments in the "values" tab of the script.
// Others: Set the overrides you want from the console using `experimentOverrides = { "web_frosted_glass": false, }`. Set to null to reset to defaults.
(() => {
const STORAGE_KEY = 'ytExperimentOverrides';
const DEFAULT_OVERRIDES = {
"web_player_use_screen_width_for_big_mode": false,
"delhi_modern_web_player": false,
"delhi_modern_web_player_icons": false,
"enable_web_delhi_icons": false
};
if (GM_getValue(STORAGE_KEY, null) === null) GM_setValue(STORAGE_KEY, DEFAULT_OVERRIDES);
Object.defineProperty(unsafeWindow, 'experimentOverrides', {
get: () => {
return GM_getValue(STORAGE_KEY, null) || DEFAULT_OVERRIDES;
},
set: (newValue) => {
if (typeof newValue !== "object") { console.log('[YT Overrides] Invalid input. Must be a valid JSON object or null to reset.'); return; }
GM_setValue(STORAGE_KEY, newValue);
if (newValue === null) console.log('[YT Overrides] Overrides reset to default. Reload the page to apply.');
else console.log('[YT Overrides] Overrides set. Reload the page to apply.');
},
enumerable: true
});
let patchLogged = false;
unsafeWindow._ytConfigHacks.add((config_) => {
for (const [experimentKey, experimentValue] of Object.entries(unsafeWindow.experimentOverrides)) {
config_.EXPERIMENT_FLAGS[experimentKey] = experimentValue;
}
const configs = config_.WEB_PLAYER_CONTEXT_CONFIGS || {};
for (const [key, entry] of Object.entries(configs)) {
if (entry && typeof entry.serializedExperimentFlags === 'string') {
const params = new URLSearchParams(entry.serializedExperimentFlags);
for (const [experimentKey, experimentValue] of Object.entries(unsafeWindow.experimentOverrides)) {
params.set(experimentKey, experimentValue);
}
entry.serializedExperimentFlags = decodeURIComponent(params.toString().replace("+", " "));
}
}
if (!patchLogged) {
console.log('[YT Overrides] Patched experiments with overrides:', unsafeWindow.experimentOverrides);
patchLogged = true;
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment