假油管的助手

修复了油管的很多问题。注意:这个脚本不是给真的油管使用。【重要提醒】在确保所有的用户都能安全访问前,此脚本暂不自带访问地址。

当前为 2018-04-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Fake-Youtube Helper
  3. // @name:zh-CN 假油管的助手
  4. // @namespace https://greasyfork.org/users/159546
  5. // @version 1.3.3
  6. // @description Fix so much problem. Caution: This script is not for really Youtube.
  7. // @description:zh-CN 修复了油管的很多问题。注意:这个脚本不是给真的油管使用。【重要提醒】在确保所有的用户都能安全访问前,此脚本暂不自带访问地址。
  8. // @author LEORChn
  9. // @include *:8700/*
  10. // @run-at document-start
  11. // @grant none
  12. // ==/UserScript==
  13. var vip,fun;
  14. (function(){
  15. recheck();
  16. })();
  17. function recheck(){ doEvents();
  18. var a=ft('a');
  19. for(var i=0,len=a.length;i<len;i++)
  20. if(gfun(a[i].href)=='testtube'){
  21. start();
  22. return;
  23. }
  24. setTimeout(recheck,500);
  25. }
  26. function start(){
  27. initPlayServer();
  28. fun=gfun(location.href);
  29. switch(fun){
  30. case'watch':
  31. auto_expand();
  32. case'user':
  33. case'channel':
  34. fix_player();
  35. case'results':
  36. case'':
  37. fix_watch_page_link();
  38. fix_img();
  39. break;
  40. }
  41. addfeature();
  42. }
  43. function fix_watch_page_link(){
  44. var ip=vip.split('//')[1],hexip='';
  45. for(var i=0,len=4,h=ip.split(':')[0].split('.');i<len;i++) hexip+=(h[i]>15?'':'0')+parseInt(h[i],10).toString(16);
  46. for(var a=ft('a'),i=a.length-1;i>=0;i--)
  47. if(a[i] && a[i].href.indexOf(ip)>0)
  48. if(!funny_2_do(a[i]))
  49. a[i].href=a[i].href.replace(vip,'')+'&pid='+hexip;
  50. //for(var a=fc('blank'),i=a.length-1;i>=0;i--) a[i].remove();
  51. }
  52. function fix_img(){
  53. for(var a=ft('img'),i=0,len=a.length;i<len;i++){
  54. var tmp=a[i].getAttribute('data-thumb');
  55. if(tmp) a[i].src=tmp;
  56. }
  57. }
  58. function fix_player(){
  59. var a,vid;
  60. switch(fun){
  61. case'user':case'channel':a=fv('upsell-video');if(!a)return;vid=a.getAttribute('data-video-id');break;
  62. case'watch':a=fix_fullpage();vid=gvid(); fc('meh')[0].className=''; break;
  63. }
  64. vp=ct('video');
  65. a.appendChild(vp);
  66. vp.outerHTML='<video id="leorvp" src="'+vip+'/live?v='+vid+'" style="width:100%;height:100%" controls="controls" autoPlay>Failed</video>';
  67. a.className=a.className.replace('off-screen-target','');
  68. for(var i=0,b=ft('button'),len=b.length;i<len;i++) if(b[i].parentElement.id=='watch7-player-age-gate-content'){b[i].remove();break;}
  69. a=fv('player-unavailable'); a.className=a.className.replace('player-height','');
  70. vp=a=fv('leorvp');
  71. a.onclick=function(){if(a.paused)a.play();else a.pause();};
  72. }
  73. function fix_fullpage(){
  74. var w=fv('playerbox'),o=fv('theater-background'),l=absLeft(o),t=absTop(o);
  75. if(w)return o;
  76. w=ct('div');
  77. w.id='playerbox';
  78. w.className='player-width player-height';
  79. w.style.cssText='position:absolute;left:'+l+'px;top:'+t+'px;z-index:5222';
  80. ft('body')[0].appendChild(w);
  81. var limtip=fv('player-unavailable');
  82. limtip.style.color='#ffffff';limtip.style.backgroundColor='transparent';
  83. w.appendChild(limtip);
  84. return w;
  85. }
  86. function auto_expand(){
  87. var vdetail=fv('action-panel-details');
  88. vdetail.className=vdetail.className.replace('yt-uix-expander-collapsed','');
  89. }
  90. function initPlayServer(){
  91. for(var a=ft('a'),i=0,len=a.length,fstr=0;i<len;i++){
  92. fstr=a[i].href.indexOf('/watch?');
  93. if(fstr>0){
  94. vip=a[i].href.substring(0,fstr);
  95. return;
  96. }
  97. }
  98. gbakip();
  99. }
  100. function gbakip(){
  101. if(location.href.indexOf('pid=')==0)return;
  102. var ip=location.href.split('pid=')[1].split('&')[0].match(/[0-9a-fA-F]{2}/g);
  103. for(var i=0,len=4;i<4;i++) ip[i]=parseInt(ip[i],16);
  104. vip='http://'+ip.join('.')+':9999';
  105. }
  106. function gfun(url){return url.split('?')[0].split('/')[3];}
  107. function gvid(){return location.href.split('v=')[1].split('&')[0];}
  108. function fv(id){return document.getElementById(id);}
  109. function ft(tag){return document.getElementsByTagName(tag);}
  110. function fc(cname){return document.getElementsByClassName(cname);}
  111. function ct(tag,to){to=document.createElement(tag);return to;}
  112. function tip(s){console.log(s);}
  113. function doEvents(){console.log('doEvents');}
  114. function absTop(e,l){l=l?l:0;return e.offsetParent==null?l:absTop(e.offsetParent,l+e.offsetTop);}
  115. function absLeft(e,l){l=l?l:0;return e.offsetParent==null?l:absLeft(e.offsetParent,l+e.offsetLeft);}
  116. //----- -----
  117. var vp,ctl;
  118. function addfeature(){
  119. switch(fun){
  120. case'watch':
  121. initPlayerControl();
  122. }
  123. funny();
  124. }
  125. function initPlayerControl(){
  126. fv('placeholder-player').outerHTML+='<div id="vpctl" class="player-width"></div>';
  127. ctl=fv('vpctl');
  128. vpctl.onselectstart=function(){return false;};
  129. vpctl.style.cursor='default';
  130. vshareEntry(); loopEntry(); downloadEntry(); fullPageEntry(); playSpeedEntry();
  131. }
  132. function vshareEntry(){
  133. var n=ct('a');
  134. n.onclick=fc('action-panel-trigger-share')[0].onclick=function(){prompt('Press Ctrl+C','http://youtu.be/'+gvid());};
  135. n.innerText='share, ';
  136. ctl.appendChild(n);
  137. n=ct('a');
  138. n.onclick=function(){prompt('Press Ctrl+C','http://youtu.be/'+gvid()+'?t='+parseInt(vp.currentTime)+'s');};
  139. n.innerText='with timestamp';
  140. ctl.appendChild(n);
  141. }
  142. function loopEntry(){
  143. var n=ct('text');
  144. n.innerHTML='<input type="checkbox" id="looper" /><text id="loopertext">loop </text>';
  145. ctl.appendChild(n);
  146. fv('looper').onchange=loopStatOC;
  147. fv('loopertext').onclick=loopStat;
  148. }
  149. function loopStat(){ var e=fv('looper'); e.checked=!e.checked; loopStatOC(); }
  150. function loopStatOC(){ vp.loop=fv('looper').checked; }
  151. function downloadEntry(){
  152. var n=ct('text');
  153. n.innerHTML='<a id="vdlgo" target="_blank">Download</a><select id="vdltype" style="width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">'+
  154. '<option>Video</option><option>Audio</option><option>Video (Live-Play Source)</option></select>';
  155. ctl.appendChild(n);
  156. download_seturl();
  157. n=fv('vdltype');
  158. n.onclick=download_seturl;
  159. }
  160. function download_seturl(){
  161. var dl=vip+'/download?v='+gvid()+'&type=',vdlgo=fv('vdlgo');
  162. switch(fv('vdltype').selectedIndex){
  163. case 0:vdlgo.href=dl+'video';break;
  164. case 1:vdlgo.href=dl+'audio';break;
  165. case 2:vdlgo.href=fv('leorvp').src;
  166. }
  167. }
  168. function playSpeedEntry(){
  169. var n=ct('text');
  170. n.innerHTML='Playback speed<select id="vpps"><option>0.5</option><option>0.8</option><option selected>1</option>'+
  171. '<option>1.2</option><option>1.3</option><option>1.5</option><option>2</option></select>';
  172. ctl.appendChild(n); n.style.cssText='float:right';
  173. fv('vpps').onclick=function(e){vp.playbackRate=parseFloat(e.target.options[e.target.selectedIndex].innerText);};
  174. }
  175. function fullPageEntry(){
  176. var n=ct('a');
  177. n.innerText='Fullpage';
  178. n.style.cssText='float:right;margin-left:5px';
  179. ctl.appendChild(n);
  180. vp.ondblclick=n.onclick=function(){
  181. var pb=fv('playerbox'),o=fix_fullpage(),l=absLeft(o),t=absTop(o);
  182. pb.style.cssText=pb.style.cssText?'':'position:absolute;left:'+l+'px;top:'+t+'px;z-index:5222';
  183. pb.className=pb.style.cssText?'player-width player-height':'fullpagescreen';
  184. //pb.offsetHeight=pb.offsetWidth*0.5625+'px';
  185. scrollTo(0,0);
  186. };
  187. n=ct('style');
  188. n.type='text/css';
  189. n.innerHTML='.fullpagescreen{background-color:#404040;position:absolute;width:100%;height:100%;top:0px;left:0px;z-index:5222}';
  190. fv('yt-masthead-container').style.background=fv('search-btn').style.background=fv('masthead-search-terms').style.background='transparent';
  191. fv('masthead-search-term').style.color='#888';
  192. var yinsiquantixing=fc('yt-consent-banner');
  193. if(yinsiquantixing[0])yinsiquantixing[0].style.background='transparent';
  194. ft('body')[0].appendChild(n);
  195. }
  196. var interest=0;
  197. function funny(){
  198. //for(var i=0,b=fc('yt-uix-button-content'),len=b.length;i<len;i++) if(b[i]&&!b[i].parentNode.href&&isNaN(b[i].innerText)) funny_1_do(b[i]);
  199. }
  200. function funny_1_do(b){b.innerText='';b.parentNode.remove();}
  201. function funny_2_do(a){
  202. var kwg=['%u8fd1%u5e73','%u6cfd%u6c11','%u6fa4%u6c11'];
  203. for(var lv=0,llen=10,curnode=a;lv<llen;lv++)
  204. if(curnode.nodeName.toUpperCase()!="LI") curnode=curnode.parentNode;
  205. else for(var k in kwg)if(curnode.innerText.includes(unescape(kwg[k]))){
  206. tip(curnode);
  207. curnode.remove();interest++;if(interest>9)location.href='//tusenpo.github.io/FlappyFrog';//funny_3_do();
  208. return true;
  209. }
  210. return false;
  211. }
  212. function funny_3_do(){ ft('body')[0].outerHTML='<body style="background:#ffffff"><iframe style="width:88%;height:88%" src="http://map.google.cn"></iframe></body>'; }
  213. function funny_4_do(){ var n=ct('div'),b=ft('body');if(b.length==0)return;b[0].appendChild(n);n.outerHTML='<div class="blank" style="position:absolute;width:99%;height:999%;top:0px;background-color:#ffffff"></div>';}