YouTube Web Tweaks

It speeds up YouTube by 50% by modified configs, redirect shorts, etc...

目前為 2023-01-14 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         YouTube Web Tweaks
// @version      2.5.1
// @description  It speeds up YouTube by 50% by modified configs, redirect shorts, etc...
// @author       Magma_Craft
// @license MIT
// @match        https://www.youtube.com/*
// @namespace    https://greatest.deepsurf.us/en/users/933798
// @icon         https://www.youtube.com/favicon.ico
// @unwrap
// @run-at document-start
// @grant        none
// ==/UserScript==

// Modifiying yt.config flags to optimize loading times and disables animations
(function() {
    window['yt'] = window['yt'] || {};
    yt['config_'] = yt.config_ || {};
    yt.config_['EXPERIMENT_FLAGS'] = yt.config_.EXPERIMENT_FLAGS || {};

    var iv = setInterval(function() {
        yt.config_.IS_TABLET = true;
        yt.config_.DISABLE_YT_IMG_DELAY_LOADING = true;
        yt.config_.EXPERIMENT_FLAGS.polymer_verifiy_app_state = false;
        yt.config_.EXPERIMENT_FLAGS.warm_load_nav_start_web = false;
        yt.config_.EXPERIMENT_FLAGS.kevlar_player_response_swf_config_wrapper_killswitch = false;
        yt.config_.EXPERIMENT_FLAGS.desktop_player_touch_gestures = false;
        yt.config_.EXPERIMENT_FLAGS.web_animated_like = false;
        yt.config_.EXPERIMENT_FLAGS.web_animated_like_lazy_load = false;
        yt.config_.EXPERIMENT_FLAGS.render_unicode_emojis_as_small_images = true;
        yt.config_.EXPERIMENT_FLAGS.kevlar_refresh_on_theme_change = false;
        yt.config_.EXPERIMENT_FLAGS.kevlar_watch_cinematics = false
        yt.config_.EXPERIMENT_FLAGS.kevlar_watch_comments_panel_button = true;
        yt.config_.EXPERIMENT_FLAGS.kevlar_watch_hide_comments_while_panel_open = true;
        yt.config_.EXPERIMENT_FLAGS.kevlar_watch_comments_ep_disable_theater = false;
    }, 1);

    var to = setTimeout(function() {
        clearInterval(iv);
    }, 1000)
})();

/* Redirect shorts to watch page */
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);
};

// CSS adjustments and other tweaks to apply
(function() {
ApplyCSS();

function ApplyCSS() {
var styles = document.createElement("style");
styles.innerHTML=`
/* Remove Learning, Fashion and Podcasts */
ytd-guide-entry-renderer > a[href*="/channel/UCrpQ4p1Ql_hG8rKXIKM1MOQ"] {
display: none !important;
}
ytd-guide-entry-renderer > a[href*="/channel/UCtFRv9O2AHqOZjjynzrv-xg"] {
display: none !important;
}
#endpoint.yt-simple-endpoint.ytd-guide-entry-renderer.style-scope[title="Podcasts"] {
display: none !important;
}

/* Remove everything from "More from YouTube" tab (excluding Premium) */
#endpoint.yt-simple-endpoint.ytd-guide-entry-renderer.style-scope[title="Creator Studio"] {
display: none !important;
}
#endpoint.yt-simple-endpoint.ytd-guide-entry-renderer.style-scope[title="YouTube Music"] {
display: none !important;
}
#endpoint.yt-simple-endpoint.ytd-guide-entry-renderer.style-scope[title="YouTube Kids"] {
display: none !important;
}
#endpoint.yt-simple-endpoint.ytd-guide-entry-renderer.style-scope[title="YouTube TV"] {
display: none !important;
}`
document.head.appendChild(styles);
}
})();

var interval = setInterval(function() {
    window.wrappedJSObject._lact = Date.now();
}, 300000);