Set Player Volume

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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);
			}
		}
	});
})();