turn volume in youtube to "1"

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

Tính đến 29-05-2021. Xem phiên bản mới nhất.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         turn volume in youtube to "1"
// @namespace    http://tampermonkey.net/
// @version      0.3
// @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';
        // Timer for setting volume to 1

        setTimeout(function() {
            document.getElementsByClassName("video-stream")[0].volume = 1;
        }, 550);

        // HTML interface to set volume to default value or to 1

        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")

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