Set YouTube Video Volume to Max

Sets the volume of YouTube videos to maximum (1)

// ==UserScript==
// @name         Set YouTube Video Volume to Max
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Sets the volume of YouTube videos to maximum (1)
// @author       Zeridiant
// @match        *://www.youtube.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to set the volume to max
    function setVolume() {
        let video = document.querySelector("video");
        if (video) {
            video.volume = 1;
        }
    }

    // Set the volume when the page loads
    window.addEventListener('load', setVolume);

    // Set the volume when navigating to a new video
    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
                setVolume();
            }
        });
    });

    observer.observe(document.body, { childList: true, subtree: true });
})();