https://gist.github.com/abec2304/2782f4fc47f9d010dfaab00f25e69c8a. It is definitely way better than this one so I am using it as well.
Bookmarklet was converted from the userscript using http://bookmarklets.org/maker/ (non minified).
https://gist.github.com/abec2304/2782f4fc47f9d010dfaab00f25e69c8a. It is definitely way better than this one so I am using it as well.
Bookmarklet was converted from the userscript using http://bookmarklets.org/maker/ (non minified).
// ==UserScript== | |
// @name Prevent Youtube Audio Normalization | |
// @namespace asdcawdcawcdkacja2333332 | |
// @version 1.5 | |
// @description Prevent Youtube Audio Normalization | |
// @author asdcawdcawcdkacja2333332 | |
// @match https://www.youtube.com/* | |
// @grant none | |
// ==/UserScript== | |
//Background tabs are throttled so sometimes it takes a second to apply the value which is annoying as hell. | |
//Not sure if requestanimationframe is better than an interval for the above reason. requestanimationframe doesn't make the sound pop on volume change though. | |
//https://webapps.stackexchange.com/questions/90995/how-can-i-change-a-youtube-videos-volume-beyond-the-normal-limits/103665#103665 | |
//There should be a better way to do this using the "loudnessDb" and the "perceptualLoudnessDb" values within the video/player configs, but I have no idea how. | |
//Try both methods together | |
var theVideo, barVolume; | |
function repeatonFrame() { | |
trytoFix(); | |
requestAnimationFrame(repeatonFrame); | |
} | |
function trytoFix() { | |
try { | |
theVideo = document.getElementsByTagName('video')[0]; | |
barVolume = document.getElementsByClassName("ytp-volume-panel")[0].attributes["aria-valuenow"].value / 100; | |
if (theVideo.volume != barVolume) { | |
console.log("Fixed the video volume from " + theVideo.volume + " to " + barVolume); | |
theVideo.volume = barVolume; | |
} | |
//document.getElementsByTagName('video')[0].volume = document.getElementsByClassName("ytp-volume-panel")[0].attributes["aria-valuenow"].value / 100; | |
} catch (e) {} | |
} | |
//SETINTERVAL METHOD | |
var TheInterval = setInterval(trytoFix, 100); | |
//REQUESTANIMATIONFRAME METHOD | |
requestAnimationFrame(repeatonFrame); | |
/* | |
//backup (useless) | |
document.getElementById("player-wrap").children[2].innerHTML.replace(/([lL])oudnessDb(.*?):(.*?)([,}])/g, "$1oudnessDb$2:0$4"); | |
*/ |
Here's an alternative implementation: https://gist.github.com/abec2304/2782f4fc47f9d010dfaab00f25e69c8a
Thanks for sharing!
Here's an alternative implementation: https://gist.github.com/abec2304/2782f4fc47f9d010dfaab00f25e69c8a