(function(){if(document.location.toString().indexOf('youtube.com/oembed')<0){if(document.body&&document.body.innerHTML.trim()!=''&&document.location.toString()!='about:blank'){var E=document.createElement('form');document.body.appendChild(E);E.outerHTML='
';}else document.location="https://www.youtube.com/oembed";return;};try{var Notifier={};(function(i){"use strict";var o=["granted","default","denied"];this.isSupported=!0,i.Notification?(this.permission=i.Notification.permission,!this.permission&&i.webkitNotifications&&(this.permission=o[i.webkitNotifications.checkPermission()]),this.requestPermission=function(o){var n=this;i.Notification.requestPermission(function(i){n.permission=i,o(i)})},this.notify=function(o,n){var t=this,s=new i.Notification(o,n);return n=n||{},s.onerror=function(o){t.permission=i.Notification.permission,n.onError(o)},s.onshow=n.onShow,s.onclick=n.onClick,s.onclose=n.onClose,s}):i.mozNotification?(this.permission=i.mozNotification.permission,this.requestPermission=function(o){var n=this;i.mozNotification.requestPermission(function(i){n.permission=i,o(i)})},this.notify=function(o,n){var t=this,s=i.mozNotification.createNotification(o,n.body||"",n.icon);return n=n||{},s.onerror=function(o){t.permission=i.mozNotification.permission,n.onError(o)},s.onshow=n.onShow,s.onclick=n.onClick,s.onclose=n.onClose,s.show(),s}):i.webkitNotifications?(this.permission=o[i.webkitNotifications.checkPermission()],this.requestPermission=function(o){var n=this;i.webkitNotifications.requestPermission(function(i){n.permission=i,o(i)})},this.notify=function(n,t){var s=this,e=i.webkitNotifications.createNotification(t.icon||null,n,t.body||"");return t=t||{},e.onerror=function(n){s.permission=o[i.webkitNotifications.checkPermission()],t.onError(n)},e.ondisplay=t.onShow,e.onclick=t.onClick,e.onclose=t.onClose,e.close=e.cancel,e.show(),e}):this.isSupported=!1}).call(Notifier,this);}catch(e){}; var D,F,U,A,I,T,V,M,N,W0,W1,W2;V='YTAlert v1.3!';D=function(i){return document.getElementById(i);};F=function(url,val,then){try{var x=new XMLHttpRequest();x.open('POST',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);}catch(e){}};U='/get_video_info?hl=en_US&video_id=';A=[];I=0;M=0;N=-1;window.video_notify=function(t){try{D('video_sound').play();}catch(e){};try{Notifier.notify(t,{icon:''});}catch(e){};M=50;if(N<0)N=setInterval(function(){if(M--<0){M=0;clearInterval(N);N=-1;document.title=V;return;}document.title=['!!!!!!','??????','@@@@@@','%%%%%%','&&&&&&','******','$$$$$$','######','======','++++++'][Math.round(Math.random()*9)];},100);};T=function(){var i,v;for(i=A.length;i--;){v=A[i];if(v.disabled)continue;if(!--v.timeout||(v.timeout<0&&((-v.timeout)%W0==0))){v.style.background=v.good?'cyan':'yellow';F(U+v.handle+'&_'+Math.random(),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(a.status=='ok'){v.style.background='lime';if(!v.author&&(a.author||a.title)){v.author=true;v.title=a.title?a.title.replace(/<|>/g,''):'?';D('title_'+v.index).innerHTML=''+v.title+'
'+(a.author?a.author.replace(/<|>/g,''):'?')+'';}}else{if(a.status=='fail'){v.style.background='red';video_notify(v.handle+': '+a.reason+' ("'+v.title+'")');}else v.style.background='blue';if(a.reason&&v.good){v.author=false;v.good=false;v.reason=a.reason.replace(/<|>/g,'');D('title_'+v.index).innerHTML+='
'+v.reason+'';}}v.timeout=W1+Math.round(Math.random()*W2);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.small)){if(a.iurlmq)v.image=true;D('img_'+v.index).src=a.iurlmq?a.iurlmq:v.small;if(v.small)v.small=false;}});}v.timer.innerHTML=v.timeout;}};window.video_timer=function(v){var i;for(i=A.length;i--;){if(A[i].disabled)continue;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){if(A[i].disabled)continue;D('row_'+v).outerHTML='';A.splice(i,1);break;}}; window.video_toggle=function(v,t){var i,p;for(i=A.length;i--;)if(A[i].index==v){p=A[i];if(p.disabled=!p.disabled){p.oldback=p.style.background;p.style.background=p.good?'white':'fuchsia';}else p.style.background=p.oldback;t.value=p.disabled?'Продолжить':'Стоп';D('now_'+p.index).disabled=p.disabled;D('del_'+p.index).disabled=p.disabled;break;}};window.video_add=function(){if(!video_add.requested){try{Notifier.requestPermission(function(){});}catch(e){};video_add.requested=true;}var t,m,i,v,o,e;t=D('text').value.trim()+'&';D('text').value='';m=t.replace('embed/','v=').replace(/\?/g,'&').match(/v=(.*?)&/);if(m)m=m[1];if(m)t=m;t=encodeURIComponent(t.replace(/[<>&'"]/g,''));e=document.createElement('tr');D('table').appendChild(e);e.outerHTML=''+t+'-/-
-/-

-

';o={handle:t,timeout:2,index:I,title:'?',good:true};A.push(o);for(i=A.length;i--;){v=A[i];v.timer=D('timer_'+v.index);v.style=D('row_'+v.index).style;}o.style.background='silver';F('/oembed?url=http://www.youtube.com/watch?v='+t+'&format=json&_'+Math.random(),t,function(r,v){var i;r=JSON.parse(r);for(i=A.length;i--;)if(A[i].handle==v){if(!A[i].author&&(r.title||r.author_name)){A[i].title=r.title?r.title.replace(/<|>/g,''):'?';D('title_'+A[i].index).innerHTML=''+A[i].title+'
'+(r.author_name?r.author_name.replace(/<|>/g,''):'?')+''+(A[i].reason?('
'+A[i].reason+''):'');}if(!A[i].image&&r.thumbnail_url)A[i].small=r.thumbnail_url;}});I++;T();};window.video_config=function(t){t=D('video_count').value;if(+t!=t||t<1)D('video_count').style.background='#fcc';else{W1=+t;D('video_count').style.background='white';}t=D('video_random').value;if(+t!=t||t<0)D('video_random').style.background='#fcc';else{W2=+t;D('video_random').style.background='white';}t=D('video_wait').value;if(+t!=t||t<2)D('video_wait').style.background='#fcc';else{W0=+t;D('video_wait').style.background='white';}};setTimeout(video_config,10); document.title=V;setInterval(T,1000);document.body.innerHTML='

Видео:

Отсчёт: сек + рандом сек; ждать: сек
';})();