Set Player Volume

Set youtube player volume using userscript menu command using prompt()

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Set Player Volume
// @namespace    https://greasyfork.org/users/1201646
// @version      1.0
// @description  Set youtube player volume using userscript menu command using prompt()
// @author       nemonai~
// @match        https://www.youtube.com/watch*
// @icon         https://icons.duckduckgo.com/ip2/youtube.com.ico
// @grant        GM_registerMenuCommand
// @run-at       document-idle
// @license      MIT
// ==/UserScript==


(() => {
	'use strict';
	GM_registerMenuCommand('Volume', () => {
		let num = prompt('Enter new volume', document.getElementById('movie_player').getVolume());

		if (num !== null) {
			num = Number(num);

			if (!Number.isNaN(num) && num !== document.getElementById('movie_player').getVolume()) {
				if (num > 100) { num = 100; }
				if (num <   0) { num =   0; }
				document.getElementById('movie_player').setVolume(num);
			}
		}
	});
})();