Last active
November 15, 2024 02:21
-
-
Save WouterG/acf1e901324aed77f466626fb5d6611f to your computer and use it in GitHub Desktop.
Disable youtube volume normalization (allow true video 100% volume)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name YouTube Disable Normalization | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Allows true 100% volume on youtube videos. | |
// @author Wouter Gerarts | |
// @match https://www.youtube.com/* | |
// @match https://youtube.com/* | |
// @grant none | |
// ==/UserScript== | |
var alwaysEnable = true; | |
(function() { | |
'use strict'; | |
function baseElement() { | |
return document.querySelector('#content'); | |
} | |
if (typeof fullVolumeButtonTaskId === 'number') { | |
console.log('clearing interval'); | |
clearInterval(fullVolumeButtonTaskId); | |
} | |
function createFullVolumeButton() { | |
var el = document.createElement('button'); | |
el.innerText = '100% Volume'; | |
el.classList.add('full-volume-addon-button'); | |
el.onclick = function() { | |
var video = baseElement().querySelector('video'); | |
video.volume = 1; | |
}; | |
return el; | |
} | |
function round (num, sig) { | |
var mult = Math.pow(10, sig); | |
return Math.round(num * mult) / mult; | |
} | |
var fullVolumeButtonTaskId = setInterval(function() { | |
if (baseElement().querySelector('video') === undefined) { | |
console.log('video element not found'); | |
return; | |
} | |
if (baseElement().querySelector('.full-volume-addon-button') != undefined) { | |
console.log('full volume addon button already found'); | |
clearInterval(fullVolumeButtonTaskId); | |
return; | |
} | |
var volumeSlider = baseElement().querySelector('.ytp-volume-slider-handle') | |
if (volumeSlider === undefined || volumeSlider === null) { | |
console.log('volumeSlider not found'); | |
return; | |
} | |
var video = baseElement().querySelector('video'); | |
var volumeSliderLeftStr = volumeSlider.style.left; | |
var volumeSliderLeft = volumeSliderLeftStr.substr(0, volumeSliderLeftStr.length - 2); | |
var volumeSliderValue = parseFloat(volumeSliderLeft) * 2.5; | |
console.log('Checking slider ' + round(volumeSliderValue / 100, 2).toString() + ' against value ' + round(video.volume, 2).toString()); | |
if (alwaysEnable || volumeSliderValue / 100 > video.volume) { | |
var videoTitleElement = baseElement().querySelector('.ytd-video-primary-info-renderer'); | |
videoTitleElement.appendChild(createFullVolumeButton()); | |
} else { | |
console.log('volume slider did not meet criteria for Full Volume button'); | |
} | |
}, 500); | |
})(); |
Any chance of an update? Seems to have just broken for me..
Any chance of an update? Seems to have just broken for me..
I maintain an alternative script which I occasionally update https://gist.github.com/abec2304/2782f4fc47f9d010dfaab00f25e69c8a
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing that. I created a new blank profile and it works, so my FF profile is just broken which I've seen before.