(function(){ var D,F,U,A,I,T; D=function(i){return document.getElementById(i);}; F=function(url,val,then){var x=new XMLHttpRequest();x.open('GET',url,true);x.overrideMimeType('text/plain; charset=x-user-defined');x.onreadystatechange=function(){if(x.readyState==4){if(x.status==200){if(then)then(x.responseText,val);}}};x.send(null);}; U='https://www.youtube.com/get_video_info?hl=en_US&video_id='; A=[]; I=0; T=function(){ var i,v; for(i=A.length;i--;){ v=A[i]; if(!--v.timeout){ v.style.background='yellow'; F(U+v.handle,v,function(r,v){ var a,i,j; r=r.split('&'); a={}; for(i=r.length;i--;){ j=r[i].split('='); a[j[0]]=decodeURIComponent(j[1]).replace(/\+/g,' '); } if(!v.author&&(a.author||a.title)){ v.author=1; D('title_'+v.index).innerHTML=''+(a.title?a.title.replace(/<|>/g,''):'?')+'
'+(a.author?a.author.replace(/<|>/g,''):'?')+''; } if(a.status=='ok'){ v.style.background='lime'; }else{ if(a.status=='fail')v.style.background='red'; else v.style.background='blue'; if(a.reason){ v.author=false; D('title_'+v.index).innerHTML=''+a.reason.replace(/<|>/g,'')+''; } } if(v.status!=a.status){ v.status=a.status; D('status_'+v.index).innerHTML=a.status.replace(/<|>/g,'').toUpperCase(); } if(!v.image&&a.iurlmq){ v.image=1; D('img_'+v.index).src=a.iurlmq; } }); } v.timer.innerHTML=v.timeout; } } window.video_timer=function(v){ var i; for(i=A.length;i--;)if(A[i].index==v)A[i].timeout=1; T(); } window.video_delete=function(v){ var i; for(i=A.length;i--;)if(A[i].index==v){ D('row_'+v).outerHTML=''; A.splice(i,1); break; } } window.video_add=function(){ var t,m,i,v; t=D('text').value+'&'; D('text').value=''; m=t.match(/v=(.*?)&/); if(m)m=m[1]; if(m)t=m; t=encodeURIComponent(t.replace(/<|>|&/g,'')); //console.log(t); D('table').innerHTML+=' '+t+' -/-
-/-

-

'; A.push({ handle:t, timeout:4, index:I, }); for(i=A.length;i--;){v=A[i]; v.timer=D('timer_'+v.index); v.style=D('row_'+v.index).style; } I++; T(); } setInterval(T,1000); document.body.innerHTML='

Video: '; })();