Skip to content

Instantly share code, notes, and snippets.

@satyr
Created March 27, 2010 16:45
Show Gist options
  • Save satyr/346209 to your computer and use it in GitHub Desktop.
Save satyr/346209 to your computer and use it in GitHub Desktop.
radiko_lite.user.js
// ==UserScript==
// @name radiko lite
// @description Simplifies radiko_player, inlining it onto the timetable.
// @namespace http://twitter.com/m_satyr
// @include http://radiko.jp/player/player.html#*
// @include http://radiko.jp/timetable/
// ==/UserScript==
if((banner = document.querySelector('#header > .banner')))
return addEventListener('load', function(){
var parent = banner.parentNode
, player = parent.appendChild(document.createElement('div'))
parent.removeChild(banner)
player.innerHTML =
'<iframe name="radiko_player" width="224" height="36" '+
'style="border:2px outset menu; overflow:hidden">'
player.style.cssText =
'position:fixed; top:0; right:0; display:inline-block; z-index:9'
document.querySelector('#cts').scrollIntoView()
}, false)
setTimeout(function(){
for(let i = setTimeout(''); i;) clearTimeout(i--)
unsafeWindow.$('*').unbind().filter('link, script, style').remove()
unsafeWindow.swfobject = unsafeWindow.jQuery = unsafeWindow.$ = null
document.body.innerHTML = <>
<style><![CDATA[
body {margin:0}
#id {
position:fixed; padding:0 2px;
background-color:menu; font:bold small monospace}
]]></style>
<div id="id">{location.hash}</div>
</> + document.getElementById('external_controller_wrap').innerHTML
document.body.addEventListener('focus', function radiko_unfocus(ev){
setTimeout(function(x){ x && x.blur() }, 0, ev.target)
}, false)
setTimeout(radiko_change, 666)
addEventListener('hashchange', radiko_change, false)
// might need to reset periodically as the player gets heavy over time
// setInterval(radiko_change, 60 * 6e4)
function radiko_change(){
location.href = 'javascript:void new '+ function(){
document.getElementById('external_controller')
.changeStation(location.hash.slice(1))
}
document.getElementById('id').textContent = location.hash
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment