YouTube Highest Quality on Fullscreen

Set YouTube video to highest available resolution when entering fullscreen (e.g. 4K, 1440p, 1080p, etc.)

< 脚本 YouTube Highest Quality on Fullscreen 的反馈

评价:好评 - 脚本运行良好

§
发布于:2025-09-25

Is there a tweak on my or your end to choose the quality? Most videos I watch can go up to like 1080p60+, but I just want 720p60.

r280822a作者
§
发布于:2025-10-01

Update to latest version and replace "const ignoredQualities = [];" line with "const ignoredQualities = ['2160p60','2160p','1440p60','1440p','1080p60','1080p'];"

§
发布于:2025-10-11

I really appreciate you doing this, but I can't get it to work? It didn't work before the update for me either. I asked the question before trying it out. I'm using GreaseMonkey on Firefox. Please let me know if you need any more info from me. Thank you for all your work and sharing this <3

r280822a作者
§
发布于:2025-10-11

Could switch to tampermonkey but if you want it to work for greasemonkey try copy/pasting this instead:


// ==UserScript==
// @name         YouTube Highest Quality on Fullscreen
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  Set YouTube video to highest available resolution when entering fullscreen (e.g. 4K, 1440p, 1080p, etc.)
// @author       Rehan Ahmad
// @match        https://www.youtube.com/*
// @icon         https://raw.githubusercontent.com/r280822a/YouTube-Highest-Quality-Fullscreen/refs/heads/main/icon/icon.png
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const script = document.createElement('script');
    script.textContent = '(' + function () {
        function showToast(message) {
            let toast = document.querySelector('tp-yt-paper-toast#fullscreen-quality-toast');
            if (toast) { // Delete if still visible to avoid unnecessary queueing
                toast.remove();
            }

            toast = document.createElement('tp-yt-paper-toast');
            toast.id = 'fullscreen-quality-toast'
            toast.innerText = message;
            document.body.appendChild(toast);

            toast.show();
        }

        function setHighestQuality() {
            if (!document.fullscreenElement) return;
            const player = document.getElementById('movie_player');
            if (!player) return;

            let qualityData = player.getAvailableQualityData?.();
            const currentQuality = player.getPlaybackQuality?.();

            // Full list of all qualities: ['2160p60','2160p','1440p60','1440p','1080p60','1080p','720p60','720p','480p','360p','240p','144p']
            //
            // Add any of the above to ignoredQualities if you don't want that quality to be selected
            // Example: const ignoredQualities = ['2160p60', '2160p'];
            // If you don't want 4k
            const ignoredQualities = ['2160p60','2160p','1440p60','1440p','1080p60','1080p'];
            qualityData = qualityData.filter(q => !ignoredQualities.includes(q.qualityLabel));
            if (!qualityData || qualityData.length === 0) {
                console.warn('No available quality levels found.');
                return;
            }

            const highest = qualityData[0]; // YouTube lists highest quality first
            const highestQuality = highest.quality;
            if (currentQuality != highestQuality && highest.isPlayable) {
                player.setPlaybackQualityRange?.(highestQuality);
                player.setPlaybackQuality?.(highestQuality);
                console.log('Quality set to highest available after entering fullscreen:', highestQuality);
                showToast('Quality set to ' + highest.qualityLabel);
            }
        }

        document.addEventListener('fullscreenchange', () => {
            setTimeout(setHighestQuality, 500);
        });

        // If already fullscreen on load
        window.addEventListener('load', () => {
            setTimeout(setHighestQuality, 2000);
        });
        // Detect URL changes
        let lastUrl = location.href;
        new MutationObserver(() => {
            const currentUrl = location.href;
            if (currentUrl !== lastUrl) {
                lastUrl = currentUrl;
                setTimeout(setHighestQuality, 2000);
            }
        }).observe(document, { subtree: true, childList: true });
    } + ')();';
    document.documentElement.appendChild(script);
})();

§
发布于:2025-10-12

Perfect! Thank you so much! Sorry for being so picky 😬 Works great on Firefox via GreaseMonkey with the code in this message folks!

发布留言

登录以发布留言。