Set Player Volume

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

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

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

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.

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

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