YouTube Web Tweaks Lite

This script is based on YouTube Web Tweaks (except it keeps most stuff including shorts player)

目前為 2024-04-11 提交的版本,檢視 最新版本

// ==UserScript==
// @name         YouTube Web Tweaks Lite
// @version      1.5.0
// @description  This script is based on YouTube Web Tweaks (except it keeps most stuff including shorts player)
// @author       Magma_Craft
// @license MIT
// @match        *://www.youtube.com/*
// @namespace    https://gf.qytechs.cn/en/users/933798
// @icon         https://www.youtube.com/favicon.ico
// @unwrap
// @run-at       document-start
// @unwrap
// @grant        none
// ==/UserScript==
 
// Enable strict mode to catch common coding mistakes
"use strict";
 
// Define the flags to assign to the EXPERIMENT_FLAGS object
const flagsToAssign = {
  IS_TABLET: true,
  DISABLE_YT_IMG_DELAY_LOADING: true,
  polymer_verifiy_app_state: false,
  desktop_delay_player_resizing: false,
  web_animated_actions: false,
  web_animated_like: false,
  web_animated_like_lazy_load: false,
  render_unicode_emojis_as_small_images: true,
  kevlar_refresh_on_theme_change: false,
  kevlar_watch_cinematics: false,
  // More tweaks (Includes Watch layout fixes)
  web_player_enable_featured_product_banner_exclusives_on_desktop: false,
  kevlar_watch_comments_ep_disable_theater: true,
  kevlar_watch_comments_panel_button: true,
  fill_view_models_on_web_vod: true,
  kevlar_watch_flexy_metadata_height: 136,
  kevlar_watch_grid: false,
  kevlar_watch_max_player_width: 1280,
  live_chat_over_engagement_panels: false,
  live_chat_scaled_height: false,
  live_chat_smaller_min_height: false,
  main_app_controller_extraction_batch_18: false,
  main_app_controller_extraction_batch_19: false,
  no_iframe_for_web_stickiness: false,
  optimal_reading_width_comments_ep: false,
  remove_masthead_channel_banner_on_refresh: false,
  small_avatars_for_comments: false,
  small_avatars_for_comments_ep: false,
  web_watch_compact_comments: false,
  web_watch_compact_comments_header: false,
  web_watch_log_theater_mode: false,
  web_watch_theater_chat: false,
  web_watch_theater_fixed_chat: false,
  wn_grid_max_item_width: 0,
  wn_grid_min_item_width: 0
};
 
const updateFlags = () => {
  // Check if the EXPERIMENT_FLAGS object exists in the window.yt.config_ property chain
  const expFlags = window?.yt?.config_?.EXPERIMENT_FLAGS;
 
  // If EXPERIMENT_FLAGS is not found, exit the function
  if (!expFlags) return;
 
  // Assign the defined flags to the EXPERIMENT_FLAGS object
  Object.assign(expFlags, flagsToAssign);
};
 
// Create a MutationObserver that calls the updateFlags function when changes occur in the document's subtree
const mutationObserver = new MutationObserver(updateFlags);
mutationObserver.observe(document, { subtree: true, childList: true });
 
var styles = document.createElement("style");
styles.innerHTML=` 
/* Remove filter categories on search results and playlists to make the UI less usable on low-entry machines */
ytd-item-section-renderer.style-scope.ytd-section-list-renderer[page-subtype="playlist"] > #header.ytd-item-section-renderer > ytd-feed-filter-chip-bar-renderer {
display: none !important;
}
 
div#chip-bar.style-scope.ytd-search-header-renderer > yt-chip-cloud-renderer.style-scope.ytd-search-header-renderer > div#container.style-scope.yt-chip-cloud-renderer {
display: none !important;
}
 
/* Revert video list (aka compact right sidebar) */
ytd-watch-flexy #comment-teaser.ytd-watch-metadata {
  display: none;
}
 
ytd-watch-flexy #dismissible.ytd-rich-grid-media {
  flex-direction: row;
}
 
ytd-watch-flexy #attached-survey.ytd-rich-grid-media,
ytd-watch-flexy #avatar-link.ytd-rich-grid-media {
  display: none;
}
 
ytd-watch-flexy ytd-thumbnail.ytd-rich-grid-media,
ytd-watch-flexy ytd-playlist-thumbnail.ytd-rich-grid-media {
  margin-right: 8px;
  height: 94px;
  width: 168px;
}
 
ytd-watch-flexy ytd-thumbnail[size=large] a.ytd-thumbnail, ytd-watch-flexy ytd-thumbnail[size=large]:before {
  border-radius: 8px;
}
 
ytd-watch-flexy ytd-rich-item-renderer,
ytd-watch-flexy ytd-rich-grid-row #contents.ytd-rich-grid-row {
  margin: 0;
}
 
ytd-watch-flexy ytd-rich-item-renderer[reduced-bottom-margin] {
  margin-top: 8px;
  margin-bottom: 0;
}
 
ytd-watch-flexy ytd-rich-grid-renderer[reduced-top-margin] #contents.ytd-rich-grid-renderer {
  padding-top: 8px;
}
 
ytd-watch-flexy ytd-rich-grid-media {
  margin-bottom: 8px;
}
 
ytd-watch-flexy ytd-video-meta-block[rich-meta] #metadata-line.ytd-video-meta-block,
ytd-watch-flexy #channel-name.ytd-video-meta-block {
  font-family: "Roboto", "Arial", sans-serif;
  font-size: 1.2rem;
  line-height: 1.8rem;
  font-weight: 400;
}
 
ytd-watch-flexy #video-title.ytd-rich-grid-media {
  margin: 0 0 4px 0;
  display: block;
  font-family: "Roboto", "Arial", sans-serif;
  font-size: 1.4rem;
  line-height: 2rem;
  font-weight: 500;
  overflow: hidden;
  display: block;
  max-height: 4rem;
  -webkit-line-clamp: 2;
  display: box;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  white-space: normal;
}
 
ytd-watch-flexy h3.ytd-rich-grid-media {
  margin: 0;
}
 
ytd-watch-flexy .title-badge.ytd-rich-grid-media, ytd-watch-flexy .video-badge.ytd-rich-grid-media {
  margin-top: 0;
}
 
ytd-watch-flexy ytd-rich-section-renderer.style-scope.ytd-rich-grid-renderer {
  display: none;
}`;
document.head.appendChild(styles);
 
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);
};
 
Object.defineProperties(document, { /*'hidden': {value: false},*/ 'webkitHidden': {value: false}, 'visibilityState': {value: 'visible'}, 'webkitVisibilityState': {value: 'visible'} });
 
setInterval(function(){
    document.dispatchEvent( new KeyboardEvent( 'keyup', { bubbles: true, cancelable: true, keyCode: 143, which: 143 } ) );
}, 60000);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址