Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Soundgasm
- // @namespace http://tampermonkey.net/
- // @version 0.3
- // @description adds keyboard controls and extends container to utilize more screen realestate
- // @author gigi
- // @match *://*.soundgasm.net/*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=soundgasm.net
- // @grant none
- // ==/UserScript==
- var a=document.getElementById('jp_audio_0');
- document.body.appendChild(document.createElement('style')).textContent = `
- #jp_container_1 {width:auto;}
- .jp-progress {right:120px; width:auto !important;}
- .jp-volume-controls {right:-90px; left:auto;}
- .jp-speed {position:absolute; top:0px; left:230px; padding:0 5px; background:#ccc; border-radius:7px; border:solid 1.5px #3eafe7; font-weight:bolder; cursor:pointer; font-size:10.24px;}
- .jp-speed-info {position:absolute; top:0px; left:252px; padding:0 8px; font-size:10.24px; font-style:oblique; line-height:16px;}
- body {overflow-x:hidden; background:black;}
- `;
- var slower=document.createElement('div');
- var faster=document.createElement('div');
- var info=document.createElement('div');
- info.id='speed-info';
- slower.id='slower';
- faster.id='faster';
- slower.classList.add('jp-speed');
- faster.classList.add('jp-speed');
- info.classList.add('jp-speed-info')
- slower.textContent='-';
- faster.textContent='+';
- info.textContent='1.0';
- faster.style.left='290px';
- faster.style.padding='0 3px';
- document.getElementsByClassName('jp-time-holder')[0].appendChild(slower);
- document.getElementsByClassName('jp-time-holder')[0].appendChild(faster);
- document.getElementsByClassName('jp-time-holder')[0].appendChild(info);
- document.getElementById('slower').addEventListener ("click", function(){a.playbackRate-=0.1;document.getElementById('speed-info').textContent=a.playbackRate.toFixed(1);} , false);
- document.getElementById('faster').addEventListener ("click", function(){a.playbackRate+=0.1;document.getElementById('speed-info').textContent=a.playbackRate.toFixed(1);} , false);
- window.addEventListener("keydown",
- (event) => {
- if (event.defaultPrevented) {
- return; // Do nothing if the event was already processed
- }
- if('1234567890'.indexOf(event.key)>=0) {
- document.getElementsByTagName('audio')[0].fastSeek((document.getElementsByTagName('audio')[0].duration/10)*event.key);
- } else if(event.key == ' ') {
- document.getElementsByTagName('audio')[0].paused ? document.getElementsByTagName('audio')[0].play() : document.getElementsByTagName('audio')[0].pause()
- } else if(event.key == 'ArrowRight') {
- document.getElementsByTagName('audio')[0].fastSeek((document.getElementsByTagName('audio')[0].currentTime+5));
- } else if(event.key == 'ArrowLeft') {
- document.getElementsByTagName('audio')[0].fastSeek((document.getElementsByTagName('audio')[0].currentTime-5));
- } else if(event.key == 'ArrowUp') {
- a.playbackRate+=0.1;document.getElementById('speed-info').textContent=a.playbackRate.toFixed(1);
- } else if(event.key == 'ArrowDown') {
- a.playbackRate-=0.1;document.getElementById('speed-info').textContent=a.playbackRate.toFixed(1);
- }
- else {
- console.log(event.key);
- return;
- }
- // Cancel the default action to avoid it being handled twice
- event.preventDefault();
- },
- true,
- );
Advertisement
Add Comment
Please, Sign In to add comment