Skip to content

Instantly share code, notes, and snippets.

@solarshado
Created November 1, 2017 02:57
Show Gist options
  • Save solarshado/bd733596aca6c8abbad001d335396155 to your computer and use it in GitHub Desktop.
Save solarshado/bd733596aca6c8abbad001d335396155 to your computer and use it in GitHub Desktop.
JS one-liner/bookmarklet to set volume of audio/video controls
/* gets value between 0-1 or 2-100 with prompt() and sets volume of all <audio> and <video> tags to that fraction */
(function(n){if(n>1) n/=100; if(n>1) n=1; if(!n) return; var g=t=>Array.from(document.getElementsByTagName(t)); var e=g("audio").concat(g("video")); e.forEach(p=>p.volume=n);})(+prompt("enter volume"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment