Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Fixes for CSS version of the non-rounded design
- // @version 20240424.18.10
- // @description This userscript will fix issues with the CSS version of the non-rounded design. It also includes shorts redirect and the return of the explore tab.
- // @author Magma_Craft
- // @license MIT
- // @match https://www.youtube.com/*
- // @namespace https://greasyfork.org/en/users/933798
- // @icon https://www.youtube.com/favicon.ico
- // @run-at document-end
- // @grant none
- // ==/UserScript==
- (function() {
- window['yt'] = window['yt'] || {};
- yt['config_'] = yt.config_ || {};
- yt.config_['EXPERIMENT_FLAGS'] = yt.config_.EXPERIMENT_FLAGS || {};
- var iv = setInterval(function() {
- yt.config_.EXPERIMENT_FLAGS.kevlar_refresh_on_theme_change = false;
- yt.config_.EXPERIMENT_FLAGS.kevlar_watch_cinematics = false;
- yt.config_.EXPERIMENT_FLAGS.kevlar_watch_grid = false;
- yt.config_.EXPERIMENT_FLAGS.kevlar_watch_grid_hide_chips = false;
- yt.config_.EXPERIMENT_FLAGS.kevlar_watch_metadata_refresh_no_old_secondary_data = false;
- yt.config_.EXPERIMENT_FLAGS.enable_channel_page_header_profile_section = false;
- yt.config_.EXPERIMENT_FLAGS.kevlar_modern_sd_v2 = false;
- yt.config_.EXPERIMENT_FLAGS.kevlar_watch_comments_panel_button = false;
- yt.config_.EXPERIMENT_FLAGS.smartimation_background = false;
- yt.config_.EXPERIMENT_FLAGS.web_animated_actions = false;
- yt.config_.EXPERIMENT_FLAGS.web_animated_like = false;
- yt.config_.EXPERIMENT_FLAGS.web_animated_like_lazy_load = false;
- yt.config_.EXPERIMENT_FLAGS.web_modern_collections_v2 = false;
- yt.config_.EXPERIMENT_FLAGS.web_modern_tabs = false;
- yt.config_.EXPERIMENT_FLAGS.web_modern_typography = false;
- yt.config_.EXPERIMENT_FLAGS.web_enable_youtab = false;
- yt.config_.EXPERIMENT_FLAGS.web_watch_rounded_player_large = false
- // Extra additions to remove the watch grid UI
- yt.config_.EXPERIMENT_FLAGS.web_player_enable_featured_product_banner_exclusives_on_desktop = false,
- yt.config_.EXPERIMENT_FLAGS.kevlar_watch_comments_panel_button = false,
- yt.config_.EXPERIMENT_FLAGS.fill_view_models_on_web_vod = true,
- yt.config_.EXPERIMENT_FLAGS.kevlar_watch_flexy_metadata_height = 136,
- yt.config_.EXPERIMENT_FLAGS.kevlar_watch_max_player_width = 1280,
- yt.config_.EXPERIMENT_FLAGS.live_chat_over_engagement_panels = false,
- yt.config_.EXPERIMENT_FLAGS.live_chat_scaled_height = false,
- yt.config_.EXPERIMENT_FLAGS.live_chat_smaller_min_height = false,
- yt.config_.EXPERIMENT_FLAGS.main_app_controller_extraction_batch_18 = false,
- yt.config_.EXPERIMENT_FLAGS.main_app_controller_extraction_batch_19 = false,
- yt.config_.EXPERIMENT_FLAGS.no_iframe_for_web_stickiness = false,
- yt.config_.EXPERIMENT_FLAGS.optimal_reading_width_comments_ep = false,
- yt.config_.EXPERIMENT_FLAGS.remove_masthead_channel_banner_on_refresh = false,
- yt.config_.EXPERIMENT_FLAGS.small_avatars_for_comments = false,
- yt.config_.EXPERIMENT_FLAGS.small_avatars_for_comments_ep = false,
- yt.config_.EXPERIMENT_FLAGS.web_watch_compact_comments = false,
- yt.config_.EXPERIMENT_FLAGS.web_watch_compact_comments_header = false,
- yt.config_.EXPERIMENT_FLAGS.web_watch_log_theater_mode = false,
- yt.config_.EXPERIMENT_FLAGS.web_watch_theater_chat = false,
- yt.config_.EXPERIMENT_FLAGS.web_watch_theater_fixed_chat = false,
- yt.config_.EXPERIMENT_FLAGS.wn_grid_max_item_width = 0,
- yt.config_.EXPERIMENT_FLAGS.wn_grid_min_item_width = 0
- }, 1);
- var to = setTimeout(function() {
- clearInterval(iv);
- }, 1000)
- })();
- // Shorts URL redirect
- var oldHref = document.location.href;
- if (window.location.href.indexOf('youtube.com/shorts') > -1) {
- window.location.replace(window.location.toString().replace('/shorts/', '/watch?v='));
- }
- window.onload = function() {
- var bodyList = document.querySelector("body")
- var observer = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- if (oldHref != document.location.href) {
- oldHref = document.location.href;
- console.log('location changed!');
- if (window.location.href.indexOf('youtube.com/shorts') > -1) {
- window.location.replace(window.location.toString().replace('/shorts/', '/watch?v='));
- }
- }
- });
- });
- var config = {
- childList: true,
- subtree: true
- };
- observer.observe(bodyList, config);
- };
- //Re-add 'Explore' tab from the sidebar menu
- function waitForElm(selector) {
- return new Promise(resolve => {
- if (document.querySelector(selector)) {
- return resolve(document.querySelector(selector));
- }
- const observer = new MutationObserver(mutations => {
- if (document.querySelector(selector)) {
- resolve(document.querySelector(selector));
- observer.disconnect();
- }
- });
- observer.observe(document.body, {
- childList: true,
- subtree: true
- });
- });
- }
- function restoreTrending() {
- var trendingData = {
- "navigationEndpoint": {
- "clickTrackingParams": "CBwQtSwYASITCNqYh-qO_fACFcoRrQYdP44D9Q==",
- "commandMetadata": {
- "webCommandMetadata": {
- "url": "/feed/explore",
- "webPageType": "WEB_PAGE_TYPE_BROWSE",
- "rootVe": 6827,
- "apiUrl": "/youtubei/v1/browse"
- }
- },
- "browseEndpoint": {
- "browseId": "FEtrending"
- }
- },
- "icon": {
- "iconType": "EXPLORE"
- },
- "trackingParams": "CBwQtSwYASITCNqYh-qO_fACFcoRrQYdP44D9Q==",
- "formattedTitle": {
- "simpleText": "Explore"
- },
- "accessibility": {
- "accessibilityData": {
- "label": "Explore"
- }
- },
- "isPrimary": true
- };
- var guidetemplate = `<ytd-guide-entry-renderer class="style-scope ytd-guide-section-renderer" is-primary="" line-end-style="none"><!--css-build:shady--><a id="endpoint" class="yt-simple-endpoint style-scope ytd-guide-entry-renderer" tabindex="-1" role="tablist"><tp-yt-paper-item role="tab" class="style-scope ytd-guide-entry-renderer" tabindex="0" aria-disabled="false"><!--css-build:shady--><yt-icon class="guide-icon style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-icon><yt-img-shadow height="24" width="24" class="style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-img-shadow><yt-formatted-string class="title style-scope ytd-guide-entry-renderer"><!--css-build:shady--></yt-formatted-string><span class="guide-entry-count style-scope ytd-guide-entry-renderer"></span><yt-icon class="guide-entry-badge style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-icon><div id="newness-dot" class="style-scope ytd-guide-entry-renderer"></div></tp-yt-paper-item></a><yt-interaction class="style-scope ytd-guide-entry-renderer"><!--css-build:shady--><div class="stroke style-scope yt-interaction"></div><div class="fill style-scope yt-interaction"></div></yt-interaction></ytd-guide-entry-renderer>`;
- document.querySelector(`#items > ytd-guide-entry-renderer:nth-child(2)`).data = trendingData;
- var miniguidetemplate = `<ytd-mini-guide-entry-renderer class="style-scope ytd-mini-guide-section-renderer" is-primary="" line-end-style="none"><!--css-build:shady--><a id="endpoint" class="yt-simple-endpoint style-scope ytd-guide-entry-renderer" tabindex="-1" role="tablist"><tp-yt-paper-item role="tab" class="style-scope ytd-guide-entry-renderer" tabindex="0" aria-disabled="false"><!--css-build:shady--><yt-icon class="guide-icon style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-icon><yt-img-shadow height="24" width="24" class="style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-img-shadow><yt-formatted-string class="title style-scope ytd-guide-entry-renderer"><!--css-build:shady--></yt-formatted-string><span class="guide-entry-count style-scope ytd-guide-entry-renderer"></span><yt-icon class="guide-entry-badge style-scope ytd-guide-entry-renderer" disable-upgrade=""></yt-icon><div id="newness-dot" class="style-scope ytd-guide-entry-renderer"></div></tp-yt-paper-item></a><yt-interaction class="style-scope ytd-guide-entry-renderer"><!--css-build:shady--><div class="stroke style-scope yt-interaction"></div><div class="fill style-scope yt-interaction"></div></yt-interaction></ytd-guide-entry-renderer>`;
- document.querySelector(`#items > ytd-mini-guide-entry-renderer:nth-child(2)`).data = trendingData;
- }
- waitForElm("#items.ytd-guide-section-renderer").then((elm) => {
- restoreTrending();
- });
- waitForElm("#items.ytd-mini-guide-section-renderer").then((elm) => {
- restoreTrending();
- });
- // Include the watch action buttons fix script that issued on older browsers
- const abtnconfig = {
- unsegmentLikeButton: false,
- noFlexibleItems: true
- };
- function updateBtns() {
- var watchFlexy = document.querySelector("ytd-watch-flexy");
- var results = watchFlexy.data.contents.twoColumnWatchNextResults.results.results.contents;
- for (var i = 0; i < results.length; i++) {
- if (results[i].videoPrimaryInfoRenderer) {
- var actions = results[i].videoPrimaryInfoRenderer.videoActions.menuRenderer;
- if (abtnconfig.unsegmentLikeButton) {
- if (actions.topLevelButtons[0].segmentedLikeDislikeButtonRenderer) {
- var segmented = actions.topLevelButtons[0].segmentedLikeDislikeButtonRenderer;
- actions.topLevelButtons.splice(0, 1);
- actions.topLevelButtons.unshift(segmented.dislikeButton);
- actions.topLevelButtons.unshift(segmented.likeButton);
- }
- }
- if (abtnconfig.noFlexibleItems) {
- for (var i = 0; i < actions.flexibleItems.length; i++) {
- actions.topLevelButtons.push(actions.flexibleItems[i].menuFlexibleItemRenderer.topLevelButton);
- }
- delete actions.flexibleItems
- }
- }
- }
- var temp = watchFlexy.data;
- watchFlexy.data = {};
- watchFlexy.data = temp;
- }
- document.addEventListener("yt-page-data-updated", (e) => {
- if (e.detail.pageType == "watch") {
- updateBtns();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement