Skip to content

Commit

Permalink
YouTubeExperiments #2251 proxying the prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
ImprovedTube committed Aug 9, 2024
1 parent e8c6371 commit 2eb52c0
Showing 1 changed file with 39 additions and 29 deletions.
68 changes: 39 additions & 29 deletions js&css/web-accessible/www.youtube.com/appearance.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
/*------------------------------------------------------------------------------
APPEARANCE
------------------------------------------------------------------------------*/
ImprovedTube.YouTubeExperiments = function () { if (document.documentElement.dataset.pageType === 'video' && window.yt?.config_?.EXPERIMENT_FLAGS) {
ImprovedTube.overrideFlags = function (flags, value) {
yt.config_.EXPERIMENT_FLAGS = new Proxy(yt.config_.EXPERIMENT_FLAGS, {
get: (t, p) => flags.includes(p) ? value : t[p], //target & prop
set: () => true
});
};
if (this.storage.undo_the_new_sidebar && yt.config_.EXPERIMENT_FLAGS.kevlar_watch_grid !== false ) {
try {
ImprovedTube.overrideFlags(
['kevlar_watch_grid', 'small_avatars_for_comments', 'small_avatars_for_comments_ep', 'web_watch_rounded_player_large'],
false
);
} catch (error) { console.error("can't undo description on the side", error); }
};
if (this.storage.description === "sidebar" && yt.config_.EXPERIMENT_FLAGS.kevlar_watch_grid !== true ) {
try {
ImprovedTube.overrideFlags(
['kevlar_watch_grid', 'small_avatars_for_comments', 'small_avatars_for_comments_ep', 'web_watch_rounded_player_large'],
true
);
} catch (error) { console.error("tried to move description to the sidebar", error); }
};
}}
/* if (document.documentElement.dataset.pageType === 'video' && window.yt?.config_?.EXPERIMENT_FLAGS) {
['kevlar_watch_grid', 'small_avatars_for_comments', 'small_avatars_for_comments_ep', 'web_watch_rounded_player_large'].forEach(flag => {
Object.defineProperty(yt.config_.EXPERIMENT_FLAGS, flag, { get: () => false });
});
}
ImprovedTube.YouTubeExperiments = function () {
if (document.documentElement.dataset.pageType === 'video' && window.yt?.config_?.EXPERIMENT_FLAGS) {
ImprovedTube.overrideFlag = function (flag, value) {
const target = Object.getPrototypeOf(window.yt.config_.EXPERIMENT_FLAGS);
const handler = {
get: (t, p) => p === flag ? value : t[p], // Target specific flag
set: () => true
};
if (!Object.getOwnPropertyDescriptor(window.yt.config_.EXPERIMENT_FLAGS, flag)) {
window.yt.config_.EXPERIMENT_FLAGS[flag] = new Proxy(target, handler);
}
};
const newSidebarFlags = [
'kevlar_watch_grid',
'small_avatars_for_comments',
'small_avatars_for_comments_ep',
'web_watch_rounded_player_large'
];
if (this.storage.undo_the_new_sidebar && yt.config_.EXPERIMENT_FLAGS.kevlar_watch_grid !== false) {
try {
newSidebarFlags.forEach(flag => {
ImprovedTube.overrideFlag(flag, false);
});
} catch (error) {
console.error("can't undo description on the side", error);
}
};

if (this.storage.description === "sidebar" && yt.config_.EXPERIMENT_FLAGS.kevlar_watch_grid !== true) {
try {
newSidebarFlags.forEach(flag => {
ImprovedTube.overrideFlag(flag, true);
});
} catch (error) {
console.error("tried to move description to the sidebar", error);
}
};
}
}
*/
/*try {
yt.config_.EXPERIMENT_FLAGS.kevlar_watch_grid = false;
Expand Down

0 comments on commit 2eb52c0

Please sign in to comment.