turn volume in youtube to "1"

It makes your youtube video volume output at it's maximum as long as you have 100% on.

当前为 2021-05-29 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         turn volume in youtube to "1"
// @namespace    https://greasyfork.org/de/users/777213-tripzz-ѕкιηѕ-lpwsand
// @version      0.5
// @description  It makes your youtube video volume output at it's maximum as long as you have 100% on.
// @author       Genc
// @match        https://www.youtube.com/watch*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

        setTimeout(function() {
            document.getElementsByClassName("ytp-volume-panel")[0].ariaValueNow === "100" ? document.getElementsByClassName("video-stream")[0].volume = 1 : console.log("default");
        }, 500)

        function insertAfter(referenceNode, newNode) {
            referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
          };

        var volumeSign = document.getElementsByClassName("ytp-next-button ytp-button")[0];
        var setValue = document.createElement("span");
        setValue.textContent = 1;
        setValue.style.width = "23.354px";
        setValue.style.textAlign = "center";

        insertAfter(volumeSign, setValue);

        setValue.addEventListener("click", function() {
            var svgAnimationSpeaker = document.getElementsByClassName("ytp-svg-fill ytp-svg-volume-animation-speaker")[0];
            if(setValue.textContent == 1) {
                document.getElementsByClassName("video-stream")[0].volume = 0.49831044449650735;
                setValue.textContent = 0.49;
                document.getElementsByClassName("ytp-volume-slider-handle")[0].style.left = "40px";
                svgAnimationSpeaker.setAttribute("d","M8,21 L12,21 L17,26 L17,10 L12,15 L8,15 L8,21 Z M19,14 L19,22 C20.48,21.32 21.5,19.77 21.5,18 C21.5,16.26 20.48,14.74 19,14 ZM19,11.29 C21.89,12.15 24,14.83 24,18 C24,21.17 21.89,23.85 19,24.71 L19,26.77 C23.01,25.86 26,22.28 26,18 C26,13.72 23.01,10.14 19,9.23 L19,11.29 Z");

            } else if (setValue.textContent == 0.49) {
                document.getElementsByClassName("video-stream")[0].volume = 1;
                setValue.textContent = 1;
                document.getElementsByClassName("ytp-volume-slider-handle")[0].style.left = "40px";
                svgAnimationSpeaker.setAttribute("d","M8,21 L12,21 L17,26 L17,10 L12,15 L8,15 L8,21 Z M19,14 L19,22 C20.48,21.32 21.5,19.77 21.5,18 C21.5,16.26 20.48,14.74 19,14 ZM19,11.29 C21.89,12.15 24,14.83 24,18 C24,21.17 21.89,23.85 19,24.71 L19,26.77 C23.01,25.86 26,22.28 26,18 C26,13.72 23.01,10.14 19,9.23 L19,11.29 Z");

            } else {
                setValue.textContent = "Refresh your site.";
            };
        });

        setInterval(function() {
            if(setValue.textContent == 1 && document.getElementsByClassName("video-stream")[0].volume !== 1 && document.getElementsByClassName("ytp-volume-panel")[0].ariaValueNow === "100") {
                document.getElementsByClassName("video-stream")[0].volume = 1;
            };
        },1500);
})();