Last active
August 29, 2015 14:02
-
-
Save long-long-float/8229bbfdcb7527f9ff26 to your computer and use it in GitHub Desktop.
niconico-anywhereのクライアント(ブックマークレット)
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
(function(){var c,messages,messages_buf,wheight,wwidth;c=function(a,b){var e;e=document.createElement('script');e.type='text/javascript';e.src=a;if(b){e.onloadDone=false;e.onload=function(){e.onloadDone=true;return b()};e.onReadystatechange=function(){if(e.readyState==='loaded'&&!e.onloadDone){e.onloadDone=true;return b()}}}if(typeof e!=='undefined'){return document.getElementsByTagName('head')[0].appendChild(e)}};messages_buf=[];c('https://cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js',function(){var b,_ref;b=io.connect("http://"+((_ref=window.niconico_anywhere_host)!=null?_ref:"niconico-learning.herokuapp.com:80"));return b.on('new-message',function(a){return messages_buf.push(a)})});messages=[];wwidth=document.documentElement.clientWidth;wheight=document.documentElement.clientHeight;setInterval((function(){var a,i,index,msg,remove_list,s,_i,_j,_k,_len,_len1,_len2,_ref,_results;for(_i=0,_len=messages_buf.length;_i<_len;_i++){msg=messages_buf[_i];a=document.createElement('div');s=a.style;s.position='absolute';s.fontFamily='MS P ゴシック';s.fontSize='30px';s.color='white';s.textShadow='1px 1px 1px #000, -1px 1px 1px #000, 1px -1px 1px #000, -1px -1px 1px #000';a.textContent=msg.content;document.body.appendChild(a);messages.push({x:wwidth,y:10+wheight*Math.random()-10,vx:-1+(-4*Math.random()),vy:0,element:a})}messages_buf=[];remove_list=[];for(i=_j=0,_len1=messages.length;_j<_len1;i=++_j){msg=messages[i];s=msg.element.style;s.left=""+msg.x+"px";s.top=""+msg.y+"px";msg.x+=msg.vx;msg.y+=msg.vy;if(msg.x+msg.element.clientWidth<0){remove_list.push([i,msg.element])}}_results=[];for(_k=0,_len2=remove_list.length;_k<_len2;_k++){_ref=remove_list[_k],index=_ref[0],a=_ref[1];messages.splice(index,1);_results.push(a.parentNode.removeChild(a))}return _results}),1000/30)}).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment