Skip to content

Instantly share code, notes, and snippets.

@qgustavor
Created March 12, 2025 15:37
Show Gist options
  • Save qgustavor/cb2f94df5136272e2e6d058053273adf to your computer and use it in GitHub Desktop.
Save qgustavor/cb2f94df5136272e2e6d058053273adf to your computer and use it in GitHub Desktop.
Increase WhatsApp Web Audio Volume
// ==UserScript==
// @name Increase WhatsApp Web Audio Volume
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Intercept audio creation and redirect to Web Audio API with increased volume using createMediaElementSource
// @author ChatGPT
// @match https://web.whatsapp.com/*
// @run-at document-start
// ==/UserScript==
(function() {
// Store original Audio constructor
const originalAudio = window.Audio;
// Create a new AudioContext
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
// Create an AudioContext GainNode to control volume
const gainNode = audioContext.createGain();
gainNode.gain.value = 2; // Increase volume by 2 (200%)
// Intercept calls to new Audio()
window.Audio = function(src) {
// Create a new Audio element (HTMLAudioElement)
const audioElement = new originalAudio(src);
// Create a MediaElementSourceNode from the audio element
const source = audioContext.createMediaElementSource(audioElement);
// Connect the source to the GainNode, and then to the AudioContext destination
source.connect(gainNode);
gainNode.connect(audioContext.destination);
// Return the modified audio element
return audioElement;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment