-
-
Save fa7ad/fa995474f5cb9fe91fb209686881373d to your computer and use it in GitHub Desktop.
[DEPRECATED, its built into youtube now] 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 https://gist.github.com/fa7ad/fa995474f5cb9fe91fb209686881373d | |
// @version 0.2 | |
// @description Allows true 100% volume on youtube videos. | |
// @author Wouter Gerarts | |
// @match https://www.youtube.com/* | |
// @match https://youtube.com/* | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
"use strict"; | |
function baseElement() { | |
return document.querySelector("#content"); | |
} | |
if (typeof fullVolumeButtonTaskId === "number") { | |
console.log("clearing interval"); | |
clearInterval(fullVolumeButtonTaskId); | |
} | |
function maxVol() { | |
var videos = document.querySelectorAll("video"); | |
videos.forEach(function (video) { | |
video.volume = 1; | |
console.log(video, video.volume); | |
}); | |
} | |
function createFullVolumeButton() { | |
var css = ` | |
.full-volume-addon-button { | |
margin: 0 0.5em; | |
padding: 0.25em 1em; | |
background: transparent; | |
color: #fff; | |
border: 1px solid #fff; | |
border-radius: 1em; | |
font: caption; | |
} | |
.full-volume-addon-button:hover { | |
cursor: pointer; | |
background: #fff; | |
color: #000; | |
} | |
`; | |
var style = document.createElement("style"); | |
if (style.styleSheet) { | |
style.styleSheet.cssText = css; | |
} else { | |
style.appendChild(document.createTextNode(css)); | |
} | |
document.querySelector("head").appendChild(style); | |
var el = document.createElement("button"); | |
el.textContent = "100% Volume"; | |
el.classList.add("full-volume-addon-button"); | |
el.onclick = function (e) { | |
e.preventDefault(); | |
maxVol(); | |
}; | |
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; | |
} | |
var volTimer = setInterval(function () { | |
if ( | |
[].every.call(document.querySelectorAll("video"), function (vid) { | |
return vid.volume === 1; | |
}) | |
) { | |
console.log("vol maxed out"); | |
clearInterval(volTimer); | |
return; | |
} else { | |
maxVol(); | |
} | |
}, 500); | |
if (baseElement().querySelector(".full-volume-addon-button") != undefined) { | |
console.log("full volume addon button already found"); | |
clearInterval(fullVolumeButtonTaskId); | |
clearInterval(volTimer); | |
return; | |
} | |
var video = baseElement().querySelector("video"); | |
var videoTitleElement = baseElement().querySelector("#title h1"); | |
videoTitleElement.appendChild(createFullVolumeButton()); | |
}, 500); | |
})(); |
Whoops, I think I'll have to eat my words. It seems like enhanced-h264ify actually still does work after disabling and re-enabling the checkbox as suggested in alextrv/enhanced-h264ify#7. Crazy.
FWIW, when lowering volume in the mixer, pausing and re-starting, then it stays. But when moving to a new video, it jumps back to 100%.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cf. https://github.com/alextrv/enhanced-h264ify/blob/e5f2ea22378e85fc55b9e6ccab27644b1bc66ba5/src/inject/inject.js#L79-L104
(and alextrv/enhanced-h264ify#1 (comment))