Optimizes YouTube performance without breaking UI elements
// ==UserScript==
// @name YouTube Performance Booster (Fixed UI)
// @version 2.1
// @description Optimizes YouTube performance without breaking UI elements
// @author HYPERR.
// @match *://*.youtube.com/*
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @run-at document-start
// @license MIT
// @namespace https://greasyfork.org/users/1476487
// ==/UserScript==
(function() {
'use strict';
// ===== SAFE CONFIGURATION =====
const settings = {
instantNavigation: true, // Smoother navigation
disableAnimations: true, // Disable UI animations
qualityPreset: 'auto', // Video quality (auto, 1080p, 720p etc)
hideShorts: true // Only hides Shorts shelf
};
// ===== SAFE CSS INJECTION =====
GM_addStyle(`
/* Animation removal (safe) */
[no-animations] * {
transition: none !important;
animation: none !important;
}
/* Non-destructive hiding */
[hide-shorts] ytd-rich-section-renderer {
display: none !important;
}
/* Layout-safe optimizations */
html {
scroll-behavior: auto !important;
}
`);
// Apply settings
document.documentElement.setAttribute('no-animations', '');
if (settings.hideShorts) {
document.documentElement.setAttribute('hide-shorts', '');
}
// ===== SAFE PERFORMANCE OPTIMIZATIONS =====
function optimizePlayer() {
const player = document.querySelector('video');
if (player) {
player.addEventListener('canplay', function() {
try {
if (settings.qualityPreset !== 'auto') {
player.setPlaybackQuality(settings.qualityPreset);
}
} catch(e) { /* Fail silently */ }
});
}
}
// ===== SAFE INSTANT NAVIGATION =====
if (settings.instantNavigation) {
document.addEventListener('mouseover', function(e) {
const link = e.target.closest('a[href^="/watch"]');
if (link) {
const preload = document.createElement('link');
preload.rel = 'prefetch';
preload.href = link.href;
document.head.appendChild(preload);
}
}, {passive: true});
}
// Initialize
const observer = new MutationObserver(optimizePlayer);
observer.observe(document, {
childList: true,
subtree: true
});
window.addEventListener('load', optimizePlayer);
})();