Skip to content

Instantly share code, notes, and snippets.

@SoaringGecko
Last active January 16, 2025 02:18
Show Gist options
  • Save SoaringGecko/e8e69a72fefb8c03e00ee21fb3b8397a to your computer and use it in GitHub Desktop.
Save SoaringGecko/e8e69a72fefb8c03e00ee21fb3b8397a to your computer and use it in GitHub Desktop.
increase video volume past the normal maximum

based off of the following code https://stackoverflow.com/a/43794379/11006719 this edited version fixes the issue that would only let you use increase the volume on one video element every time the url is changed (The Firefox versions run when you click the page do to Firefox requiring the user to interact with the page before it allows you to create an AudioContext).

The versions with safety in the name (and the userscripts) will prompt you to confirm your input when you set it so high.

Chromium Bookmarklet (safety on)

Chromium Bookmarklet

Firefox Bookmarklet (safety on)

Firefox Bookmarklet

Userscript Versions (meant for/requires Tampermonkey)

Userscript Version (triggers through button in context menu)

Universal Userscript Version (triggers on Ctrl + Right-Click, Allows for use on streaming services/iframes)

Alt Universal Userscript Version (same as above except it triggers on Ctrl + Click)

function changeAudioGainFunny() {
if (window._gainNode) {
let e = document.querySelector("video");
if (e._mediaElementSourceNode) {
window._gainNode.gain.value = parseFloat(prompt("Set the playback rate"));
return
}
let n = new AudioContext,
a = n.createMediaElementSource(e),
t = n.createGain();
window._gainNode = t, t.gain.value = parseFloat(prompt("Set the playback rate")), a.connect(t), t.connect(n.destination), e._mediaElementSourceNode = a
} else {
let i = document.querySelector("video"),
o = new AudioContext,
c = o.createMediaElementSource(i),
d = o.createGain();
d.gain.value = parseFloat(prompt("Set the audio gain")), c.connect(d), d.connect(o.destination), window._gainNode = d, i._mediaElementSourceNode = c
}
}
javascript:!function(){if(window._gainNode){let e=document.querySelector("video");if(e._mediaElementSourceNode){window._gainNode.gain.value=parseFloat(prompt("Set the playback rate"));return}let n=new AudioContext,t=n.createMediaElementSource(e),a=n.createGain();window._gainNode=a,a.gain.value=parseFloat(prompt("Set the playback rate")),t.connect(a),a.connect(n.destination),e._mediaElementSourceNode=t}else{let i=document.querySelector("video"),o=new AudioContext,c=o.createMediaElementSource(i),d=o.createGain();d.gain.value=parseFloat(prompt("Set the audio gain")),c.connect(d),d.connect(o.destination),window._gainNode=d,i._mediaElementSourceNode=c}}();
javascript:document.addEventListener("click",function(){if(window._gainNode){let e=document.querySelector("video");if(e._mediaElementSourceNode){function t(){(funny=parseFloat(prompt("Set the playback rate")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?window._gainNode.gain.value=funny:t():window._gainNode.gain.value=funny}t();return}let n=new(window.AudioContext||window.webkitAudioContext),o=n.createMediaElementSource(e),a=n.createGain();function t(){(funny=parseFloat(prompt("Set the playback rate")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?(window._gainNode=a,a.gain.value=funny,o.connect(a),a.connect(n.destination),e._mediaElementSourceNode=o):t():(window._gainNode=a,a.gain.value=funny,o.connect(a),a.connect(n.destination),e._mediaElementSourceNode=o)}t()}else{let i=document.querySelector("video"),u=new(window.AudioContext||window.webkitAudioContext),c=u.createMediaElementSource(i),d=u.createGain();function t(){(funny=parseFloat(prompt("Set the audio gain")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?(d.gain.value=funny,c.connect(d),d.connect(u.destination),window._gainNode=d,i._mediaElementSourceNode=c):t():(d.gain.value=funny||1,c.connect(d),d.connect(u.destination),window._gainNode=d,i._mediaElementSourceNode=c)}t()}},{once:!0});
javascript:document.addEventListener("click",function(){if(window._gainNode){let e=document.querySelector("video");if(e._mediaElementSourceNode){function t(){(funny=parseFloat(prompt("Set the playback rate")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?window._gainNode.gain.value=funny:t():window._gainNode.gain.value=funny}t();return}let n=new(window.AudioContext||window.webkitAudioContext),o=n.createMediaElementSource(e),a=n.createGain();function t(){(funny=parseFloat(prompt("Set the playback rate")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?(window._gainNode=a,a.gain.value=funny,o.connect(a),a.connect(n.destination),e._mediaElementSourceNode=o):t():(window._gainNode=a,a.gain.value=funny,o.connect(a),a.connect(n.destination),e._mediaElementSourceNode=o)}t()}else{let i=document.querySelector("video"),u=new(window.AudioContext||window.webkitAudioContext),c=u.createMediaElementSource(i),d=u.createGain();function t(){(funny=parseFloat(prompt("Set the audio gain")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?(d.gain.value=funny,c.connect(d),d.connect(u.destination),window._gainNode=d,i._mediaElementSourceNode=c):t():(d.gain.value=funny,c.connect(d),d.connect(u.destination),window._gainNode=d,i._mediaElementSourceNode=c)}t()}},{once:!0});
javascript:!function(){if(window._gainNode){let e=document.querySelector("video");if(e._mediaElementSourceNode){n();function n(){(funny=parseFloat(prompt("Set the playback rate")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?window._gainNode.gain.value=funny:n():window._gainNode.gain.value=funny}}let t=new AudioContext,o=t.createMediaElementSource(e),a=t.createGain();function n(){(funny=parseFloat(prompt("Set the playback rate")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?(window._gainNode=a,a.gain.value=funny,o.connect(a),a.connect(t.destination),e._mediaElementSourceNode=o):n():(window._gainNode=a,a.gain.value=funny,o.connect(a),a.connect(t.destination),e._mediaElementSourceNode=o)}n()}else{let i=document.querySelector("video"),u=new AudioContext,c=u.createMediaElementSource(i),l=u.createGain();function n(){(funny=parseFloat(prompt("Set the audio gain")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?(l.gain.value=funny,c.connect(l),l.connect(u.destination),window._gainNode=l,i._mediaElementSourceNode=c):n():(l.gain.value=funny||1,c.connect(l),l.connect(u.destination),window._gainNode=l,i._mediaElementSourceNode=c)}n()}}();
function changeAudioGainFunny() {
document.addEventListener("click", function() {
if (window._gainNode) {
let e = document.querySelector("video");
if (e._mediaElementSourceNode) {
window._gainNode.gain.value = parseFloat(prompt("Set the playback rate"));
return
}
let n = new(window.AudioContext || window.webkitAudioContext),
t = n.createMediaElementSource(e),
i = n.createGain();
window._gainNode = i, i.gain.value = parseFloat(prompt("Set the playback rate")), t.connect(i), i.connect(n.destination), e._mediaElementSourceNode = t
} else {
let o = document.querySelector("video"),
a = new(window.AudioContext || window.webkitAudioContext),
c = a.createMediaElementSource(o),
d = a.createGain();
d.gain.value = parseFloat(prompt("Set the audio gain")), c.connect(d), d.connect(a.destination), window._gainNode = d, o._mediaElementSourceNode = c
}
}, {
once: !0
})
}
function changeAudioGainFunny() {
document.addEventListener("click", function() {
if (window._gainNode) {
let e = document.querySelector("video");
if (e._mediaElementSourceNode) {
function n() {
(funny = parseFloat(prompt("Set the playback rate"))) >= 10 ? confirm("The volume you have set is a little loud (" + funny + "), are you sure you want to continue?") ? window._gainNode.gain.value = funny : n() : window._gainNode.gain.value = funny
}
n();
return
}
let t = new(window.AudioContext || window.webkitAudioContext),
o = t.createMediaElementSource(e),
i = t.createGain();
function n() {
(funny = parseFloat(prompt("Set the playback rate"))) >= 10 ? confirm("The volume you have set is a little loud (" + funny + "), are you sure you want to continue?") ? (window._gainNode = i, i.gain.value = funny, o.connect(i), i.connect(t.destination), e._mediaElementSourceNode = o) : n() : (window._gainNode = i, i.gain.value = funny, o.connect(i), i.connect(t.destination), e._mediaElementSourceNode = o)
}
n()
} else {
let a = document.querySelector("video"),
u = new(window.AudioContext || window.webkitAudioContext),
c = u.createMediaElementSource(a),
d = u.createGain();
function n() {
(funny = parseFloat(prompt("Set the audio gain"))) >= 10 ? confirm("The volume you have set is a little loud (" + funny + "), are you sure you want to continue?") ? (d.gain.value = funny, c.connect(d), d.connect(u.destination), window._gainNode = d, a._mediaElementSourceNode = c) : n() : (d.gain.value = funny, c.connect(d), d.connect(u.destination), window._gainNode = d, a._mediaElementSourceNode = c)
}
n()
}
}, {
once: !0
})
}
function changeAudioGainFunny() {
if (window._gainNode) {
let e = document.querySelector("video");
if (e._mediaElementSourceNode) {
n();
function n() {
(funny = parseFloat(prompt("Set the playback rate"))) >= 10 ? confirm("The volume you have set is a little loud (" + funny + "), are you sure you want to continue?") ? window._gainNode.gain.value = funny : n() : window._gainNode.gain.value = funny
}
}
let o = new AudioContext,
t = o.createMediaElementSource(e),
a = o.createGain();
function n() {
(funny = parseFloat(prompt("Set the playback rate"))) >= 10 ? confirm("The volume you have set is a little loud (" + funny + "), are you sure you want to continue?") ? (window._gainNode = a, a.gain.value = funny, t.connect(a), a.connect(o.destination), e._mediaElementSourceNode = t) : n() : (window._gainNode = a, a.gain.value = funny, t.connect(a), a.connect(o.destination), e._mediaElementSourceNode = t)
}
n()
} else {
let i = document.querySelector("video"),
u = new AudioContext,
c = u.createMediaElementSource(i),
l = u.createGain();
function n() {
(funny = parseFloat(prompt("Set the audio gain"))) >= 10 ? confirm("The volume you have set is a little loud (" + funny + "), are you sure you want to continue?") ? (l.gain.value = funny, c.connect(l), l.connect(u.destination), window._gainNode = l, i._mediaElementSourceNode = c) : n() : (l.gain.value = funny, c.connect(l), l.connect(u.destination), window._gainNode = l, i._mediaElementSourceNode = c)
}
n()
}
}
// ==UserScript==
// @name Custom Playback Rate and Volume (context-menu)
// @namespace tampermonkey-scripts
// @description Sets custom playback rate and volume for HTML5 videos
// @version 1.0
// @match *://*/*
// @grant none
// @run-at context-menu
// ==/UserScript==
(function () {
if (window._gainNode) {
let video = document.querySelector("video");
if (video._mediaElementSourceNode) {
setPlaybackRateAndVolume();
} else {
setPlaybackRateAndVolumeWithSourceNode(video);
}
} else {
let video = document.querySelector("video");
setAudioGain(video);
}
function setPlaybackRateAndVolume() {
let playbackRate = parseFloat(prompt("Set the playback rate"));
if (playbackRate >= 10) {
if (confirm("The volume you have set is a little loud (" + playbackRate + "), are you sure you want to continue?")) {
window._gainNode.gain.value = playbackRate;
} else {
setPlaybackRateAndVolume();
}
} else {
window._gainNode.gain.value = playbackRate;
}
}
function setPlaybackRateAndVolumeWithSourceNode(video) {
let audioContext = new AudioContext();
let sourceNode = audioContext.createMediaElementSource(video);
let gainNode = audioContext.createGain();
function setPlaybackRateAndVolume() {
let playbackRate = parseFloat(prompt("Set the playback rate"));
if (playbackRate >= 10) {
if (confirm("The volume you have set is a little loud (" + playbackRate + "), are you sure you want to continue?")) {
window._gainNode = gainNode;
gainNode.gain.value = playbackRate;
sourceNode.connect(gainNode);
gainNode.connect(audioContext.destination);
video._mediaElementSourceNode = sourceNode;
} else {
setPlaybackRateAndVolume();
}
} else {
window._gainNode = gainNode;
gainNode.gain.value = playbackRate;
sourceNode.connect(gainNode);
gainNode.connect(audioContext.destination);
video._mediaElementSourceNode = sourceNode;
}
}
setPlaybackRateAndVolume();
}
function setAudioGain(video) {
let audioContext = new AudioContext();
let sourceNode = audioContext.createMediaElementSource(video);
let gainNode = audioContext.createGain();
function setGain() {
let audioGain = parseFloat(prompt("Set the audio gain"));
if (audioGain >= 10) {
if (confirm("The volume you have set is a little loud (" + audioGain + "), are you sure you want to continue?")) {
gainNode.gain.value = audioGain;
sourceNode.connect(gainNode);
gainNode.connect(audioContext.destination);
window._gainNode = gainNode;
video._mediaElementSourceNode = sourceNode;
} else {
setGain();
}
} else {
gainNode.gain.value = audioGain;
sourceNode.connect(gainNode);
gainNode.connect(audioContext.destination);
window._gainNode = gainNode;
video._mediaElementSourceNode = sourceNode;
}
}
setGain();
}
})();
// ==UserScript==
// @name change video volume
// @namespace http://tampermonkey.net/
// @homepage https://gist.github.com/SoaringGecko/e8e69a72fefb8c03e00ee21fb3b8397a#file-readme-md
// @homepageURL https://gist.github.com/SoaringGecko/e8e69a72fefb8c03e00ee21fb3b8397a#file-readme-md
// @website https://gist.github.com/SoaringGecko/e8e69a72fefb8c03e00ee21fb3b8397a#file-readme-md
// @source https://gist.github.com/SoaringGecko/e8e69a72fefb8c03e00ee21fb3b8397a#file-readme-md
// @version 5.0
// @description Change any videos volume with ctrl right-click
// @author WhiteTapeti
// @include *
// @grant none
// @updateURL https://gist.github.com/SoaringGecko/e8e69a72fefb8c03e00ee21fb3b8397a/raw/increase_video_volume_userscript_safety_universal.user.js
// ==/UserScript==
var elemScript = document.createElement('script');
elemScript.innerHTML = `document.addEventListener("contextmenu",function(e){if(e.ctrlKey){if(window._gainNode){let t=document.querySelector("video");if(t._mediaElementSourceNode){function n(){(funny=parseFloat(prompt("Set the playback rate")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?window._gainNode.gain.value=funny:n():window._gainNode.gain.value=funny}n();return}let o=new(window.AudioContext||window.webkitAudioContext),i=o.createMediaElementSource(t),a=o.createGain();function n(){(funny=parseFloat(prompt("Set the playback rate")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?(window._gainNode=a,a.gain.value=funny,i.connect(a),a.connect(o.destination),t._mediaElementSourceNode=i):n():(window._gainNode=a,a.gain.value=funny,i.connect(a),a.connect(o.destination),t._mediaElementSourceNode=i)}n()}else{let u=document.querySelector("video"),c=new(window.AudioContext||window.webkitAudioContext),d=c.createMediaElementSource(u),l=c.createGain();function n(){(funny=parseFloat(prompt("Set the audio gain")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?(l.gain.value=funny,d.connect(l),l.connect(c.destination),window._gainNode=l,u._mediaElementSourceNode=d):n():(l.gain.value=funny||1,d.connect(l),l.connect(c.destination),window._gainNode=l,u._mediaElementSourceNode=d)}n()}}});`;
document.body.append(elemScript);
// ==UserScript==
// @name change video volume
// @namespace http://tampermonkey.net/
// @homepage https://gist.github.com/SoaringGecko/e8e69a72fefb8c03e00ee21fb3b8397a#file-readme-md
// @homepageURL https://gist.github.com/SoaringGecko/e8e69a72fefb8c03e00ee21fb3b8397a#file-readme-md
// @website https://gist.github.com/SoaringGecko/e8e69a72fefb8c03e00ee21fb3b8397a#file-readme-md
// @source https://gist.github.com/SoaringGecko/e8e69a72fefb8c03e00ee21fb3b8397a#file-readme-md
// @version 3.0
// @description Change any videos volume with ctrl click
// @author WhiteTapeti
// @include *
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @grant none
// @updateURL https://gist.github.com/SoaringGecko/e8e69a72fefb8c03e00ee21fb3b8397a/raw/increase_video_volume_userscript_safety_universal_alt.user.js
// ==/UserScript==
var elemScript = document.createElement('script');
elemScript.innerHTML = `document.addEventListener("click",function(e){if(e.ctrlKey){if(window._gainNode){let t=document.querySelector("video");if(t._mediaElementSourceNode){function n(){(funny=parseFloat(prompt("Set the playback rate")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?window._gainNode.gain.value=funny:n():window._gainNode.gain.value=funny}n();return}let o=new(window.AudioContext||window.webkitAudioContext),i=o.createMediaElementSource(t),a=o.createGain();function n(){(funny=parseFloat(prompt("Set the playback rate")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?(window._gainNode=a,a.gain.value=funny,i.connect(a),a.connect(o.destination),t._mediaElementSourceNode=i):n():(window._gainNode=a,a.gain.value=funny,i.connect(a),a.connect(o.destination),t._mediaElementSourceNode=i)}n()}else{let u=document.querySelector("video"),c=new(window.AudioContext||window.webkitAudioContext),d=c.createMediaElementSource(u),l=c.createGain();function n(){(funny=parseFloat(prompt("Set the audio gain")))>=10?confirm("The volume you have set is a little loud ("+funny+"), are you sure you want to continue?")?(l.gain.value=funny,d.connect(l),l.connect(c.destination),window._gainNode=l,u._mediaElementSourceNode=d):n():(l.gain.value=funny||1,d.connect(l),l.connect(c.destination),window._gainNode=l,u._mediaElementSourceNode=d)}n()}}});`;
document.body.append(elemScript);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment