u-Youtube

make Youtube under ur control

  1. // ==UserScript==
  2. // @name u-Youtube
  3. // @name:zh-CN 功夫制霸YouTube
  4. // @name:zh-TW 功夫製霸YouTube
  5. // @name:en u-Youtube
  6. // @name:ua u-Youtube
  7. // @name:ja カンフー支配YouTube
  8. // @name:ko 쿵푸 지배YouTube
  9. // @name:it u-Youtube
  10. // @name:de u-Youtube
  11. // @name:fr u-Youtube
  12. // @namespace https://github.com/rasso1/u-Youtube
  13. // @version 1.49
  14. // @description make Youtube under ur control
  15. // @description:zh-TW make Youtube under ur control
  16. // @description:en make Youtube under ur control
  17. // @description:ja あなたのコントロール下でYouTubeを作る
  18. // @description:ko 유튜브를 당신의 통제하에 두십시오
  19. // @description:it rendi youtube sotto il tuo controllo
  20. // @description:de Machen Sie YouTube unter Ihrer Kontrolle
  21. // @description:fr faire de youtube sous votre contrôle
  22. // @author ok!
  23. // @match https://www.youtube.com/*
  24. // @match https://youtube.com/*
  25. // @run-at document-start
  26.  
  27. // ==/UserScript==
  28.  
  29. (function() {
  30. 'use strict';
  31. var expand_description = 0;var subscription_up = 1;var del_promote = 1;var full_screen =0;
  32. var sec_sub,sec_fwd,wheel_sec,buffer_time,dark_mode,video_speed,video_quality,english_mode,comment_right,temp_buffer,temp_speed,speed_display,current_time,doc_s,icare_mode,ytplay_bezel,newVideo_check;
  33. var video_elem,v_elem;
  34. var inner_hight=window.innerHeight-parseInt(window.innerHeight/7);
  35. var inner_width=window.innerWidth*0.35;
  36.  
  37. //HTML n Script policy
  38. const overwrite_default = false; // If a default policy already exists, it might be best not to overwrite it, but to try and set a custom policy and use it to manually generate trusted types. Try at your own risk
  39. const prefix = GM_info.script.name;
  40. var passThroughFunc = function(string, sink){
  41. return string; // Anything passing through this function will be returned without change
  42. }
  43. var TTPName = "passthrough";
  44. var TTP_default, TTP = {createHTML: passThroughFunc, createScript: passThroughFunc, createScriptURL: passThroughFunc}; // We can use TTP.createHTML for all our assignments even if we don't need or even have Trusted Types; this should make fallbacks and polyfills easy
  45. var needsTrustedHTML = false;
  46. function doit(){
  47. try{
  48. if(typeof window.isSecureContext !== 'undefined' && window.isSecureContext){
  49. if (window.trustedTypes && window.trustedTypes.createPolicy){
  50. needsTrustedHTML = true;
  51. if(trustedTypes.defaultPolicy){
  52. log("TT Default Policy exists");
  53. if(overwrite_default)
  54. TTP = window.trustedTypes.createPolicy("default", TTP);
  55. else
  56. TTP = window.trustedTypes.createPolicy(TTPName, TTP); // Is the default policy permissive enough? If it already exists, best not to overwrite it
  57. TTP_default = trustedTypes.defaultPolicy;
  58.  
  59. log("Created custom passthrough policy, in case the default policy is too restrictive: Use Policy '" + TTPName + "' in var 'TTP':", TTP);
  60. }
  61. else{
  62. TTP_default = TTP = window.trustedTypes.createPolicy("default", TTP);
  63. }
  64. log("Trusted-Type Policies: TTP:", TTP, "TTP_default:", TTP_default);
  65. }
  66. }
  67. }catch(e){
  68. log(e);
  69. }
  70. }
  71. function log(...args){
  72. if("undefined" != typeof(prefix) && !!prefix)
  73. args = [prefix + ":", ...args];
  74. if("undefined" != typeof(debugging) && !!debugging)
  75. args = [...args, new Error().stack.replace(/^\s*(Error|Stack trace):?\n/gi, "").replace(/^([^\n]*\n)/, "\n")];
  76. console.log(...args);
  77. }
  78. doit();
  79. //end Greasy Fork镜像 Trusted-Types Helper Author Benjamin Philipp
  80.  
  81.  
  82. var youtube_hand = {
  83. message_box: {
  84. show: function(message) {
  85. clearTimeout(ytplay_bezel);
  86. document.querySelector("#container > #movie_player .ytp-bezel-text").innerHTML = message;
  87. document.querySelector("#container > #movie_player .ytp-bezel-text").parentNode.parentNode.style.display = "";
  88. document.querySelector("#container > #movie_player .ytp-bezel-text").parentNode.parentNode.classList.remove("ytp-bezel-text-hide");
  89. ytplay_bezel = setTimeout(youtube_hand.message_box.hide, 2500);
  90. },
  91. hide: function() {
  92. document.querySelector("#container > #movie_player .ytp-bezel-text").innerText = "";
  93. document.querySelector("#container > #movie_player .ytp-bezel-text").parentNode.parentNode.style.display = "none";
  94. }
  95. },
  96. dark_eye:function (){
  97. if(localStorage.getItem('icare_mode')==1){
  98. document.querySelector("html").style="font-size:13px;font-family: Roboto, Arial, sans-serif;"
  99. }
  100. else {document.querySelector("html").style="font-size:10px;font-family: Roboto, Arial, sans-serif;"}
  101.  
  102. if(localStorage.getItem('dark_mode')==1){
  103. if(!document.querySelector("html").hasAttribute("dark")){
  104. document.querySelector("html").setAttribute("dark",true);}
  105. }
  106. else if(document.querySelector("html").hasAttribute("dark"))
  107. {document.querySelector("html").removeAttribute("dark")}
  108. if(localStorage.getItem("comment_right")==1&&document.querySelector("#columns #primary #primary-inner #sections")&&document.querySelector("#secondary #secondary-inner")&&!document.fullscreenElement){
  109.  
  110. //评论右上移
  111. document.querySelector("#columns #primary #primary-inner #sections").style="width:"+inner_width+"px;height:"+inner_hight+"px;overflow-y:auto";
  112. document.querySelector("#columns #primary #primary-inner #sections").classList.add('standardized-themed-scrollbar');
  113. // document.querySelector("#columns #primary #primary-inner #sections")
  114. document.querySelector("#secondary #secondary-inner").append(document.querySelector("#columns #primary #primary-inner #sections"));
  115. document.querySelector("#page-manager #columns > #secondary > #secondary-inner > #sections").onscroll=function(){
  116. document.querySelector("body").style.overflow="hidden";
  117. }
  118. document.querySelector("#page-manager #columns > #secondary > #secondary-inner > #sections").onpointerleave=function(){
  119. document.querySelector("body").style.overflow="";
  120. }
  121. /*
  122. document.querySelector("#page-manager #columns > #secondary > #secondary-inner > #sections").onscroll=function(){
  123. let comment_height= parseInt(document.querySelector("#page-manager #columns > #secondary > #secondary-inner > #sections").style.height);
  124. comment_height+=1;
  125. document.querySelector("#page-manager #columns > #secondary > #secondary-inner > #sections").style.height = comment_height+"px";
  126. document.querySelector("#page-manager #columns > #secondary > #secondary-inner > #sections").style.float="right";
  127. };
  128. */
  129. //related 左下移
  130. document.querySelector("#columns #primary #primary-inner").append(document.querySelector("#secondary #secondary-inner #related"));
  131.  
  132.  
  133. // 监听全屏事件
  134. document.addEventListener("fullscreenchange", function () {
  135. if(localStorage.getItem("comment_right")==1){
  136. if (document.fullscreenElement) {
  137. // 视频进入全屏
  138. document.querySelector("#page-manager #columns > #secondary > #secondary-inner > #sections").style="width:auto;height:"+window.innerHeight*1+"px;overflow-y:auto";
  139. //评论左下移
  140. //localStorage.setItem('comment_right',0);
  141. /*
  142. document.querySelector("#columns #primary #primary-inner").append(document.querySelector("#secondary #secondary-inner #sections"));
  143. //related 右上移
  144. document.querySelector("#secondary #secondary-inner").append(document.querySelector("#related"));
  145. document.querySelector("#secondary #secondary-inner #sections").remove();
  146. document.querySelector("#columns #primary #primary-inner #sections").style="width:"+window.innerWidth*0.60+"px;height:"+window.innerHeight*1+"px;overflow-y:auto";
  147. document.querySelector("#columns #primary #primary-inner #sections").classList.add('standardized-themed-scrollbar');
  148. */
  149. //localStorage.setItem('comment_right',1);
  150. } else {
  151. // 视频退出全屏
  152. document.querySelector("#page-manager #columns > #secondary > #secondary-inner > #sections").style="width:"+inner_width+"px;height:"+inner_hight+"px;overflow-y:auto";
  153.  
  154. // if(document.getElementById("comment_to").checded==1){
  155. // localStorage.setItem('comment_right',1);}
  156. }
  157. }
  158. });
  159.  
  160. }
  161. // else if(document.querySelector("yt-live-chat-app")){document.querySelector("#secondary #secondary-inner").append(document.querySelector("yt-live-chat-app"))}
  162. },
  163. dark_eye1:function (){
  164. if(localStorage.getItem('dark_mode')==1){
  165. var style_type = document.createElement("style");style_type.id = "style_type";
  166. style_type.innerHTML = `#end > div.dropdown-hover > div{font-size:12px;color:#bbb !important;background-color:#202020 !important;}
  167. #end > div.dropdown-hover > button{background-color:#222 !important;} #end > div.dropdown-hover path{fill:transparent !important;stroke:white !important;}
  168. #end > div.dropdown-hover > div > div{color:#aaa !important;background-color:#202020 !important;}
  169. #end > div.dropdown-hover > div > div p{font-size:12px;color:#bbb !important;background-color:#202020 !important;}
  170. .dropdown-hover button div{font-size:12px;color:#aaa !important;background-color:#333 !important;}
  171. #sec_sub,#sec_fwd,#wheel_sec,#buffer_time{font-size:12px;color:#bbb !important;background-color:#333 !important;border-radius:5px;}`;
  172. document.head.appendChild(style_type);
  173. }
  174. },
  175.  
  176. //播放设置
  177. play_menu:function(){
  178. /*
  179. const escapeHTMLPolicy = trustedTypes.createPolicy("myEscapePolicy", {
  180. createHTML: (string) => string.replace(/</g, "&lt;"),
  181. });
  182. const escaped = escapeHTMLPolicy.createHTML(`<button style="border:none;outline:none;background-color:#fff;height:37px;width:37px;margin-right:10px;" aria-label="缓存/速度设置"><svg viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet" focusable="false" style="pointer-events: none; display: block; width: 100%; height: 100%;"><g class="style-scope yt-icon">
  183. <path d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.1-1.65c.2-.15.25-.42.13-.64l-2-3.46c-.12-.22-.4-.3-.6-.22l-2.5 1c-.52-.4-1.08-.73-1.7-.98l-.37-2.65c-.06-.24-.27-.42-.5-.42h-4c-.27 0-.48.18-.5.42l-.4 2.65c-.6.25-1.17.6-1.7.98l-2.48-1c-.23-.1-.5 0-.6.22l-2 3.46c-.14.22-.08.5.1.64l2.12 1.65c-.04.32-.07.65-.07.98s.02.66.06.98l-2.1 1.65c-.2.15-.25.42-.13.64l2 3.46c.12.22.4.3.6.22l2.5-1c.52.4 1.08.73 1.7.98l.37 2.65c.04.24.25.42.5.42h4c.25 0 .46-.18.5-.42l.37-2.65c.6-.25 1.17-.6 1.7-.98l2.48 1c.23.1.5 0 .6-.22l2-3.46c.13-.22.08-.5-.1-.64l-2.12-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z" fill="transparent" stroke="black"></path>
  184. </g></svg>
  185. </button>
  186.  
  187. <div style="background:#fff;border-radius: 10px;left: -160px;right: 0;margin-left: 0;margin-right: -100px;padding-top: 10px;" class="dropdown-box fadeInDown"><div class="item clearfix" style="border-radius:10px;"><p style="margin:10px auto;font-size:18px;"><span class="mandarin invisible">播放设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="english">Playback Setting&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font size=2>Chs </font><input style="margin:auto" id="english_mode" class="switch switch-anim" type="checkbox" checked></p>
  188. <div style="margin:10px auto;font-size:12px;"><hr /><hr /></div>
  189. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible" style="margin:10px auto;font-size:16px;">当前速度:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="english">current speed:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="speed_display"></span></p>
  190. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible">选择播放速度:&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="english">specify spee<font color=#5bb7fe>d</font>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><button id="speed_button" style="background-color: #5bb7fe;border-radius:5px;color:white;font-size:12px;"> &nbsp; 1x&nbsp; </button></p><input type="range" min="0" max="100" value="25" class="slider" id="speed_slider"><br /><br />
  191. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible">跳过片头秒数:&nbsp;&nbsp;&nbsp;</span><span class="english">skip the title:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input type="text" id="sec_fwd" style="width:40px;height:12px;vertical-align: middle;padding: 5px;background-color:#fff;border: 2px solid #ddd;border-radius:5px;font-size:12px;" placeholder="seconds">
  192. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible">跳过片尾秒数:&nbsp;&nbsp;&nbsp;</span><span class="english">skip the end:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input type="text" id="sec_sub" style="width:40px;height:12px;vertical-align: middle;padding: 5px;background-color: #fff;border: 2px solid #ddd;border-radius:5px;font-size:12px;" placeholder="seconds"></p>
  193. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible">鼠标滚动秒数:&nbsp;&nbsp;&nbsp;</span><span class="english">mouse scroll:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input type="text" id="wheel_sec" style="width:40px;height:12px;vertical-align: middle;padding: 5px;background-color: #fff;border: 2px solid #ddd;border-radius:5px;font-size:12px;" placeholder="seconds"></p>
  194. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible">暂停缓存秒数:&nbsp;&nbsp;&nbsp;</span><span class="english">paus<font color=#5bb7fe>e</font> n cashing:&nbsp;&nbsp;&nbsp;&nbsp;</span><input type="text" id="buffer_time" style="width:40px;height:12px;vertical-align: middle;padding: 5px;background-color: #fff;border: 2px solid #ddd;border-radius:5px;font-size:12px;" placeholder="seconds"></p>
  195. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible">播放质量:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class="english">specify resolution&nbsp;</span> <select id="video_quality" style="border-radius:5px;"><option value="auto">auto</option><option value="hd2160">4K 2160p</option><option value="hd1440">HD 1440p</option><option value="hd1080">HD 1080p</option><option value="hd720">720p</option> <option value="large">480p</option><option value="medium">360p</option><option value="small">240p</option><option value="tiny">144p</option> </select></p>
  196. <p style="margin:10px auto 20px auto;font-size:16px;"><span class="mandarin invisible">评论载右:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="english">comments to right:&nbsp;&nbsp;&nbsp;</span><input style="margin:auto" id="comment_to" class="switch switch-anim" type="checkbox" checked></p>
  197. <p style="margin:10px auto 20px auto;font-size:16px;"><span class="mandarin invisible">眼保模式 :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="english">iCare mode:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input style="margin:auto" id="icare_mode" class="switch switch-anim" type="checkbox" checked></p>
  198. <p style="margin:10px auto 20px auto;font-size:16px;"><span class="mandarin invisible">暗夜模式 :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="english">dark mode:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input style="margin:auto" id="dark_mode" class="switch switch-anim" type="checkbox" checked></p>
  199. </div></div>
  200.  
  201. <style>#speed_slider {width: 175px;}.invisible {display: none;}.ytd-feed-filter-chip-bar-renderer.style-scope{z-index:999 !important;}.fadeInDown{-webkit-animation:fadeInDown .5s .2s ease both;-moz-animation:fadeInDown .5s .2s ease both}@-webkit-keyframes fadeInDown{0%{opacity:0;-webkit-transform:translateY(-10px)}100%{opacity:1;-webkit-transform:translateY(0)}}@-moz-keyframes fadeInDown{0%{opacity:0;-moz-transform:translateY(-10px)}100%{opacity:1;-moz-transform:translateY(0)}}.dropdown{position:relative}.dropdown-box{display:none;position:absolute;z-index:999999999}.dropdown-box.top{bottom:100%;padding-bottom:10px;left:50%;margin-left:-80px}.dropdown-box.bottom{top:100%;padding-top:10px;left:50%;margin-left:-80px}.dropdown-box.left{left:100%;padding-left:10px;bottom:0}.dropdown-box.right{right:100%;padding-right:10px;bottom:0}.dropdown-box .item{padding:10px;width:250px;border-radius:2px}.dropdown-hover{position:relative}.dropdown-hover:hover .dropdown-box{display:block}</style>
  202. <style>a {color: #670000;}.switch {width: 26px;height: 13px;position: relative;border: 1px solid #dfdfdf;background-color: #fdfdfd;box-shadow: #dfdfdf 0 0 0 0 inset; border-radius: 18px;background-clip: content-box;display: inline-block;-webkit-appearance: none;user-select: none;outline: none;} .switch:before { content: '';width: 13px;height: 13px;position: absolute;top: 0;left: 0;border-radius: 12px;background-color: #fff;box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);}.switch:checked {border-color: #5bb7fe;box-shadow: #5bb7fe 0 0 0 16px inset;background-color: #5bb7fe;}.switch:checked:before {left: 15px;}.switch.switch-anim {transition: border cubic-bezier(0, 0, 0, 1) 0.4s, box-shadow cubic-bezier(0, 0, 0, 1) 0.4s;}.switch.switch-anim:before {transition: left 0.3s;}.switch.switch-anim:checked {box-shadow: #5bb7fe 0 0 0 14px inset;background-color: #5bb7fe;transition: border ease 0.4s, box-shadow ease 0.4s, background-color ease 1.2s;}.switch.switch-anim:checked:before {transition: left 0.3s;}.text-red {color: #aaa;}</style>
  203. <style>.standardized-themed-scrollbar::-webkit-scrollbar {
  204. width: 1em;
  205. }
  206. .standardized-themed-scrollbar::-webkit-scrollbar-track {
  207. -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  208. }
  209. .standardized-themed-scrollbar::-webkit-scrollbar-thumb {
  210. background-color: darkgrey;
  211. height: 56px;border-radius: 10px;border: 4px solid transparent;background-clip: content-box;
  212. }</style>`);
  213. */
  214.  
  215. // const policy = trustedTypes.createPolicy('default',{createHTML: (string) => string});
  216.  
  217. // Use the policy to assign HTML safely
  218. // const unsafeHtml = "<img>";
  219. //const safeHtml = policy.createHTML(unsafeHtml);
  220. //document.querySelector("#placeholder").innerHTML = safeHtml;
  221.  
  222. /*
  223. const policy = trustedTypes.createPolicy('default', {
  224. createHTML: (string) => string
  225. });
  226.  
  227. // Use the policy to assign HTML safely
  228. const unsafeHtml = "<img>";
  229. const safeHtml = policy.createHTML(unsafeHtml);
  230. document.querySelector("#title").innerHTML = safeHtml;
  231. */
  232.  
  233.  
  234.  
  235.  
  236. var html_app = document.createElement("div");
  237.  
  238. // html_app.innerHTML =escaped; const unsafeHtml =`
  239. html_app.innerHTML =`
  240. <button style="border:none;outline:none;background-color:#fff;height:37px;width:37px;margin-right:10px;" aria-label="缓存/速度设置"><svg viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet" focusable="false" style="pointer-events: none; display: block; width: 100%; height: 100%;"><g class="style-scope yt-icon">
  241. <path d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.1-1.65c.2-.15.25-.42.13-.64l-2-3.46c-.12-.22-.4-.3-.6-.22l-2.5 1c-.52-.4-1.08-.73-1.7-.98l-.37-2.65c-.06-.24-.27-.42-.5-.42h-4c-.27 0-.48.18-.5.42l-.4 2.65c-.6.25-1.17.6-1.7.98l-2.48-1c-.23-.1-.5 0-.6.22l-2 3.46c-.14.22-.08.5.1.64l2.12 1.65c-.04.32-.07.65-.07.98s.02.66.06.98l-2.1 1.65c-.2.15-.25.42-.13.64l2 3.46c.12.22.4.3.6.22l2.5-1c.52.4 1.08.73 1.7.98l.37 2.65c.04.24.25.42.5.42h4c.25 0 .46-.18.5-.42l.37-2.65c.6-.25 1.17-.6 1.7-.98l2.48 1c.23.1.5 0 .6-.22l2-3.46c.13-.22.08-.5-.1-.64l-2.12-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z" fill="transparent" stroke="black"></path>
  242. </g></svg>
  243. </button>
  244.  
  245. <div style="background:#fff;border-radius: 10px;left: -160px;right: 0;margin-left: 0;margin-right: -100px;padding-top: 10px;" class="dropdown-box fadeInDown"><div class="item clearfix" style="border-radius:10px;"><p style="margin:10px auto;font-size:18px;"><span class="mandarin invisible">播放设置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="english">Playback Setting&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><font size=2>Chs </font><input style="margin:auto" id="english_mode" class="switch switch-anim" type="checkbox" checked></p>
  246. <div style="margin:10px auto;font-size:12px;"><hr /><hr /></div>
  247. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible" style="margin:10px auto;font-size:16px;">当前速度:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="english">current speed:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="speed_display"></span></p>
  248. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible">选择播放速度:&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="english">specify spee<font color=#5bb7fe>d</font>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><button id="speed_button" style="background-color: #5bb7fe;border-radius:5px;color:white;font-size:12px;"> &nbsp; 1x&nbsp; </button></p><input type="range" min="0" max="100" value="25" class="slider" id="speed_slider"><br /><br />
  249. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible">跳过片头秒数:&nbsp;&nbsp;&nbsp;</span><span class="english">skip the title:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input type="text" id="sec_fwd" style="width:40px;height:12px;vertical-align: middle;padding: 5px;background-color:#fff;border: 2px solid #ddd;border-radius:5px;font-size:12px;" placeholder="seconds">
  250. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible">跳过片尾秒数:&nbsp;&nbsp;&nbsp;</span><span class="english">skip the end:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input type="text" id="sec_sub" style="width:40px;height:12px;vertical-align: middle;padding: 5px;background-color: #fff;border: 2px solid #ddd;border-radius:5px;font-size:12px;" placeholder="seconds"></p>
  251. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible">鼠标滚动秒数:&nbsp;&nbsp;&nbsp;</span><span class="english">mouse scroll:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input type="text" id="wheel_sec" style="width:40px;height:12px;vertical-align: middle;padding: 5px;background-color: #fff;border: 2px solid #ddd;border-radius:5px;font-size:12px;" placeholder="seconds"></p>
  252. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible">暂停缓存秒数:&nbsp;&nbsp;&nbsp;</span><span class="english">paus<font color=#5bb7fe>e</font> n cashing:&nbsp;&nbsp;&nbsp;&nbsp;</span><input type="text" id="buffer_time" style="width:40px;height:12px;vertical-align: middle;padding: 5px;background-color: #fff;border: 2px solid #ddd;border-radius:5px;font-size:12px;" placeholder="seconds"></p>
  253. <p style="margin:10px auto;font-size:16px;"><span class="mandarin invisible">播放质量:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class="english">specify resolution&nbsp;</span> <select id="video_quality" style="border-radius:5px;"><option value="auto">auto</option><option value="hd2160">4K 2160p</option><option value="hd1440">HD 1440p</option><option value="hd1080">HD 1080p</option><option value="hd720">720p</option> <option value="large">480p</option><option value="medium">360p</option><option value="small">240p</option><option value="tiny">144p</option> </select></p>
  254. <p style="margin:10px auto 20px auto;font-size:16px;"><span class="mandarin invisible">评论载右:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="english">comments to right:&nbsp;&nbsp;&nbsp;</span><input style="margin:auto" id="comment_to" class="switch switch-anim" type="checkbox" checked></p>
  255. <p style="margin:10px auto 20px auto;font-size:16px;"><span class="mandarin invisible">眼保模式 :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="english">iCare mode:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input style="margin:auto" id="icare_mode" class="switch switch-anim" type="checkbox" checked></p>
  256. <p style="margin:10px auto 20px auto;font-size:16px;"><span class="mandarin invisible">暗夜模式 :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="english">dark mode:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><input style="margin:auto" id="dark_mode" class="switch switch-anim" type="checkbox" checked></p>
  257. </div></div>
  258.  
  259. <style>#speed_slider {width: 175px;}.invisible {display: none;}.ytd-feed-filter-chip-bar-renderer.style-scope{z-index:999 !important;}.fadeInDown{-webkit-animation:fadeInDown .5s .2s ease both;-moz-animation:fadeInDown .5s .2s ease both}@-webkit-keyframes fadeInDown{0%{opacity:0;-webkit-transform:translateY(-10px)}100%{opacity:1;-webkit-transform:translateY(0)}}@-moz-keyframes fadeInDown{0%{opacity:0;-moz-transform:translateY(-10px)}100%{opacity:1;-moz-transform:translateY(0)}}.dropdown{position:relative}.dropdown-box{display:none;position:absolute;z-index:999999999}.dropdown-box.top{bottom:100%;padding-bottom:10px;left:50%;margin-left:-80px}.dropdown-box.bottom{top:100%;padding-top:10px;left:50%;margin-left:-80px}.dropdown-box.left{left:100%;padding-left:10px;bottom:0}.dropdown-box.right{right:100%;padding-right:10px;bottom:0}.dropdown-box .item{padding:10px;width:250px;border-radius:2px}.dropdown-hover{position:relative}.dropdown-hover:hover .dropdown-box{display:block}</style>
  260. <style>a {color: #670000;}.switch {width: 26px;height: 13px;position: relative;border: 1px solid #dfdfdf;background-color: #fdfdfd;box-shadow: #dfdfdf 0 0 0 0 inset; border-radius: 18px;background-clip: content-box;display: inline-block;-webkit-appearance: none;user-select: none;outline: none;} .switch:before { content: '';width: 13px;height: 13px;position: absolute;top: 0;left: 0;border-radius: 12px;background-color: #fff;box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);}.switch:checked {border-color: #5bb7fe;box-shadow: #5bb7fe 0 0 0 16px inset;background-color: #5bb7fe;}.switch:checked:before {left: 15px;}.switch.switch-anim {transition: border cubic-bezier(0, 0, 0, 1) 0.4s, box-shadow cubic-bezier(0, 0, 0, 1) 0.4s;}.switch.switch-anim:before {transition: left 0.3s;}.switch.switch-anim:checked {box-shadow: #5bb7fe 0 0 0 14px inset;background-color: #5bb7fe;transition: border ease 0.4s, box-shadow ease 0.4s, background-color ease 1.2s;}.switch.switch-anim:checked:before {transition: left 0.3s;}.text-red {color: #aaa;}</style>
  261. <style>.standardized-themed-scrollbar::-webkit-scrollbar {
  262. width: 1em;
  263. }
  264. .standardized-themed-scrollbar::-webkit-scrollbar-track {
  265. -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  266. }
  267. .standardized-themed-scrollbar::-webkit-scrollbar-thumb {
  268. background-color: darkgrey;
  269. height: 56px;border-radius: 10px;border: 4px solid transparent;background-clip: content-box;
  270. }</style>
  271. `;
  272.  
  273. // const safeHtml = DOMPurify.sanitize(unsafeHtml);
  274. // const safeHtml = policy.createHTML(unsafeHtml);
  275. // safeHtml.classList.add('dropdown-hover');
  276. //document.querySelector("#placeholder").innerHTML = safeHtml;
  277. //document.querySelector("#end").appendChild(safeHtml);
  278. html_app.classList.add('dropdown-hover');
  279. document.querySelector("#end").appendChild(html_app);
  280.  
  281. //
  282. var speed_slider=document.getElementById("speed_slider"),speed_button=document.getElementById("speed_button"),
  283. y=document.getElementById("sec_sub"),z=document.getElementById("wheel_sec"),x=document.getElementById("buffer_time"),w=document.getElementById("dark_mode"),
  284. s=document.getElementById("video_quality"),v=document.getElementById("sec_fwd"),t=document.getElementById("english_mode"),c=document.getElementById("comment_to"),iii=document.getElementById("icare_mode");
  285. dark_mode = localStorage.getItem('dark_mode');comment_right = localStorage.getItem('comment_right');icare_mode = localStorage.getItem('icare_mode');
  286. var english_mode = localStorage.getItem('english_mode');
  287. speed_display=document.getElementById("speed_display");
  288. const mandarins = document.querySelectorAll('.mandarin');const englishs = document.querySelectorAll('.english');
  289.  
  290.  
  291. video_speed = localStorage.getItem('speed');sec_fwd = localStorage.getItem('sec_fwd');sec_sub = localStorage.getItem('sec_sub');
  292. wheel_sec = localStorage.getItem('wheel_sec');buffer_time = localStorage.getItem('buffer_time');
  293. video_quality = localStorage.getItem('video_quality')?localStorage.getItem('video_quality'):"auto";
  294.  
  295. english_mode = localStorage.getItem('english_mode');
  296. //判读英文菜单
  297. if(localStorage.getItem('english_mode')==1){
  298. for (const mandarin of mandarins) {
  299. mandarin.className -= ' invisible';
  300. }
  301. for (const english of englishs) {
  302. english.className += ' invisible';
  303. }
  304. }
  305.  
  306. video_speed?speed_display.innerHTML=video_speed+"x":speed_display.innerHTML="1x";
  307.  
  308. setTimeout(function (){
  309. if(video_speed&&document.querySelector('#movie_player'))
  310. document.querySelector("#movie_player > div.html5-video-container > video").playbackRate = video_speed;},4000);
  311.  
  312. speed_slider.value = localStorage.getItem('speed')*25;
  313.  
  314. speed_slider.oninput=function(){localStorage.setItem('speed',this.value/25);video_speed = localStorage.getItem('speed');video_speed?speed_display.innerHTML=video_speed+"x":speed_display.innerHTML="1x";
  315. document.querySelector("#movie_player > div.html5-video-container > video").playbackRate = video_speed;
  316. }
  317.  
  318. speed_button.onclick=function(){localStorage.setItem('speed',1);video_speed = localStorage.getItem('speed');video_speed?speed_display.innerHTML=video_speed+"x":speed_display.innerHTML="1x";
  319. document.querySelector("#movie_player > div.html5-video-container > video").playbackRate = video_speed;
  320. speed_slider.value = localStorage.getItem('speed')*25;
  321. }
  322.  
  323. sec_fwd?v.value=sec_fwd:v.value="";
  324. v.onchange=function(){localStorage.setItem('sec_fwd',this.value);sec_fwd = localStorage.getItem('sec_fwd');sec_fwd?v.value=sec_fwd:v.value="";
  325. }
  326. sec_sub?y.value=sec_sub:y.value="";
  327. y.onchange=function(){localStorage.setItem('sec_sub',this.value);sec_sub = localStorage.getItem('sec_sub');sec_sub?y.value=sec_sub:y.value="";
  328. }
  329.  
  330. wheel_sec?z.value=wheel_sec:z.value="";
  331. z.onchange=function(){localStorage.setItem('wheel_sec',this.value);wheel_sec = localStorage.getItem('wheel_sec');wheel_sec?z.value=wheel_sec:z.value="";
  332. }
  333. buffer_time?x.value=buffer_time:x.value="";
  334. x.onchange=function(){localStorage.setItem('buffer_time',this.value);buffer_time = localStorage.getItem('buffer_time');buffer_time?x.value=buffer_time:x.value="";
  335. }
  336. c.checded=comment_right; if(comment_right!=1){document.getElementById("comment_to").removeAttribute('checked');}
  337. c.onchange=function(){if(c.checked){localStorage.setItem('comment_right','1');youtube_hand.dark_eye();}
  338. else{localStorage.setItem('comment_right',0);
  339. //评论右上移
  340.  
  341. document.querySelector("#columns #primary #primary-inner").append(document.querySelector("#secondary #secondary-inner #sections"));
  342. //related 左下移
  343. document.querySelector("#secondary #secondary-inner").append(document.querySelector("#related"));
  344. document.querySelector("#secondary #secondary-inner #sections").remove();
  345.  
  346. }
  347. comment_right = localStorage.getItem('comment_right');
  348. }
  349.  
  350. iii.checded=icare_mode; if(icare_mode!=1){document.getElementById("icare_mode").removeAttribute('checked');}
  351. iii.onchange=function(){if(iii.checked){localStorage.setItem('icare_mode','1');}
  352. else{localStorage.setItem('icare_mode',0);
  353. }
  354. icare_mode = localStorage.getItem('icare_mode');
  355. }
  356.  
  357. w.checded=dark_mode; if(dark_mode!=1){document.getElementById("dark_mode").removeAttribute('checked');}
  358. w.onchange=function(){if(w.checked){localStorage.setItem('dark_mode','1');youtube_hand.dark_eye();youtube_hand.dark_eye1();}
  359. else{localStorage.setItem('dark_mode',0);
  360. document.querySelector("html").removeAttribute("dark");
  361. document.querySelector('#style_type').remove();
  362. }
  363. dark_mode = localStorage.getItem('dark_mode');
  364. }
  365. t.checded=english_mode; if(english_mode!=1){document.getElementById("english_mode").removeAttribute('checked');}
  366. t.onchange=function(){if(t.checked){localStorage.setItem('english_mode','1');
  367. for (const mandarin of mandarins) {
  368. mandarin.className -= ' invisible';}
  369. for (const english of englishs) {
  370. english.className += ' invisible';}
  371. }
  372. else{localStorage.setItem('english_mode',0);
  373. for (const mandarin of mandarins) {
  374. mandarin.className += ' invisible';}
  375. for (const english of englishs) {
  376. english.className -= ' invisible';}
  377. }
  378. english_mode = localStorage.getItem('english_mode');
  379. }
  380.  
  381. if(video_quality){
  382. for(var i=0;i<s.length;i++){
  383. if(s.options[i].value==video_quality){
  384. s.options[i].selected=true;
  385. }
  386. }
  387. }
  388. s.onchange=function (){
  389. var quality_value = s[s.selectedIndex].getAttribute("value");
  390. localStorage.setItem('video_quality',quality_value);
  391. video_quality = localStorage.getItem('video_quality');
  392. var avail_quali;var v_elem = document.querySelector("#movie_player");
  393. if((avail_quali = v_elem.getAvailableQualityLevels())&&avail_quali.indexOf(video_quality) == -1){
  394. v_elem.setPlaybackQualityRange(avail_quali[0],avail_quali[0]);
  395. }
  396. else{v_elem.setPlaybackQualityRange(video_quality,video_quality);}
  397. }
  398.  
  399. },
  400.  
  401. play_main:function (){
  402.  
  403. sec_fwd = localStorage.getItem('sec_fwd');
  404. sec_sub = localStorage.getItem('sec_sub');
  405. wheel_sec = localStorage.getItem('wheel_sec');
  406. buffer_time = localStorage.getItem('buffer_time');
  407.  
  408. var video_speed = localStorage.getItem('speed');
  409.  
  410.  
  411.  
  412.  
  413. //每3秒试执行主应用操作
  414. var main_timer = setInterval(function () {
  415. video_elem = document.querySelector("#movie_player > div.html5-video-container > video");
  416. v_elem = document.querySelector("#movie_player");
  417.  
  418. if (video_elem){
  419. newVideo_check=document.querySelector("#movie_player > div.html5-video-container > video").duration;
  420. main_opr();
  421. let videoText_check1 = setInterval(function(){
  422. if(document.querySelector("#info-text > #info-strings > yt-formatted-string")){
  423. //video_elem.currentTime=0;
  424. video_speed = localStorage.getItem('speed');
  425. if(buffer_time&&document.querySelector("#info-text > #info-strings > yt-formatted-string")){
  426. youtube_hand.message_box.show("<div>video speed "+video_speed+"x</div><div>cashe "+buffer_time+" seconds</div><div>"+document.querySelector("#info-strings > yt-formatted-string").innerText+" & "+document.querySelector("#count > ytd-video-view-count-renderer > span.view-count.style-scope.ytd-video-view-count-renderer").innerText+"</div>");
  427. }
  428. else if(document.querySelector("#info-text > #info-strings > yt-formatted-string")){
  429. youtube_hand.message_box.show("<div>video speed "+video_speed+"x</div><div>no cashe</div><div>"+document.querySelector("#info-strings > yt-formatted-string").innerText+" & "+document.querySelector("#count > ytd-video-view-count-renderer > span.view-count.style-scope.ytd-video-view-count-renderer").innerText+"</div>");
  430. }
  431. clearInterval(videoText_check1);
  432. // alert("change display");
  433.  
  434. }
  435.  
  436. }
  437. ,1000)
  438. video_elem.onloadeddata = function (){
  439. //22-11-29
  440. //newVideo_check = document.querySelector("#movie_player > div.html5-video-info-panel > div > div:nth-child(1) > span").innerText;
  441. // alert("load");
  442. let videoload_check = setInterval(function(){
  443. //删除全屏时顶部文字
  444. if(document.querySelector("#movie_player > div.ytp-chrome-top > div.ytp-title > div")){
  445. document.querySelector("#movie_player > div.ytp-chrome-top > div.ytp-title > div").remove();
  446. }
  447.  
  448. //5秒后自动全屏
  449. if (!document.fullscreenElement&&full_screen){
  450. setTimeout(function(){
  451. if (!document.fullscreenElement){
  452. document.querySelector("#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-right-controls > button.ytp-fullscreen-button.ytp-button").click();
  453. // document.querySelector("#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-right-controls > button.ytp-fullscreen-button.ytp-button").remove()
  454.  
  455. full_screen=1;
  456. }
  457.  
  458.  
  459. },5000)
  460. }
  461.  
  462. if(newVideo_check){
  463. //youtube_hand.message_box.show("onload2");
  464. clearInterval(videoload_check);}
  465. else if(newVideo_check=document.querySelector("#movie_player > div.html5-video-container > video").duration){
  466. main_opr();
  467.  
  468.  
  469.  
  470. //youtube_hand.message_box.show("onload1");
  471. setTimeout(function(){
  472. if(buffer_time&&document.querySelector("#info-text > #info-strings > yt-formatted-string")){
  473. youtube_hand.message_box.show("<div>video speed "+video_speed+"x</div><div>cashe "+buffer_time+" seconds</div><div>"+document.querySelector("#info-strings > yt-formatted-string").innerText+" & "+document.querySelector("#count > ytd-video-view-count-renderer > span.view-count.style-scope.ytd-video-view-count-renderer").innerText+"</div>");
  474. }
  475. //document.querySelector("#info-text > #info-strings > yt-formatted-string").innerText
  476. else if(document.querySelector("#info-text > #info-strings > yt-formatted-string")){
  477. youtube_hand.message_box.show("<div>video speed "+video_speed+"x</div><div>no cashe</div><div>"+document.querySelector("#info-strings > yt-formatted-string").innerText+" & "+document.querySelector("#count > ytd-video-view-count-renderer > span.view-count.style-scope.ytd-video-view-count-renderer").innerText+"</div>");
  478. }
  479. // alert("load display");
  480. },4000)
  481. setTimeout(function(){video_elem.onloadeddata = "";},3000)
  482.  
  483. clearInterval(videoload_check);
  484. }},1000);
  485.  
  486.  
  487. }
  488.  
  489. video_elem.ondurationchange = function(){
  490. //删除全屏时顶部文字
  491. if(document.querySelector("#movie_player > div.ytp-chrome-top > div.ytp-title > div")){
  492. document.querySelector("#movie_player > div.ytp-chrome-top > div.ytp-title > div").remove();
  493. }
  494.  
  495. //5秒后自动全屏
  496. if (!document.fullscreenElement&&full_screen){
  497. setTimeout(function(){
  498. if (!document.fullscreenElement){
  499. document.querySelector("#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-right-controls > button.ytp-fullscreen-button.ytp-button").click();
  500. // document.querySelector("#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-right-controls > button.ytp-fullscreen-button.ytp-button").remove()
  501.  
  502. full_screen=1;
  503.  
  504. }
  505. },5000)
  506. }
  507.  
  508. //alert("change");
  509. // if(newVideo_check == document.querySelector("#movie_player > div.html5-video-info-panel > div > div:nth-child(1) > span").innerText){}
  510. if(!newVideo_check){
  511. newVideo_check=document.querySelector("#movie_player > div.html5-video-container > video").duration;
  512. // alert("in");
  513. let videoText_check = setInterval(function(){
  514. if(document.querySelector("#info-text > #info-strings > yt-formatted-string")){
  515. //video_elem.currentTime=0;
  516. video_speed = localStorage.getItem('speed');
  517. if(buffer_time&&document.querySelector("#info-text > #info-strings > yt-formatted-string")){
  518. youtube_hand.message_box.show("<div>video speed "+video_speed+"x</div><div>cashe "+buffer_time+" seconds</div><div>"+document.querySelector("#info-strings > yt-formatted-string").innerText+" & "+document.querySelector("#count > ytd-video-view-count-renderer > span.view-count.style-scope.ytd-video-view-count-renderer").innerText+"</div>");
  519. }
  520. else if(document.querySelector("#info-text > #info-strings > yt-formatted-string")){
  521. youtube_hand.message_box.show("<div>video speed "+video_speed+"x</div><div>no cashe</div><div>"+document.querySelector("#info-strings > yt-formatted-string").innerText+" & "+document.querySelector("#count > ytd-video-view-count-renderer > span.view-count.style-scope.ytd-video-view-count-renderer").innerText+"</div>");
  522. }
  523.  
  524.  
  525. clearInterval(videoText_check);
  526.  
  527. }
  528.  
  529. }
  530. ,1000)
  531. main_opr();//youtube_hand.message_box.show("change");
  532. }
  533. else if(newVideo_check&&newVideo_check==document.querySelector("#movie_player > div.html5-video-container > video").duration){
  534. // alert("out");
  535. }
  536. else { video_elem.currentTime=0;
  537. setTimeout(function(){
  538. // alert("out in");
  539.  
  540. video_speed = localStorage.getItem('speed');
  541. if(buffer_time&&document.querySelector("#info-text > #info-strings > yt-formatted-string")){
  542. youtube_hand.message_box.show("<div>video speed "+video_speed+"x</div><div>cashe "+buffer_time+" seconds</div><div>"+document.querySelector("#info-strings > yt-formatted-string").innerText+" & "+document.querySelector("#count > ytd-video-view-count-renderer > span.view-count.style-scope.ytd-video-view-count-renderer").innerText+"</div>");
  543. }
  544. else if(document.querySelector("#info-text > #info-strings > yt-formatted-string")){
  545. youtube_hand.message_box.show("<div>video speed "+video_speed+"x</div><div>no cashe</div><div>"+document.querySelector("#info-strings > yt-formatted-string").innerText+" & "+document.querySelector("#count > ytd-video-view-count-renderer > span.view-count.style-scope.ytd-video-view-count-renderer").innerText+"</div>");
  546. }
  547.  
  548.  
  549. },3000)
  550. main_opr();
  551. }
  552.  
  553.  
  554.  
  555. }
  556.  
  557. clearInterval(main_timer);}
  558. },50)
  559.  
  560. //主应用操作
  561. function main_opr() {
  562. doc_s = window.document;
  563. //视频质量选择
  564.  
  565. var avail_quali;var current_time;
  566. if((avail_quali = v_elem.getAvailableQualityLevels())&&avail_quali.indexOf(video_quality) == -1){
  567. v_elem.setPlaybackQualityRange(avail_quali[0],avail_quali[0]);
  568. }
  569. else if(video_quality=="auto"){}
  570. else if(video_quality){v_elem.setPlaybackQualityRange(video_quality,video_quality);}
  571. //点开视频介绍
  572. setTimeout(function(){
  573. if(expand_description){
  574.  
  575. if(document.getElementById("action-panel-details")) {
  576. document.getElementById("action-panel-details").classList.remove("yt-uix-expander-collapsed");
  577. }
  578.  
  579. if(document.querySelector("#more > .more-button.style-scope.ytd-video-secondary-info-renderer")) {
  580. document.querySelector("#more > .more-button.style-scope.ytd-video-secondary-info-renderer").click();
  581. }
  582. if(document.querySelector("#expand")){
  583. document.querySelector("#expand").click();
  584. }
  585. }
  586. },5000);
  587.  
  588.  
  589.  
  590. //前跳过秒数+速度+播放质量设定
  591. video_elem.oncanplay = function(){
  592.  
  593. if(video_speed&&video_elem){
  594. video_elem.playbackRate = video_speed;
  595. }
  596. // if(current_time>200){current_time=0}
  597. if(sec_fwd&&(video_elem.currentTime < sec_fwd/1)&&(document.querySelector("#title > h1 > yt-formatted-string").innerText.includes("袁色")||document.querySelector("#title > h1 > yt-formatted-string").innerText.includes("袁腾飞")||document.querySelector("#title > h1 > yt-formatted-string").innerText.includes("会员翻牌"))){
  598. video_elem.currentTime += sec_fwd/1;
  599. video_elem.oncanplay = "";
  600. }
  601. // video_elem.currentTime += 1;
  602.  
  603. }
  604.  
  605. //暂停缓存
  606.  
  607. sec_sub = localStorage.getItem('sec_sub');
  608. video_elem.onpause = function(){
  609. if(document.querySelector("body > tp-yt-iron-overlay-backdrop")){
  610. document.querySelector("body > tp-yt-iron-overlay-backdrop").remove();
  611. if(document.querySelector("body > ytd-app > ytd-popup-container > tp-yt-paper-dialog")){
  612. document.querySelector("body > ytd-app > ytd-popup-container > tp-yt-paper-dialog").remove();
  613.  
  614. }
  615. video_elem.play();
  616. //document.querySelector("#movie_player > div.html5-video-container > video").play();
  617.  
  618.  
  619.  
  620. }
  621.  
  622.  
  623.  
  624.  
  625. //youtube_hand.message_box.show('<div>'+document.querySelector("#header-author yt-formatted-string > a").innerText+'</div>');
  626. if(!buffer_time||buffer_time == 0){return;}
  627. if(parseInt(video_elem.currentTime)==parseInt(video_elem.duration)){current_time=0;video_elem.onpause = "";video_elem.onplay = "";video_elem.oncanplaythrough ="";}
  628. else{current_time = parseInt(video_elem.currentTime);
  629. video_elem.oncanplaythrough = function(){
  630. if(parseInt(video_elem.currentTime)==parseInt(video_elem.duration)){current_time=0;video_elem.onpause = "";video_elem.onplay = "";video_elem.oncanplaythrough ="";}
  631. else{video_elem.currentTime +=1;
  632. if(sec_sub){
  633. if((video_elem.currentTime-current_time)>(buffer_time?buffer_time:0)||(video_elem.duration<(video_elem.currentTime+parseInt(sec_sub)+10)))
  634. {video_elem.currentTime = current_time;
  635. //console.log(current_time);console.log(video_elem.currentTime);
  636. video_elem.oncanplaythrough='';current_time=0;}
  637. }
  638. else{
  639. if(current_time!=0){
  640. if((video_elem.currentTime-current_time)>(buffer_time?buffer_time:0)||(video_elem.duration<(video_elem.currentTime+20)))
  641. {video_elem.currentTime = current_time;
  642. video_elem.oncanplaythrough='';}
  643. }
  644. else{ video_elem.oncanplaythrough='';}
  645. }
  646. }
  647. }
  648. video_elem.currentTime += 1;
  649. }
  650. }
  651. video_elem.onplay = function(){
  652.  
  653. if(parseInt(video_elem.currentTime)==parseInt(video_elem.duration-1)){
  654. current_time = 0;
  655. video_elem.onpause = "";video_elem.onplay = "";video_elem.oncanplaythrough ="";} // new
  656. else if(current_time){video_elem.currentTime = current_time;
  657. video_elem.oncanplaythrough = "";
  658. }
  659. }
  660. video_elem.onended = function(){current_time = "";video_elem.onpause = "";video_elem.onplay = "";video_elem.oncanplaythrough ="";
  661. }
  662. //中键全屏
  663.  
  664. video_elem.addEventListener("mouseup", function(e) {
  665. e.preventDefault();
  666. if(e.button==1){
  667. document.querySelector("#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-right-controls > button.ytp-fullscreen-button.ytp-button").click();
  668. }
  669. }, false);
  670. //按c开启/停止缓冲功能,按e调整视频速度
  671. doc_s.onkeydown = key_down;
  672.  
  673. function key_down(e){
  674. //document.addEventListener("keydown", function(e) {
  675.  
  676. if (document.activeElement.id != "" && document.activeElement.id != "movie_player") {
  677. return;}
  678.  
  679. else{
  680. if (e.keyCode == 69) {
  681. e.preventDefault();
  682. if(buffer_time){
  683. temp_buffer = buffer_time;
  684. buffer_time="";
  685. current_time=0;
  686. //localStorage.setItem('buffer_time','');
  687. youtube_hand.message_box.show("no cashing set");
  688. }
  689. else if(temp_buffer){buffer_time=temp_buffer;
  690. // localStorage.setItem('buffer_time',temp_buffer);
  691. youtube_hand.message_box.show("cashing "+buffer_time+" seconds set");
  692. }
  693. else{youtube_hand.message_box.show("no cashing time preset");}
  694. }
  695. else if(e.keyCode == 68) {
  696. if(video_speed != 1){
  697. temp_speed = video_speed;
  698. video_speed=1;
  699. video_elem.playbackRate = video_speed;
  700. speed_display.innerHTML="1x";
  701. //localStorage.setItem('speed','1')
  702. youtube_hand.message_box.show("video speed 1x set");
  703. }
  704. else if(temp_speed){
  705. if(localStorage.getItem('speed')!=temp_speed){video_speed=localStorage.getItem('speed');}
  706. else{video_speed=temp_speed;}
  707. video_elem.playbackRate = video_speed/1;
  708. speed_display.innerHTML=video_speed+"x";
  709. //localStorage.setItem('speed',temp_speed);
  710. youtube_hand.message_box.show("video speed "+video_speed+"x set");
  711. }
  712. else{ youtube_hand.message_box.show("no video speed preset");}
  713.  
  714. }
  715. doc_s.onkeydown = "";
  716. setTimeout(function(){doc_s.onkeydown = key_down;},200);
  717. }
  718. }
  719.  
  720. // 滚轮前进后退
  721. video_elem.onwheel = function(e){e.preventDefault()};
  722. v_elem.onwheel = wheel_e;
  723.  
  724. function wheel_e (event) {
  725. if(wheel_sec){
  726. event.preventDefault();
  727.  
  728. video_elem.currentTime += parseInt(event.deltaY>0?wheel_sec/1:-wheel_sec) ;
  729.  
  730. v_elem.onwheel="";
  731. setTimeout(function(){v_elem.onwheel= wheel_e;
  732. video_elem.onwheel = function(e){e.preventDefault()};
  733. },300);
  734.  
  735. //同时重设播放速度
  736. video_speed = localStorage.getItem('speed');
  737. document.querySelector("#movie_player > div.html5-video-container > video").playbackRate = video_speed;
  738. }
  739. }
  740.  
  741. //每隔25秒获取播放剩余时间,如在25秒内则执行主程序
  742. if(sec_sub !== ""&&sec_sub !=0){
  743. const sec_sub2=sec_sub/1+12;
  744. setInterval(function(){
  745. let left_duration = get_dura();
  746. if((left_duration < sec_sub) && (left_duration != 0))
  747. {
  748.  
  749. next_exec();
  750.  
  751. }
  752. }, 1000);
  753. }
  754.  
  755. //next part 执行
  756. function next_exec(){
  757. const sel_part2 = document.querySelector("#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-left-controls > a.ytp-next-button.ytp-button");
  758. if (sel_part2)
  759. {
  760. //console.log("clicked next---");
  761. sel_part2.click();
  762. // video_elem.currentTime=0;
  763. current_time=0;}
  764. }
  765.  
  766. //获取播放剩余时间
  767. function get_dura() {
  768. const sel_start = video_elem.currentTime;
  769. const sel_fin = video_elem.duration;
  770. if (sel_fin) {
  771. return sel_fin-sel_start;
  772. }
  773. return 0;
  774. }
  775.  
  776.  
  777.  
  778.  
  779. }
  780.  
  781. },
  782.  
  783. move_menu:function (){
  784. //点开显示其余items
  785. document.querySelector("#sections > ytd-guide-section-renderer:nth-child(2) > #items > ytd-guide-collapsible-entry-renderer > #expander-item > #endpoint").click();
  786. //移动频道到左顶部
  787. document.querySelector("#sections > ytd-guide-section-renderer:nth-child(1)").parentNode.append(document.querySelector("#sections > ytd-guide-section-renderer:nth-child(1)"))
  788.  
  789.  
  790.  
  791.  
  792. /*
  793.  
  794. // Create a Trusted Type policy
  795. const scriptPolicy = trustedTypes.createPolicy('true', {
  796. createScript: (scriptContent) => scriptContent
  797. });
  798.  
  799. // Use the policy to safely assign a script
  800. const scriptContent = "console.log('This is a trusted script');";
  801. const trustedScript = scriptPolicy.createScript(scriptContent);
  802.  
  803. // Create a script element
  804. const scriptElement = document.createElement('script');
  805. scriptElement.textContent = trustedScript;
  806. document.head.appendChild(scriptElement);
  807. */
  808.  
  809. //页面写入script和style
  810. var a_bug = document.createElement("script");
  811. a_bug.innerHTML = `// 监听draggable的相关事件
  812. function dragstart_handler(ev) {
  813. //console.log("dragStart");
  814. document.querySelector("#"+ev.target.id).style="margin-top: 25px !important;";
  815. // Add the target element's id to the data transfer object
  816. ev.dataTransfer.setData("text", ev.target.id);
  817. ev.dataTransfer.setData("text1", ev.target);
  818. //console.log(ev.dataTransfer.getData("text1"));
  819. ev.dataTransfer.dropEffect = "move";
  820. //console.log(ev.target.id);
  821.  
  822. }
  823. function dragEnter(ev) {
  824. //console.log("dragenter");
  825. ev.preventDefault();
  826. ev.target.className += ' drag-over';
  827. }
  828. function dragLeave(e) {
  829. ev.preventDefault();
  830. this.className = 'droppable';
  831. }
  832. function dragover_handler(ev) {
  833. ev.preventDefault();
  834. //ev.dataTransfer.dropEffect = "move"
  835. }
  836. function drop_handler(ev) {
  837. ev.preventDefault();
  838. // Get the id of the target and add the moved element to the target's DOM
  839. var data = ev.dataTransfer.getData("text");
  840. var first=ev.target.firstChild; //得到第一个元素
  841. ev.target.insertBefore(document.getElementById(data),first); //在第原来的第一个元素之前插入
  842. //ev.target.appendChild(document.getElementById(data));
  843. }
  844. function dragend_handler(ev) {
  845. // console.log("dragEnd");
  846. // Remove all of the drag data
  847. ev.dataTransfer.clearData();
  848. //localStorage.setItem("itemstate",document.querySelector("#sections > ytd-guide-section-renderer:nth-child(1) #items").outerHTML);
  849.  
  850. //itemdetail写入localStorage
  851. var json = [];
  852. var data = {};
  853. var items_length=document.querySelectorAll("#sections > ytd-guide-section-renderer:nth-child(1) > #items > ytd-guide-entry-renderer").length
  854. for(var i=0;i<items_length-1;i++){
  855. data = {};
  856. //data.id = document.querySelectorAll("#sections > ytd-guide-section-renderer:nth-child(1) > #items > ytd-guide-entry-renderer")[i].id;
  857. //data.imgsrc = document.querySelectorAll("#sections > ytd-guide-section-renderer:nth-child(1) > #items > ytd-guide-entry-renderer #img")[i].src;
  858. data.text =document.querySelectorAll("#sections > ytd-guide-section-renderer:nth-child(1) > #items > ytd-guide-entry-renderer")[i].innerText;
  859. //data.href = document.querySelectorAll("#sections > ytd-guide-section-renderer:nth-child(1) > #items > ytd-guide-entry-renderer > #endpoint")[i].href;
  860.  
  861. json.push(data);
  862.  
  863. }
  864. var jsonString = JSON.stringify(json);//[{"id":1,"imgsrc":"test1","text":2}]
  865. localStorage.setItem("itemdetail",jsonString);
  866. //localStorage.setItem("item_new","");
  867. }
  868. function noAllowDrop(ev) {
  869. //console.log("stopPropagation");
  870. ev.stopPropagation();
  871. }
  872.  
  873.  
  874. //点击订阅或退订时,删除localStorage内已有相同item
  875. if(document.querySelector("#inner-header-container #subscribe-button")){var subscribe_button = document.querySelector("#inner-header-container #subscribe-button")}
  876. else if(document.querySelector("#meta-contents #top-row > #subscribe-button")){var subscribe_button = document.querySelector("#meta-contents #top-row > #subscribe-button");}
  877. // var subscribe_button = document.querySelector("#inner-header-container #subscribe-button")?document.querySelector("#inner-header-container #subscribe-button"):document.querySelector("#meta-contents #top-row > #subscribe-button");
  878.  
  879. if(subscribe_button){
  880.  
  881. subscribe_button.onclick=function(){
  882.  
  883. //localStorage.setItem("item_new",document.querySelector("#text > a").innerText);
  884. //localStorage.removeItem("itemdetail",document.querySelector("#channel-name #text").innerText);
  885. let obj = JSON.parse(localStorage.itemdetail);
  886. for(let j=obj.length-1;j>-1;j--){
  887. if(obj[j]&&obj[j].text==document.querySelector("#channel-name #text").innerText){
  888. let items_down = document.querySelectorAll("#sections > ytd-guide-section-renderer:nth-child(1) > #items > ytd-guide-entry-renderer");
  889.  
  890. items_down.forEach(function(element,index,array) {
  891.  
  892. if(element.firstElementChild.title==document.querySelector("#channel-name #text").innerText){
  893.  
  894. document.querySelector("#sections > ytd-guide-section-renderer:nth-child(1) #items").append(element);
  895. return false;
  896. }
  897. })
  898.  
  899. delete obj[j];}
  900. }
  901. localStorage.setItem("itemdetail",JSON.stringify(obj));
  902. // console.log("delete suc");
  903. }
  904. }
  905.  
  906. `;
  907. document.body.appendChild(a_bug);
  908.  
  909. var style_type2 = document.createElement("style");style_type2.id = "style_type";
  910. style_type2.innerHTML = `#sections > ytd-guide-section-renderer:nth-child(1) > #items > ytd-guide-entry-renderer{margin: 1em 0em 1em 0em !important;}
  911. .drag-over {
  912. border-style: dashed;
  913. }
  914. .droppable{}
  915. `;
  916. //#expandable-items > ytd-guide-entry-renderer{margin: 1.2em 0em 1.2em 0em !important;}
  917. document.head.appendChild(style_type2);
  918.  
  919. //开始操作
  920. var menu_opr = setInterval(function(){
  921.  
  922. // const droppables = document.querySelector("#sections > ytd-guide-section-renderer:nth-child(1)");
  923. if(document.querySelector("#sections > ytd-guide-section-renderer:nth-child(1) #items > ytd-guide-entry-renderer")){
  924. const droppables = document.querySelector("#sections > ytd-guide-section-renderer:nth-child(1) > #items");
  925. const draggable = document.querySelectorAll("#sections > ytd-guide-section-renderer:nth-child(1) > #items > ytd-guide-entry-renderer");
  926. const no_draggable = document.querySelectorAll("#sections > ytd-guide-section-renderer:nth-child(1) > #items > ytd-guide-entry-renderer > #endpoint");
  927. // const no_droppable = document.querySelectorAll("#sections > ytd-guide-section-renderer:nth-child(1) > #items > ytd-guide-entry-renderer > #endpoint > tp-yt-paper-item");
  928. // const no_droppable = document.querySelectorAll("#sections > ytd-guide-section-renderer:nth-child(1) > #items > ytd-guide-entry-renderer > #endpoint *");
  929. const no_droppable = document.querySelectorAll("#sections > ytd-guide-section-renderer:nth-child(1) > #items *");
  930.  
  931. const draggable2 = document.querySelectorAll("#expandable-items > ytd-guide-entry-renderer");
  932. const no_draggable2 = document.querySelectorAll("#expandable-items > ytd-guide-entry-renderer > #endpoint");
  933. // const no_droppable2 = document.querySelectorAll("#expandable-items > ytd-guide-entry-renderer > #endpoint *");
  934.  
  935. droppables.setAttribute("ondrop","drop_handler(event);");
  936. droppables.setAttribute("ondragover","dragover_handler(event);");
  937. // droppables.setAttribute("ondragenter","dragEnter(event);");
  938. // droppables.setAttribute("ondragleave","dragLeave(event);");
  939. no_draggable.forEach(function(element,index,array) {
  940. element.setAttribute("draggable",false);
  941. });
  942. no_draggable2.forEach(function(element,index,array) {
  943. element.setAttribute("draggable",false);
  944. });
  945.  
  946. no_droppable.forEach(function(element,index,array) {
  947. element.setAttribute("ondragover","noAllowDrop(event);");
  948. });
  949. // no_droppable2.forEach(function(element,index,array) {
  950. // element.setAttribute("ondragover","noAllowDrop(event);");
  951. //});
  952.  
  953.  
  954. draggable.forEach(function(element,index,array) {
  955. if(index<array.length){
  956. element.setAttribute("draggable",true);
  957. element.setAttribute("ondragstart","dragstart_handler(event);");
  958. element.setAttribute("ondragend","dragend_handler(event);");
  959. if(!element.id){element.setAttribute("id","move"+index);}
  960. }
  961. });
  962. let index_x =0;
  963. draggable2.forEach(function(element,index,array) {
  964. index_x=index+7;
  965. element.setAttribute("draggable",true);
  966. element.setAttribute("ondragstart","dragstart_handler(event);");
  967. element.setAttribute("ondragend","dragend_handler(event);");
  968. element.setAttribute("id","move"+index_x);
  969.  
  970. });
  971.  
  972. //把隐藏内容拉出来,放入items
  973. const parent_item = document.querySelector("#sections > ytd-guide-section-renderer:nth-child(1) #items");
  974. let insert_sec = document.querySelector("#sections > ytd-guide-section-renderer:nth-child(1) #items > ytd-guide-collapsible-entry-renderer");
  975. let new_content2=document.querySelectorAll("#sections > ytd-guide-section-renderer:nth-child(1) #items > ytd-guide-collapsible-entry-renderer #expanded #expandable-items > ytd-guide-entry-renderer");
  976. new_content2.forEach(function(element){parent_item.insertBefore(element,insert_sec)});
  977.  
  978.  
  979. const obj = JSON.parse(localStorage.getItem("itemdetail"));
  980.  
  981. //getItem("itemdetail")然后写入网页列表
  982. if(localStorage.getItem("itemdetail")){
  983.  
  984. var items_drag = document.querySelectorAll("#sections > ytd-guide-section-renderer:nth-child(1) > #items > ytd-guide-entry-renderer");
  985.  
  986. for(var j=obj.length-1;j>-1;j--){
  987. // if(j==0){
  988. items_drag.forEach(function(element,index,array) {
  989.  
  990. //console.log(element.firstElementChild.title);
  991. //console.log(obj[j].text);
  992. if(obj[j]&&element.firstElementChild.title==obj[j].text){
  993.  
  994. parent_item.prepend(element);
  995. return false;
  996. }
  997. })
  998.  
  999. }
  1000.  
  1001.  
  1002. }
  1003. //把当日订阅和历史记录置顶
  1004. //document.querySelector("#sections > ytd-guide-section-renderer:nth-child(1) > #items").prepend(document.querySelector("#sections > ytd-guide-section-renderer:nth-child(2) #items > ytd-guide-entry-renderer:nth-child(4)"));
  1005. //当日订阅 document.querySelector("#sections > ytd-guide-section-renderer:nth-child(1) > #items").prepend(document.querySelector("#sections a[href='/feed/subscriptions']").parentElement);
  1006. document.querySelector("#sections > ytd-guide-section-renderer:nth-child(1) > #items").prepend(document.querySelector("#sections a[href='/feed/history']").parentElement);
  1007. document.querySelector("#sections > ytd-guide-section-renderer:nth-child(1) > #items").prepend(document.querySelector("#sections a[href='/playlist?list=WL']").parentElement);
  1008.  
  1009. clearInterval(menu_opr);
  1010. }
  1011.  
  1012. },100)
  1013.  
  1014. }
  1015.  
  1016.  
  1017. }
  1018.  
  1019.  
  1020.  
  1021. var load_menu = setInterval(function(){
  1022. //youtube_hand.dark_eye();
  1023.  
  1024. if(document.querySelector("#end")){
  1025. youtube_hand.play_menu();
  1026. youtube_hand.play_main();
  1027. youtube_hand.dark_eye1();
  1028.  
  1029. //document.querySelector("html").onpropertychange = youtube_hand.dark_eye;
  1030.  
  1031. clearInterval(load_menu);
  1032.  
  1033. }
  1034. },100)
  1035.  
  1036. /*
  1037. window.onload=function(){
  1038. document.addEventListener("yt-navigate-finish", function() {
  1039. youtube_hand.play_menu();
  1040. youtube_hand.play_main();
  1041. youtube_hand.dark_eye1();
  1042. })
  1043. };
  1044. */
  1045. setInterval(function(){ youtube_hand.dark_eye();
  1046. if(del_promote){
  1047. if(document.querySelector(".ytp-ce-element.ytp-ce-playlist.ytp-ce-element-show")){
  1048. document.querySelector(".ytp-ce-element.ytp-ce-playlist.ytp-ce-element-show").remove();
  1049. // console.log("del 1");
  1050. }
  1051.  
  1052. if(document.querySelector(".ytp-ce-element.ytp-ce-video.ytp-ce-element-show")){
  1053. document.querySelector(".ytp-ce-element.ytp-ce-video.ytp-ce-element-show").remove();
  1054. //console.log("del 2");
  1055. }
  1056. if(document.querySelector(".ytp-ce-element.ytp-ce-channel.ytp-ce-channel-this.ytp-ce-element-show")){
  1057. document.querySelector(".ytp-ce-element.ytp-ce-channel.ytp-ce-channel-this.ytp-ce-element-show").remove();
  1058. // console.log("del 3");
  1059. }
  1060. }
  1061.  
  1062.  
  1063. },1000)
  1064.  
  1065.  
  1066. if(subscription_up){
  1067. var move_ma=setInterval(function(){
  1068. if(document.querySelector("#sections > ytd-guide-section-renderer:nth-child(2)"))
  1069. {
  1070. youtube_hand.move_menu();
  1071.  
  1072. clearInterval(move_ma);
  1073. }
  1074. },200)
  1075. }
  1076. /*
  1077. setTimeout(function(){
  1078. document.querySelector("#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-right-controls > button.ytp-fullscreen-button.ytp-button").click();
  1079. },10000)
  1080. */
  1081. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址