Skip to content

Instantly share code, notes, and snippets.

@benok
Forked from 1024kibits/radiko_addl_ctrl.js
Last active April 22, 2022 05:50
Show Gist options
  • Save benok/4bb3841b81a0b3a686a6d2484d32d2cb to your computer and use it in GitHub Desktop.
Save benok/4bb3841b81a0b3a686a6d2484d32d2cb to your computer and use it in GitHub Desktop.
radiko に再生速度変更ボタンと指定秒ジャンプボタンを追加する bookmarklet
javascript:((i,a,p,c,m,s,l,e,j,r,u)=>{
if($('#'+i)[0])return;
$('#stream-player').append(
`<div id=${i} textAlign="center">
Jump:
<button>-30s</button><button> -10s</button>
<button> +10s</button><button>+30s</button><button>+1m</button><button> +3m</button><button>+10m</button>
Rate:
<input type=number step=0.05 min=0.25 max=4.0 value=1.00 style=width:4em>
<button>-0.1</button><button>+0.1</button><button>=1.0</button>
</div>`
);
j=(d)=>{
let b=$('#seekbar'),k=b.find('.knob'),w=b.width();
k.css('left', c(k.position().left+w*d/player.duration(),0,w))
.draggable('option', 'stop')()
};
e=$(`#${i} :first`);
e .click(()=>{j( -30)});
(e=e.next()).click(()=>{j( -10)});
(e=e.next()).click(()=>{j( +10)});
(e=e.next()).click(()=>{j( +30)});
(e=e.next()).click(()=>{j( +60)});
(e=e.next()).click(()=>{j(+180)});
(e=e.next()).click(()=>{j(+600)});
u=(d=0,v)=>{
a().playbackRate=
a().defaultPlaybackRate=
+(r.value=c((v?v:+r.value)+d,0.25,4.0).toFixed(2));
};
r=((e=e.next()).change(()=>u())).get(0);
(e=e.next()).click(()=>u(-0.1));
(e=e.next()).click(()=>u(+0.1));
(e=e.next()).click(()=>u(0,1));
setInterval(u,1000);
l=p.loadHlsjs;
p.loadHlsjs=function(u){return l.call(this,u.replace(...(u.match(m)?[m,s]:[s,m])))};
})('additional-controlls',()=>player._player._audio,player._player.constructor.prototype,c=(v,l,h)=>Math.min(Math.max(v,l),h),'tf-rpaa.smartstream.ne.jp/tf','radiko.jp/v2/api/ts')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment