Created
March 23, 2020 17:07
-
-
Save rafaelgallani/6d28ee38e1efd178839f3b06d17e10ed to your computer and use it in GitHub Desktop.
Tampermonkey extension to speed up or slow down Whatsapp Web audios
This file contains hidden or 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 WhatsApp Audio Playback Rate Changer | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description try to take over the world! | |
| // @author You | |
| // @match https://web.whatsapp.com/ | |
| // @grant none | |
| // @runat document-end | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| var playbackRate = 1; | |
| var changeAudioPlaybackRate = function(){ | |
| document.querySelectorAll('audio').forEach(audio => audio.playbackRate = playbackRate); | |
| } | |
| document.addEventListener('keydown', function(){ | |
| if (event.altKey){ | |
| if (event.key == '+') { | |
| playbackRate += .25; | |
| changeAudioPlaybackRate(); | |
| } else if (event.key == '-') { | |
| playbackRate -= .25; | |
| changeAudioPlaybackRate(); | |
| } | |
| } | |
| }); | |
| const RECEIVED_AUDIOS_WHATSAPP_SRC = 'blob:https://web.whatsapp.com/' | |
| const audioDefaultPlay = window.Audio.prototype.play | |
| window.Audio.prototype.play = function(){ | |
| if (this.src.startsWith(RECEIVED_AUDIOS_WHATSAPP_SRC)){ | |
| this.playbackRate = playbackRate; | |
| } | |
| audioDefaultPlay.apply(this) | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment