Disable DRC Audio on YouTube

Disables DRC Audio (Stable Volume) on YouTube

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Disable DRC Audio on YouTube
// @author       Adri
// @namespace    http://tampermonkey.net/
// @match        https://www.youtube.com/*
// @grant        none
// @version      0.1
// @description  Disables DRC Audio (Stable Volume) on YouTube
// @license      MIT
// @run-at       document-idle
// ==/UserScript==

// ad-hoc script - manipulates yt html/js to manually disable stable volume
// executes on first-page load, assumes yt doesn't change drc after that
(function() {
    'use strict';
    console.log('ya')
    function waitForElement(selector) {
        return new Promise((resolve, reject) => {
            let element = document.querySelector(selector);
            if (element) {
                resolve(element);
            } else {
                const observer = new MutationObserver(mutations => {
                    const element = document.querySelector(selector);
                    if (element) {
                        observer.disconnect();
                        resolve(element);
                    }
                });
                observer.observe(document.body, {
                    childList: true,
                    subtree: true
                });
            }
        });
    }

    function disableDRC() {
        return new Promise((resolve, reject) => {
            waitForElement('.ytp-settings-button')
                .then(menuButton => {
                    menuButton.click();
                    menuButton.click();
                    return waitForElement('.ytp-drc-menu-item');
                })
                .then(drcMenuItem => {
                    if (drcMenuItem.getAttribute('aria-checked') === 'true') {
                        drcMenuItem.click();
                        console.log('Disabled DRC Audio');
                    } else {
                        console.log('DRC Audio is already disabled');
                    }
                    resolve();
                })
                .catch(error => {
                    reject(error);
                });
        });
    }

    // Main execution
    disableDRC()
        .catch(error => {
            console.error('Error:', error);
        });

})();