YouTube Auto HD + FPS

A script that automatically sets YouTube videos to 1080p with 30 fps.

// ==UserScript==
// @name         YouTube Auto HD + FPS
// @description  A script that automatically sets YouTube videos to 1080p with 30 fps.
// @version      1.0
// @author       Midnight
// @namespace    https://google.com
// @match        *://*/*
// @run-at       document-start
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    "use strict";

    const log = console.log;

    // Get the YouTube player
    const player = document.querySelector("ytd-player");

    // Set the video quality to 1080p
    player.playbackQuality = "hd1080";

    // Set the highest frame rate to 30 fps
    player.maxFps = 30;

    // If the user changes the video quality, reset it to 1080p
    player.onPlaybackQualityChange = function(quality) {
      if (quality !== "hd1080") {
        player.playbackQuality = "hd1080";
      }
    };

})();