diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index 06841ebc8..0384bc658 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Offline) -// @version 191.96 +// @version 192.03 // @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howrad (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -1180,19 +1180,19 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/new-styles.min.js"] = (()=>{return(e,t)=>{if(document.URL===`https://h.bilibili.com/`){return}SpinQuery.any(()=>$(".custom-scrollbar"),e=>e.removeClass("custom-scrollbar"));SpinQuery.any(()=>$("#banner_link"),()=>t.removeStyle("tweetsStyle"));const l={selectors:["div.nav-con.fl","#link-navbar-vm",".link-navbar",".nav-header-wrapper",".z_top .z_header"],get allSelectors(){return this.selectors.reduce((e,t)=>e+","+t)},get navbar(){let e=null;for(const t of this.selectors){e=e||document.querySelector(t)}return e},supports(e){if(e instanceof Element){const t=parseInt(window.getComputedStyle(e).height);const l=[60,50,0,56];return l.indexOf(t)!==-1}return false}};SpinQuery.any(()=>$(l.allSelectors),()=>{const e=l.navbar;if(l.supports(e)){t.applyStyle("style","bilibili-style-optimization")}else{t.applyStyle("oldStyle","bilibili-style-optimization")}})}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/override-navbar.min.js"] = (()=>{return(e,n)=>{new SpinQuery(()=>$(".head-content.bili-wrapper>div.search:not(.filter-item)"),e=>e.length>0&&$(".nav-con.fr").filter((e,n)=>n.innerText).length>0,e=>{const n=$(".nav-con.fr").filter((e,n)=>n.innerText);e.detach().insertAfter(n)}).start();SpinQuery.any(()=>$("#banner_link"),()=>n.removeStyle("tweetsStyle"));if(e.preserveRank){SpinQuery.any(()=>$(".head-content.bili-wrapper>div.search:not(.filter-item) .searchform,.nav-con #nav_searchform"),e=>{e.addClass("preserve-rank");if(e.find("a.icons-enabled").length===0){e.prepend(`\n \n \n \n `)}})}else{SpinQuery.any(()=>$(".head-content.bili-wrapper>div.search:not(.filter-item) .searchform,.nav-con #nav_searchform"),e=>{e.removeClass("preserve-rank");e.find("a.icons-enabled").remove()})}if(!e.showBanner){n.applyStyle("noBannerStyle")}else{n.removeStyle("noBannerStyle")}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-navbar.min.js"] = (()=>{return()=>{SpinQuery.count(()=>$("ul.fr>li.nav-item").not(".profile-info"),6,n=>{const r=(n,r)=>{const t=$(r);t.css("cursor","pointer");const o=t.find("a.t");o.removeAttr("href")};n.each(r)})}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-player.min.js"] = (()=>{return(t,i)=>{const e=t=>{let i=0;let e=0;while(t&&!isNaN(t.offsetLeft)&&!isNaN(t.offsetTop)){i+=t.offsetLeft-t.scrollLeft;e+=t.offsetTop-t.scrollTop;t=t.offsetParent}return{x:i,y:e}};const o=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let s=fixed(o)+"秒";if(e>0){s=e+"分"+s}if(i>0){s=i+"时"+s}return s};const s=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let s=(o<10?"0":"")+fixed(o);s=(e<10?"0":"")+e+":"+s;s=(i<10?"0":"")+i+":"+s;return s};class n{constructor(t){this.action=new l(t);this.onTouchStart=null;this.onTouchEnd=null;this.direction=null;t.addEventListener("touchstart",t=>{this.xDown=t.touches[0].clientX;this.yDown=t.touches[0].clientY;if(this.onTouchStart){this.onTouchStart(t)}});t.addEventListener("touchmove",i=>{if(!this.xDown||!this.yDown){return}const o=i.touches[0].clientX;const s=i.touches[0].clientY;const n=e(t);const l={x:(i.touches[0].pageX-n.x)/t.clientWidth,y:(i.touches[0].pageY-n.y)/t.clientHeight,width:t.clientWidth,height:t.clientHeight};const a=this.xDown-o;const c=this.yDown-s;if(!this.direction){let t="";if(Math.abs(a)>Math.abs(c)){t="horizontal"}else{t="vertical"}this.direction=t;i.preventDefault()}else{if(this.direction==="vertical"){this.action.startAction(this.direction,c,l)}else if(this.direction==="horizontal"){this.action.startAction(this.direction,-a,l)}i.preventDefault()}});t.addEventListener("touchend",t=>{this.xDown=null;this.yDown=null;this.direction=null;if(this.onTouchEnd){this.onTouchEnd(t)}})}}class l{constructor(t){this.lowSpeedForward=null;this.lowSpeedBackward=null;this.mediumSpeedForward=null;this.mediumSpeedBackward=null;this.highSpeedForward=null;this.highSpeedBackward=null;this.lowVolumeUp=null;this.lowVolumeDown=null;this.mediumVolumeUp=null;this.mediumVolumeDown=null;this.highVolumeUp=null;this.highVolumeDown=null;this.speedCancel=null;this.volumeCancel=null;this.minSwipeDistance=20;this.onActionStart=null;this.onActionEnd=null;this.element=t;this.touchStart=false;this.startPosition=null;this.lastAction=null;t.addEventListener("touchstart",t=>{this.touchStart=true});t.addEventListener("touchend",t=>{this.startPosition=null;this.onActionEnd&&this.onActionEnd(this.lastAction);this.lastAction=null})}startAction(t,i,e){if(this.touchStart){this.onActionStart&&this.onActionStart(t);this.startPosition=e;this.touchStart=false}if(t==="vertical"){if(Math.abs(i)=1/3&&this.startPosition.x<=2/3){t=1;o=this.mediumVolumeUp;s=this.mediumVolumeDown}else{t=2;o=this.highVolumeUp;s=this.highVolumeDown}if(i>0){const s=Math.round(t*100*(i-this.minSwipeDistance)/(1.5*e.height));o&&o(s);this.lastAction={type:"volume",volume:s}}else{const o=Math.round(t*100*(i+this.minSwipeDistance)/(1.5*e.height));s&&s(o);this.lastAction={type:"volume",volume:o}}}}else if(t==="horizontal"){if(e.y<1/3&&(e.x<.1||e.x>.9)||Math.abs(i)=1/3&&this.startPosition.y<=2/3){t=.2;e=this.mediumSpeedForward;o=this.mediumSpeedBackward}else{t=1;e=this.highSpeedForward;o=this.highSpeedBackward}if(i>0){const o=(i-this.minSwipeDistance)*t;e&&e(o);this.lastAction={type:"playback",seconds:o}}else{const e=(i+this.minSwipeDistance)*t;o&&o(e);this.lastAction={type:"playback",seconds:e}}}}}}class a{constructor(){this.aid=unsafeWindow.aid;this.cid=unsafeWindow.cid;this.cidData=null;this.supportWebp=a.supportWebp}getVideoshot(t,i){if(!this.cidData){downloadText(`https://api.bilibili.com/x/player/videoshot?aid=${this.aid}&cid=${this.cid}&index=1`).then(e=>{this.cidData=JSON.parse(e).data;this.getVideoshot(t,i)})}else{const e=this.cidData;const o=e.index;let s=0;for(let i=0;i=o[i]&&tt.replace(".jpg",".jpg@.webp"))}const l=parseInt(e.pv_x_len)||10;const a=parseInt(e.pv_y_len)||10;const c=parseInt(e.pv_x_size)||160;const r=parseInt(e.pv_y_size)||90;const h=-(s%100%l)*c;const d=-Math.floor(s%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(s/100)]})`,backgroundPosition:`${h}px ${d}px`})}}static get supportWebp(){try{const t=document.createElement("canvas");if(t.getContext&&t.getContext("2d"))try{return t.toDataURL("image/webp").indexOf("data:image/webp")===0}catch(t){return false}else return false}catch(t){return false}}}function c(t){t.unbind("click")}function r(i){if($(".touch-video-box").length!==0){return}$(".bilibili-player-video-subtitle").before(`\n \n \n \n \n \n `);const e=$("video");const l=e.prop("duration");const c=new n(i.get(0));const r=document.getElementsByClassName("touch-video-info")[0];const h=document.getElementsByClassName("touch-video-box")[0];let d=Math.round(e.prop("volume")*100);const u=t=>{t/=100;if(t<0){t=0}else if(t>1){t=1}e.prop("volume",t);$(".bilibili-player-video-volume-num").text(Math.round(t*100));$(".bui-thumb").css("transform",`translateY(-${48*t}px)`);$(".bui-track-vertical .bui-bar").css("transform",`scaleY(${t})`);if(t===0){$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",true)}else if(t===1){$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-max");e.prop("muted",false)}else{$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",false)}};if(t.touchVideoPlayerAnimation){h.classList.add("animation")}c.action.onActionStart=(t=>{h.classList.add("adjust-opened");r.innerHTML="";d=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");let a=n+i;let c=fixed(100*a/l);let h=i;if(a>l){a=l;c=100;h=l-n}else if(a<0){a=0;c=0;h=n}const d=`${s(n)} →${s(a)} (${c}%)`;const u=`\n \n \n ${t}速\n \n \n 进度: ${i>0?"+":"-"}${o(h)}\n \n \n \n \n \n \n \n ${d}\n \n \n `;r.innerHTML=u;p.getVideoshot(a,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${c/100})`)}};c.action.lowSpeedBackward=m("低");c.action.lowSpeedForward=m("低");c.action.mediumSpeedBackward=m("中");c.action.mediumSpeedForward=m("中");c.action.highSpeedBackward=m("高");c.action.highSpeedForward=m("高");const v=t=>{return i=>{let e=d+i;let o=Math.abs(i);if(e>100){e=100;o=100-d}else if(e<0){e=0;o=d}const s=`${d} → ${e}`;u(e);const n=`\n \n \n ${t}速\n \n \n 音量: ${i>0?"+":"-"}${o}\n \n \n \n \n ${s}\n \n \n `;r.innerHTML=n;$(".touch-progress").css("transform",`scaleX(${e/100})`)}};c.action.lowVolumeUp=v("低");c.action.lowVolumeDown=v("低");c.action.mediumVolumeUp=v("中");c.action.mediumVolumeDown=v("中");c.action.highVolumeUp=v("高");c.action.highVolumeDown=v("高");c.action.speedCancel=(()=>{r.innerHTML=`松开手指,取消进退`;$(".touch-progress").css("transform","scaleX(0)")});c.action.volumeCancel=(()=>{r.innerHTML=`松开手指,取消调整`;$(".touch-progress").css("transform","scaleX(0)");u(d)});if(!unsafeWindow.TOUCH_PLAYER_DEBUG){c.action.onActionEnd=(t=>{r.innerHTML="";if(t){if(t.type==="playback"){let i=e.prop("currentTime");i+=t.seconds;if(i<0){i=0}else if(i>l){i=l}e.prop("currentTime",i)}}h.classList.remove("adjust-opened")})}}function h(t){if(!t.hasClass("disable-original-hover")){t.addClass("disable-original-hover");const i=unsafeWindow.$(".bilibili-player-video");const e="touch-video-control-show";const o=i.data("events").click[0].handler;const s=new DoubleClickEvent(t=>o(t),()=>t.toggleClass(e));i.unbind("click");s.bind(i[0])}}function d(){SpinQuery.any(()=>$(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),c);new SpinQuery(()=>$(".bilibili-player-video"),t=>t.length>0&&$("video").length>0&&$("video").prop("duration"),r).start();if(t.touchVideoPlayerDoubleTapControl){new SpinQuery(()=>$(".bilibili-player-area"),t=>t.length>0&&unsafeWindow.$&&unsafeWindow.$(".bilibili-player-video").data("events"),h).start()}}(Observer.childList||Observer.subtree)("#bofqi",()=>d());i.applyStyle("touchPlayerStyle")}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-danmaku.min.js"] = (()=>{return()=>{(Observer.childList||Observer.subtree)("#bofqi",()=>{SpinQuery.any(()=>$(".bui-collapse-header"),e=>{if(parseInt($(".bui-collapse-body").css("height"))===0&&$(".bui-collapse-arrow-text").text()==="展开"){e.click()}})})}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-player.min.js"] = (()=>{return(t,i)=>{const e=t=>{let i=0;let e=0;while(t&&!isNaN(t.offsetLeft)&&!isNaN(t.offsetTop)){i+=t.offsetLeft-t.scrollLeft;e+=t.offsetTop-t.scrollTop;t=t.offsetParent}return{x:i,y:e}};const o=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let s=fixed(o)+"秒";if(e>0){s=e+"分"+s}if(i>0){s=i+"时"+s}return s};const s=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let s=(o<10?"0":"")+fixed(o);s=(e<10?"0":"")+e+":"+s;s=(i<10?"0":"")+i+":"+s;return s};class n{constructor(t){this.action=new l(t);this.onTouchStart=null;this.onTouchEnd=null;this.direction=null;t.addEventListener("touchstart",t=>{this.xDown=t.touches[0].clientX;this.yDown=t.touches[0].clientY;if(this.onTouchStart){this.onTouchStart(t)}});t.addEventListener("touchmove",i=>{if(!this.xDown||!this.yDown){return}const o=i.touches[0].clientX;const s=i.touches[0].clientY;const n=e(t);const l={x:(i.touches[0].pageX-n.x)/t.clientWidth,y:(i.touches[0].pageY-n.y)/t.clientHeight,width:t.clientWidth,height:t.clientHeight};const a=this.xDown-o;const c=this.yDown-s;if(!this.direction){let t="";if(Math.abs(a)>Math.abs(c)){t="horizontal"}else{t="vertical"}this.direction=t;i.preventDefault()}else{if(this.direction==="vertical"){this.action.startAction(this.direction,c,l)}else if(this.direction==="horizontal"){this.action.startAction(this.direction,-a,l)}i.preventDefault()}});t.addEventListener("touchend",t=>{this.xDown=null;this.yDown=null;this.direction=null;if(this.onTouchEnd){this.onTouchEnd(t)}})}}class l{constructor(t){this.lowSpeedForward=null;this.lowSpeedBackward=null;this.mediumSpeedForward=null;this.mediumSpeedBackward=null;this.highSpeedForward=null;this.highSpeedBackward=null;this.lowVolumeUp=null;this.lowVolumeDown=null;this.mediumVolumeUp=null;this.mediumVolumeDown=null;this.highVolumeUp=null;this.highVolumeDown=null;this.speedCancel=null;this.volumeCancel=null;this.minSwipeDistance=20;this.onActionStart=null;this.onActionEnd=null;this.element=t;this.touchStart=false;this.startPosition=null;this.lastAction=null;t.addEventListener("touchstart",t=>{this.touchStart=true});t.addEventListener("touchend",t=>{this.startPosition=null;this.onActionEnd&&this.onActionEnd(this.lastAction);this.lastAction=null})}startAction(t,i,e){if(this.touchStart){this.onActionStart&&this.onActionStart(t);this.startPosition=e;this.touchStart=false}if(t==="vertical"){if(Math.abs(i)=1/3&&this.startPosition.x<=2/3){t=1;o=this.mediumVolumeUp;s=this.mediumVolumeDown}else{t=2;o=this.highVolumeUp;s=this.highVolumeDown}if(i>0){const s=Math.round(t*100*(i-this.minSwipeDistance)/(1.5*e.height));o&&o(s);this.lastAction={type:"volume",volume:s}}else{const o=Math.round(t*100*(i+this.minSwipeDistance)/(1.5*e.height));s&&s(o);this.lastAction={type:"volume",volume:o}}}}else if(t==="horizontal"){if(e.y<1/3&&(e.x<.1||e.x>.9)||Math.abs(i)=1/3&&this.startPosition.y<=2/3){t=.2;e=this.mediumSpeedForward;o=this.mediumSpeedBackward}else{t=1;e=this.highSpeedForward;o=this.highSpeedBackward}if(i>0){const o=(i-this.minSwipeDistance)*t;e&&e(o);this.lastAction={type:"playback",seconds:o}}else{const e=(i+this.minSwipeDistance)*t;o&&o(e);this.lastAction={type:"playback",seconds:e}}}}}}class a{constructor(){this.aid=unsafeWindow.aid;this.cid=unsafeWindow.cid;this.cidData=null;this.supportWebp=a.supportWebp}getVideoshot(t,i){if(!this.cidData){downloadText(`https://api.bilibili.com/x/player/videoshot?aid=${this.aid}&cid=${this.cid}&index=1`).then(e=>{this.cidData=JSON.parse(e).data;this.getVideoshot(t,i)})}else{const e=this.cidData;const o=e.index;let s=0;for(let i=0;i=o[i]&&tt.replace(".jpg",".jpg@.webp"))}const l=parseInt(e.pv_x_len)||10;const a=parseInt(e.pv_y_len)||10;const c=parseInt(e.pv_x_size)||160;const r=parseInt(e.pv_y_size)||90;const h=-(s%100%l)*c;const d=-Math.floor(s%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(s/100)]})`,backgroundPosition:`${h}px ${d}px`})}}static get supportWebp(){try{const t=document.createElement("canvas");if(t.getContext&&t.getContext("2d"))try{return t.toDataURL("image/webp").indexOf("data:image/webp")===0}catch(t){return false}else return false}catch(t){return false}}}function c(t){t.unbind("click")}function r(i){if($(".touch-video-box").length!==0){return}$(".bilibili-player-video-subtitle").before(`\n \n \n \n \n \n `);const e=$("video");const l=e.prop("duration");const c=new n(i.get(0));const r=document.getElementsByClassName("touch-video-info")[0];const h=document.getElementsByClassName("touch-video-box")[0];let d=Math.round(e.prop("volume")*100);const u=t=>{t/=100;if(t<0){t=0}else if(t>1){t=1}e.prop("volume",t);$(".bilibili-player-video-volume-num").text(Math.round(t*100));$(".bui-thumb").css("transform",`translateY(-${48*t}px)`);$(".bui-track-vertical .bui-bar").css("transform",`scaleY(${t})`);if(t===0){$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",true)}else if(t===1){$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-max");e.prop("muted",false)}else{$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",false)}};if(t.touchVideoPlayerAnimation){h.classList.add("animation")}c.action.onActionStart=(t=>{h.classList.add("adjust-opened");r.innerHTML="";d=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");let a=n+i;let c=fixed(100*a/l);let h=i;if(a>l){a=l;c=100;h=l-n}else if(a<0){a=0;c=0;h=n}const d=`${s(n)} →${s(a)} (${c}%)`;const u=`\n \n \n ${t}速\n \n \n 进度: ${i>0?"+":"-"}${o(h)}\n \n \n \n \n \n \n \n ${d}\n \n \n `;r.innerHTML=u;p.getVideoshot(a,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${c/100})`)}};c.action.lowSpeedBackward=m("低");c.action.lowSpeedForward=m("低");c.action.mediumSpeedBackward=m("中");c.action.mediumSpeedForward=m("中");c.action.highSpeedBackward=m("高");c.action.highSpeedForward=m("高");const v=t=>{return i=>{let e=d+i;let o=Math.abs(i);if(e>100){e=100;o=100-d}else if(e<0){e=0;o=d}const s=`${d} → ${e}`;u(e);const n=`\n \n \n ${t}速\n \n \n 音量: ${i>0?"+":"-"}${o}\n \n \n \n \n ${s}\n \n \n `;r.innerHTML=n;$(".touch-progress").css("transform",`scaleX(${e/100})`)}};c.action.lowVolumeUp=v("低");c.action.lowVolumeDown=v("低");c.action.mediumVolumeUp=v("中");c.action.mediumVolumeDown=v("中");c.action.highVolumeUp=v("高");c.action.highVolumeDown=v("高");c.action.speedCancel=(()=>{r.innerHTML=`松开手指,取消进退`;$(".touch-progress").css("transform","scaleX(0)")});c.action.volumeCancel=(()=>{r.innerHTML=`松开手指,取消调整`;$(".touch-progress").css("transform","scaleX(0)");u(d)});if(!unsafeWindow.TOUCH_PLAYER_DEBUG){c.action.onActionEnd=(t=>{r.innerHTML="";if(t){if(t.type==="playback"){let i=e.prop("currentTime");i+=t.seconds;if(i<0){i=0}else if(i>l){i=l}e.prop("currentTime",i)}}h.classList.remove("adjust-opened")})}}function h(t){if(!t.hasClass("disable-original-hover")){t.addClass("disable-original-hover");const i=unsafeWindow.$(".bilibili-player-video");const e="touch-video-control-show";const o=i.data("events").click[0].handler;const s=new DoubleClickEvent(t=>o(t),()=>t.toggleClass(e));i.unbind("click");s.bind(i[0])}}function d(){SpinQuery.any(()=>$(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),c);new SpinQuery(()=>$(".bilibili-player-video"),t=>t.length>0&&$("video").length>0&&$("video").prop("duration"),r).start();if(t.touchVideoPlayerDoubleTapControl){new SpinQuery(()=>$(".bilibili-player-area"),t=>t.length>0&&unsafeWindow.$&&unsafeWindow.$(".bilibili-player-video").data("events"),h).start()}}Observer.childListSubtree("#bofqi",()=>d());i.applyStyle("touchPlayerStyle")}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-danmaku.min.js"] = (()=>{return()=>{Observer.childListSubtree("#bofqi",()=>{SpinQuery.any(()=>$(".bui-collapse-header"),e=>{if(parseInt($(".bui-collapse-body").css("height"))===0&&$(".bui-collapse-arrow-text").text()==="展开"){e.click()}})})}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/remove-promotions.min.js"] = (()=>{return(n,i)=>{SpinQuery.any(()=>$(".gg-pic").parent("a"),n=>{n.css("display","none");n.each((n,i)=>{const e=$(i).index()+1;const c=$(i).parent().parent().find(`.pic li:nth-child(${e})`);$(c).css("visibility","hidden")})})}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater.min.js"] = (()=>{return()=>{const e=e=>{const t=e.match(/(av[\d]+)\/p([\d]+)/);if(t){return`https://www.bilibili.com/video/${t[1]}/?p=${t[2]}`}else{return"javascript:;"}};const t=t=>{const r=t.map(t=>{const r=t.getAttribute("href");if(!r){return"javascript:;"}if(r.match(/.*watchlater.*|javascript:;/g)){return e(r)}if(r.indexOf("video/av")!==-1){return r}});t.forEach((e,t)=>$(e).attr("href",r[t]).attr("target","_blank"))};const r=(...e)=>{for(const r of e){SpinQuery.select(()=>document.querySelectorAll(r),e=>t([...e]))}};SpinQuery.any(()=>$(".watch-later-list"),()=>{(Observer.childListSubtree||Observer.subtree)("#viewlater-app",()=>{SpinQuery.condition(()=>document.URL.match(/(av[\d]+)\/p([\d]+)/),e=>e&&document.URL.indexOf("watchlater")!==-1,()=>{const t=e(document.URL);if(t!==null){window.location.replace(t)}});SpinQuery.any(()=>$("#viewlater-app .s-btn[href='#/']"),e=>e.remove());r(".av-pic",".av-about>a")})});SpinQuery.any(()=>$("li.nav-item[report-id*=watchlater]"),()=>{(Observer.childListSubtree||Observer.subtree)("li.nav-item[report-id*=watchlater]",()=>{r(".av-item>a",".av-about>a","div.watch-later-m>ul>div>li>a");SpinQuery.any(()=>$(".read-more.mr"),e=>e.remove());SpinQuery.any(()=>$(".read-more-grp>.read-more"),e=>e.css({float:"none",width:"auto"}))})})}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/hide-top-search.min.js"] = (()=>{return()=>{const e=[".nav-search-keyword",".search-keyword"];for(const r of e){new SpinQuery(()=>$(r),e=>e!==undefined&&e.length>0&&e.attr("placeholder").length>0,e=>e.attr("placeholder","搜索")).start()}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/haruna-scale.min.js"] = (()=>{return(n,t)=>{const a="bilibili-haruna-scale";if($(a).length===0){t.applyStyleFromText(`\n \n `)}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/remove-watermark.min.js"] = (()=>{return(i,l)=>{const n="bilibili-live-watermark";if($(`#${n}`).length===0){l.applyStyleFromText(`\n \n `)}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/full-tweets-title.min.js"] = (()=>{return(e,l)=>{l.applyStyle("fullTweetsTitleStyle")}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{const n=t.attributes.videoInfo.export.VideoInfo;class i{constructor(e){this.url=e;if($(".image-viewer").length===0){this.createDom()}this.viewer=$(".image-viewer-container");this.downloadImage()}createDom(){$("body").append(t.data.imageViewerDom.text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","");const n=URL.createObjectURL(e.response);this.imageData=n;this.viewer.find(".download").attr("href",n).attr("download",t);this.viewer.find(".image").prop("src",n)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}if($("meta[itemprop='image'],meta[property='og:image']").length>0){return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.condition(()=>(unsafeWindow||window).aid,e=>e!==undefined);return e!=="undefined"},success:async()=>{async function e(){const e=(unsafeWindow||window).aid;const t=new n(e);await t.fetchInfo();return t.coverUrl}let t=new i(await e());$("#view-cover").on("click",()=>{t.show()});(Observer.childList||Observer.subtree)("#bofqi",async()=>{t=new i(await e())})}}}}else{return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.any(()=>$(".header-info-ctnr .room-cover"));return typeof e!=="undefined"},success:async()=>{const e=$(".header-info-ctnr .room-cover");const t=e.attr("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const n=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const o=await downloadText(n);const s=JSON.parse(o).data.cover;const a=new i(s);$("#view-cover").on("click",()=>{a.show()})}}}}}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{const n=t.attributes.videoInfo.export.VideoInfo;class i{constructor(e){this.url=e;if($(".image-viewer").length===0){this.createDom()}this.viewer=$(".image-viewer-container");this.downloadImage()}createDom(){$("body").append(t.data.imageViewerDom.text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","");const n=URL.createObjectURL(e.response);this.imageData=n;this.viewer.find(".download").attr("href",n).attr("download",t);this.viewer.find(".image").prop("src",n)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}if($("meta[itemprop='image'],meta[property='og:image']").length>0){return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.condition(()=>(unsafeWindow||window).aid,e=>e!==undefined);return e!=="undefined"},success:async()=>{async function e(){const e=(unsafeWindow||window).aid;const t=new n(e);await t.fetchInfo();return t.coverUrl}let t=new i(await e());$("#view-cover").on("click",()=>{t.show()});Observer.childListSubtree("#bofqi",async()=>{t=new i(await e())})}}}}else{return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.any(()=>$(".header-info-ctnr .room-cover"));return typeof e!=="undefined"},success:async()=>{const e=$(".header-info-ctnr .room-cover");const t=e.attr("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const n=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const o=await downloadText(n);const a=JSON.parse(o).data.cover;const s=new i(a);$("#view-cover").on("click",()=>{s.show()})}}}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/notify-new-version.min.js"] = (()=>{return(e,n)=>{const t={less:-1,equal:0,greater:1,incomparable:NaN};class s{constructor(e){this.parts=e.split(".").map(e=>parseInt(e));this.versionString=e}compareTo(e){for(let n=0;ne.parts[n]){return t.greater}return t.less}if(this.parts.length!==e.parts.length){return t.less}return t.equal}greaterThan(e){return this.compareTo(e)===t.greater}lessThan(e){return this.compareTo(e)===t.less}equals(e){return this.compareTo(e)===t.equal}}const r=new s(n.data.latestVersion.text);const i=new s(e.currentVersion);if(r.greaterThan(i)){const n=`新版本${r.versionString}已发布. 安装查看`;const t=Toast.info(n,"检查更新");$("#new-version-link").on("click",()=>t&&t.dismiss());return{widget:{content:`\n \n \n \n 安装更新\n \n \n \n \n 查看更新\n \n `,success:()=>{$("#new-version-update").on("click",()=>document.querySelector("#new-version-update a").click());$("#new-version-info").on("click",()=>document.querySelector("#new-version-info a").click())}}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/toast.min.js"] = (()=>{return(t,s)=>{class e{constructor(t="",s="",e="default"){this.type=e;this.message=t;this.title=s;this.duration=3e3;this.element=$(this.cardHtml)[0];this.$element=$(this.element);$(".toast-card-container").append(this.$element)}show(){this.element.classList.add("visible");this.$element.find(".toast-card-dismiss").on("click",()=>this.dismiss());if(this.duration){setTimeout(()=>this.dismiss(),this.duration)}}dismiss(){if(this.element.classList.contains("visible")){this.$element.on("transitionend",()=>this.$element.remove());this.element.classList.remove("visible")}}get cardHtml(){return`\n \n \n ${this.title}\n \n \n \n \n ${this.message}\n \n `}static get container(){return $(".toast-card-container")}static createToastContainer(){if($(".toast-card-container").length===0){$("body").append(``)}}static internalShow(t,s,i,n){const a=new e(t,s,n);a.duration=i;a.show();return a}static show(t,s,e){return this.internalShow(t,s,e,"default")}static info(t,s,e){return this.internalShow(t,s,e,"info")}static success(t,s,e){return this.internalShow(t,s,e,"success")}static error(t,s,e){return this.internalShow(t,s,e,"error")}}s.applyStyle("toastStyle");e.createToastContainer();return{export:e}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/remove-top-mask.min.js"] = (()=>{return(i,n)=>{const l="bilibili-video-top-mask";if($(`#${l}`).length===0){n.applyStyleFromText(`\n \n `)}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/blur-video-control.min.js"] = (()=>{return(r,e)=>{(Observer.childListSubtree||Observer.subtree)("#bofqi",()=>{SpinQuery.count(()=>$(".bui-slider .bui-track.bui-track-video-progress,.bilibili-player-video-control-bottom"),2,r=>{if(!r.hasClass("video-control-blur-container")){r.addClass("video-control-blur-container");r.prepend(``)}})});e.applyStyle("blurVideoControlStyle")}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/blur-video-control.min.js"] = (()=>{return(r,i)=>{Observer.childListSubtree("#bofqi",()=>{SpinQuery.count(()=>$(".bui-slider .bui-track.bui-track-video-progress,.bilibili-player-video-control-bottom"),2,r=>{if(!r.hasClass("video-control-blur-container")){r.addClass("video-control-blur-container");r.prepend(``)}})});i.applyStyle("blurVideoControlStyle")}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/dark-schedule.min.js"] = (()=>{return(e,t)=>{class s{constructor(...e){if(e.length===0){const e=new Date;this.hour=e.getHours();this.minute=e.getMinutes()}else if(e.length===1){const[t]=e;[this.hour,this.minute]=t.split(":").slice(0,2).map(e=>this.validatePart(e));this.normalize()}else if(v.length===2){[this.hour,this.minute]=e}}validatePart(e){const t=parseInt(e);if(!isNaN(t)&&0<=t&&t<=59){return t}else{return null}}normalize(){while(this.minute<0){this.minute+=60;this.hour-=1}while(this.minute>=60){this.minute-=60;this.hour+=1}while(this.hour<0){this.hour+=24}while(this.hour>=24){this.hour-=24}}lessThan(e){if(this.houre.hour||this.hour===e.hour&&this.minute>e.minute){return true}return false}equals(e){return this.hour===e.hour&&this.minute===e.minute}isInRange(e,t){if(e.equals(t)){return false}let s=this.greaterThan(e)&&this.lessThan(t);if(e.greaterThan(t)){s=this.greaterThan(e)||this.lessThan(t)}const i=s||this.equals(e);return i}static millisecondsBefore(e){const t=new s;const i=(new Date).getSeconds();const r=1e3*(t.hour*3600+t.minute*60+i);const n=1e3*(e.hour*3600+e.minute*60);let h=n-r;if(t.greaterThan(e)||t.equals(e)&&i!==0){h+=24*3600*1e3}return h}}function i(){if(e.darkSchedule){const t=new s(e.darkScheduleStart);const r=new s(e.darkScheduleEnd);const n=new s;const h=n.isInRange(t,r);if(e.useDarkStyle!==h){e.useDarkStyle=h;saveSettings(e)}let u=0;if(h){u=s.millisecondsBefore(r)}else{u=s.millisecondsBefore(t)}if(u!==0){setTimeout(()=>i(),u)}}}i();return{export:s}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/clear-cache.min.js"] = (()=>{return(n,c)=>{return{widget:{content:`\n \n \n 清除缓存\n `,condition:()=>typeof offlineData==="undefined",success:()=>{$("#clear-cache").on("click",()=>{n.cache={};saveSettings(n);Toast.success("已删除全部缓存.","清除缓存",5e3)})}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.js"] = (()=>{return(e,t)=>{const s={entity:null,aid:undefined,cid:undefined,isOldBangumi:false,isStardustBangumi:false};const n=[];class i{constructor(){this.menuPanel=document.querySelector(".download-video-panel");this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}addMenuClass(){this.menuPanel.classList.remove(...this.menuClasses);this.menuPanel.classList.add(this.currentMenuClass);return this.currentMenuClass}resetMenuClass(){[this.currentMenuClass]=this.menuClasses;this.addMenuClass()}nextMenuClass(){const e=this.menuClasses.indexOf(this.currentMenuClass)+1;const t=this.menuClasses[e>=this.menuClasses.length?0:e];this.currentMenuClass=t;this.addMenuClass();return t}addError(){this.menuPanel.classList.add("error")}removeError(){this.menuPanel.classList.remove("error");this.resetMenuClass()}async getUrl(e){if(e){return`https://api.bilibili.com/x/player/playurl?avid=${s.aid}&cid=${s.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${s.aid}&cid=${s.cid}&otype=json`}}}class o extends i{constructor(){super();this.menuClasses=["action","progress"];this.currentMenuClass="action"}async getUrl(){const e=await SpinQuery.select(()=>n[0]).catch(()=>logError("获取番剧下载链接失败."));return e}}class a extends i{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${s.aid}&cid=${s.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${s.aid}&cid=${s.cid}&qn=&otype=json`}}}class r{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new c(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{s.entity.getUrl().then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText);if(s.code!==0){t("获取清晰度信息失败.")}const i=s.data||s.result||s;const o=i.accept_quality;const a=i.accept_format.split(",");const l=i.accept_description;const c=[];while(o.length>0){const e=new r(o.pop(),a.pop(),l.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class l{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class c{constructor(e,t){this.format=e;this.fragments=t||[];this.progress=null;this.loaded=0;this.totalSize=null;this.workingXhr=null;this.fragmentSplitFactor=6*5}fetchVideoInfo(){return new Promise((e,t)=>{s.entity.getUrl(this.format.quality).then(n=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{const n=JSON.parse(i.responseText.replace(/http:/g,"https:"));const o=n.data||n.result||n;if(!s.isOldBangumi&&o.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const a=o.durl;this.fragments=a.map(e=>new l(e.length,e.size,e.url,e.backup_url));e(this.fragments)});i.withCredentials=true;i.open("GET",n);i.send()})})}cancelDownload(){if("forEach"in this.workingXhr){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];const s=Math.round(e.size/this.fragmentSplitFactor);let n=0;while(n{let n=0;const o=new XMLHttpRequest;o.open("GET",e.url);o.responseType="arraybuffer";o.withCredentials=false;o.addEventListener("progress",e=>{this.loaded+=e.loaded-n;n=e.loaded;this.progress&&this.progress(this.loaded/this.totalSize)});o.addEventListener("load",()=>{if((""+o.status)[0]==="2"){t(o.response)}else{s(`请求失败.`)}});o.addEventListener("abort",()=>s("下载已取消."));o.addEventListener("error",()=>s(`下载失败.`));o.setRequestHeader("Range",i);o.send();this.workingXhr.push(o)}));n=Math.round(n+s)+1}return Promise.all(t)}copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t=null){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=$("a#video-complete").attr("href");if(e&&$(`.link[href=${e}]`).length===0){URL.revokeObjectURL(e)}}downloadSingle(e){const[t]=e;const s=this.makeBlob(t);const n=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","")+this.extension();return[s,n]}async downloadMultiple(e){const t=new JSZip;const s=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","");if(e.length>1){e.forEach((e,n)=>{const i=this.fragments[n];t.file(`${s} - ${n+1}${this.extension(i)}`,this.makeBlob(e,i))})}else{const[n]=e;t.file(`${s}${this.extension()}`,this.makeBlob(n))}const n=await t.generateAsync({type:"blob"});const i=s+".zip";return[n,i]}async download(){const e=[];this.loaded=0;this.totalSize=this.fragments.map(e=>e.size).reduce((e,t)=>e+t);for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let t=null;let s=null;if(e.length===1){[t,s]=this.downloadSingle(e)}else{[t,s]=await this.downloadMultiple(e)}const n=URL.createObjectURL(t);this.cleanUpOldBlobUrl();this.progress&&this.progress(0);return{url:n,filename:s}}}async function d(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);s.aid=e;s.cid=t;if(document.URL.indexOf("bangumi")!==-1){const e=await SpinQuery.select(()=>document.querySelector("#bofqi"));if(!e.classList.contains("stardust-player")){s.isOldBangumi=true;s.entity=new o;await SpinQuery.unsafeJquery();unsafeWindow.$(unsafeWindow.document).ajaxSend((e,t,s)=>{if(s.url.indexOf("https://bangumi.bilibili.com/player/web_api/v2/playurl")!==-1){n.unshift(s.url)}})}else{s.isStardustBangumi=true;s.entity=new a}}else{s.entity=new i}return e!==undefined&&t!==undefined}async function u(){await d();const e=await r.availableFormats;let[n]=e;const i=()=>n.downloadInfo().catch(e=>{s.entity.addError();$(".video-error").text(e)});async function o(){if(!n){return}s.entity.nextMenuClass();const e=await i();e.progress=(e=>{$(".download-progress-value").text(`${fixed(e*100)}`);$(".download-progress-foreground").css("transform",`scaleX(${e})`)});document.querySelector(".download-progress-cancel>span").onclick=(()=>e.cancelDownload());const t=await e.download().catch(e=>{s.entity.addError();$(".video-error").text(e)});if(!t){return}const o=document.getElementById("video-complete");o.setAttribute("href",t.url);o.setAttribute("download",t.filename);o.click();const a=`下载完成. 再次保存`;Toast.success(a,"下载视频");s.entity.resetMenuClass()}async function a(){if(!n){return}const e=await i();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);s.entity.resetMenuClass()}$(".video-action>#video-action-download").on("click",o);$(".video-action>#video-action-copy").on("click",a);e.forEach(e=>{$(`${e.displayName}`).on("click",()=>{n=e;s.entity.nextMenuClass()}).prependTo("ol.video-quality")});t.applyStyle("downloadVideoStyle");const l=document.querySelector(".download-video-panel");const c=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!l.contains(e.target)){c()}});$(".video-error").on("click",()=>{$(".video-error").text("");s.entity.removeError()});s.entity.addMenuClass()}return{widget:{content:t.data.downloadVideoDom.text,condition:d,success:u}}}})(); @@ -1204,10 +1204,10 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/about.min.js"] = (()=>{return(e,i)=>{$("body").append(i.data.aboutDom.text);const n=GM_info.script.name.replace("Bilibili Evolved","").replace(/^[\(\) ]+|[\(\) ]+$/g,"")+" · "+e.currentVersion;$(".bilibili-evolved-version").text(n);const o=[{name:"jQuery",homepage:"https://jquery.com/",license:"MIT",version:"3.2.1"},{name:"JSZip",homepage:"https://stuk.github.io/jszip/",license:"MIT",version:"3.1.5"}];o.forEach(e=>{$(".open-source-components").append(`\n \n \n ${e.name}\n ${e.version} · ${e.license}\n \n \n `)});function t(){$("#about-close").on("click",()=>{$(".bilibili-evolved-about").toggleClass("opened")});$(".gui-settings").on("click",e=>{if(e.shiftKey===true){$(".bilibili-evolved-about").toggleClass("opened")}})}return{widget:{success:t}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/custom-control-background.min.css"] = `.bilibili-player-video-control-mask{background:0 0!important}.bilibili-player-video-control-bottom,.bui-slider .bui-track.bui-track-video-progress .bui-bar-wrap{background:rgba(0,0,0,var(--custom-control-background-opacity))!important}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/custom-control-background.min.js"] = (()=>{return(o,t)=>{if(o.customControlBackgroundOpacity>0){t.applyStyle("customControlBackgroundStyle");if(!o.touchVideoPlayer){t.applyImportantStyleFromText(`\n\n `)}}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-player-mode.min.js"] = (()=>{return(e,i)=>{const n=[{name:"常规",action:()=>{}},{name:"宽屏",action:()=>{$(".bilibili-player-video-btn-widescreen").click()}},{name:"网页全屏",action:()=>{$(".bilibili-player-video-web-fullscreen").click()}}];let t=()=>{};async function l(){if(e.autoLightOff){await SpinQuery.unsafeJquery();const e=await SpinQuery.any(()=>unsafeWindow.$(".bilibili-player-video-btn-setting"));e.mouseover().mouseout();t=(()=>{SpinQuery.any(()=>$(".bilibili-player-video-btn-setting-panel-others-content-lightoff .bui-checkbox-input"),e=>{const i=e[0];i.checked=true;raiseEvent(i,"change")})})}}async function a(){await l();await SpinQuery.condition(()=>$(".bilibili-player-video,.bilibili-player-video-btn-start,.bilibili-player-area"),e=>e.length===3&&$("video").length>0&&$("video").prop("duration"));const i=document.querySelector("video");if(i.length===0){return}const a=n.find(i=>i.name===e.defaultPlayerMode);if(a.name==="全屏"){const e=await SpinQuery.unsafeJquery();const i=document.querySelector(".bilibili-player-video-btn-start");const n=()=>{const t=e(".bilibili-player-video-btn-fullscreen").data("events");if(t.click&&t.click[0]&&t.click[0].handler){const i=e(".bilibili-player-video-btn-fullscreen").data("events").click[0].handler;console.log(i);i()}i.removeEventListener("click",n)};i.addEventListener("click",n)}else{const n=()=>{if(a&&$("#bilibiliPlayer[class*=mode-]").length===0){a.action()}t();if(e.applyPlayerModeOnPlay){i.removeEventListener("play",n)}};if(e.applyPlayerModeOnPlay){i.addEventListener("play",n)}else{n()}}}(Observer.childList||Observer.subtree)("#bofqi",()=>a())}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-video-quality.min.js"] = (()=>{return(e,a)=>{const t=[{name:"1080P60",value:116},{name:"1080P+",value:112},{name:"1080P",value:80},{name:"720P60",value:74},{name:"720P",value:64},{name:"480P",value:32},{name:"360P",value:15},{name:"自动",value:0}];async function i(){const a=await SpinQuery.any(()=>$(".bilibili-player-video-quality-menu .bui-select-list>li.bui-select-item"));const i=(e,a)=>a-e;const[n]=a.toArray().map(e=>parseInt(e.getAttribute("data-value"))).sort(i);const[l]=t.filter(a=>a.name===e.defaultVideoQuality).map(e=>e.value).sort(i);const[o]=t.map(e=>e.value).filter(e=>e<=Math.min(l,n)).sort(i);console.info(`[Video Quality] availableHighestQualities=${n}`);console.info(`[Video Quality] targetQuality=${l}`);console.info(`[Video Quality] finalQuality=${o}`);const u=await SpinQuery.condition(()=>document.querySelector("video"),e=>e);function s(){a.each((e,a)=>{if(parseInt(a.getAttribute("data-value"))===o){a.click()}});this.removeEventListener("play",s)}u.addEventListener("play",s)}(Observer.childList||Observer.subtree)("#bofqi",()=>i())}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-player-mode.min.js"] = (()=>{return(e,i)=>{const n=[{name:"常规",action:()=>{}},{name:"宽屏",action:()=>{$(".bilibili-player-video-btn-widescreen").click()}},{name:"网页全屏",action:()=>{$(".bilibili-player-video-web-fullscreen").click()}}];let t=()=>{};async function l(){if(e.autoLightOff){await SpinQuery.unsafeJquery();const e=await SpinQuery.any(()=>unsafeWindow.$(".bilibili-player-video-btn-setting"));e.mouseover().mouseout();t=(()=>{SpinQuery.any(()=>$(".bilibili-player-video-btn-setting-panel-others-content-lightoff .bui-checkbox-input"),e=>{const i=e[0];i.checked=true;raiseEvent(i,"change")})})}}async function a(){await l();await SpinQuery.condition(()=>$(".bilibili-player-video,.bilibili-player-video-btn-start,.bilibili-player-area"),e=>e.length===3&&$("video").length>0&&$("video").prop("duration"));const i=document.querySelector("video");if(i.length===0){return}const a=n.find(i=>i.name===e.defaultPlayerMode);if(a.name==="全屏"){const e=await SpinQuery.unsafeJquery();const i=document.querySelector(".bilibili-player-video-btn-start");const n=()=>{const t=e(".bilibili-player-video-btn-fullscreen").data("events");if(t.click&&t.click[0]&&t.click[0].handler){const i=e(".bilibili-player-video-btn-fullscreen").data("events").click[0].handler;console.log(i);i()}i.removeEventListener("click",n)};i.addEventListener("click",n)}else{const n=()=>{if(a&&$("#bilibiliPlayer[class*=mode-]").length===0){a.action()}t();if(e.applyPlayerModeOnPlay){i.removeEventListener("play",n)}};if(e.applyPlayerModeOnPlay){i.addEventListener("play",n)}else{n()}}}Observer.childListSubtree("#bofqi",()=>a())}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-video-quality.min.js"] = (()=>{return(e,a)=>{const t=[{name:"1080P60",value:116},{name:"1080P+",value:112},{name:"1080P",value:80},{name:"720P60",value:74},{name:"720P",value:64},{name:"480P",value:32},{name:"360P",value:15},{name:"自动",value:0}];async function i(){const a=await SpinQuery.any(()=>$(".bilibili-player-video-quality-menu .bui-select-list>li.bui-select-item"));const i=(e,a)=>a-e;const[n]=a.toArray().map(e=>parseInt(e.getAttribute("data-value"))).sort(i);const[l]=t.filter(a=>a.name===e.defaultVideoQuality).map(e=>e.value).sort(i);const[o]=t.map(e=>e.value).filter(e=>e<=Math.min(l,n)).sort(i);console.info(`[Video Quality] availableHighestQualities=${n}`);console.info(`[Video Quality] targetQuality=${l}`);console.info(`[Video Quality] finalQuality=${o}`);const u=await SpinQuery.condition(()=>document.querySelector("video"),e=>e);function s(){a.each((e,a)=>{if(parseInt(a.getAttribute("data-value"))===o){a.click()}});this.removeEventListener("play",s)}u.addEventListener("play",s)}Observer.childListSubtree("#bofqi",()=>i())}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/combo-like.min.js"] = (()=>{return(e,t)=>{(async()=>{const e=await SpinQuery.select(()=>document.querySelector(".ops span.like"));e.style.userSelect="none";function t(t,n){const s=new CustomEvent(t,n);e.dispatchEvent(s)}const n=200;let s=true;e.addEventListener("touchstart",e=>{e.preventDefault();s=true;setTimeout(()=>s=false,n);t("mousedown",e)});e.addEventListener("touchend",e=>{e.preventDefault();t("mouseup",e);if(s===true){t("click",e)}})})()}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/auto-continue.min.js"] = (()=>{return(e,t)=>{function i(e){const t=/((\d)*:)?(\d)*:(\d)*/g;const i=e.text();const n=i.match(t);if(!n){return}const r=n[0].split(":");const o=(()=>{if(r.length===3){const[e,t,i]=r.map(e=>parseInt(e));return e*60*60+t*60+i}else if(r.length===2){const[e,t]=r.map(e=>parseInt(e));return e*60+t}else{logError(`解析历史时间发生错误: historyTime=${JSON.stringify(r)}`);return NaN}})();const s=e.parent();const l=document.querySelector("video");if(o从头开始`);t.appendTo(s).on("click",()=>l.currentTime=0);e.html(`已跳转到上次历史记录${n[0]}`)}else{s.find(".bilibili-player-video-toast-item-close").get(0).click()}}function n(){SpinQuery.condition(()=>$(".bilibili-player-video-toast-item-text"),e=>e.text().indexOf("上次看到")!==-1,e=>i(e.filter((e,t)=>t.innerText.indexOf("上次看到")!==-1)))}(Observer.childList||Observer.subtree)("#bofqi",n)}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/auto-continue.min.js"] = (()=>{return(e,t)=>{function i(e){const t=/((\d)*:)?(\d)*:(\d)*/g;const i=e.text();const n=i.match(t);if(!n){return}const r=n[0].split(":");const o=(()=>{if(r.length===3){const[e,t,i]=r.map(e=>parseInt(e));return e*60*60+t*60+i}else if(r.length===2){const[e,t]=r.map(e=>parseInt(e));return e*60+t}else{logError(`解析历史时间发生错误: historyTime=${JSON.stringify(r)}`);return NaN}})();const s=e.parent();const l=document.querySelector("video");if(o从头开始`);t.appendTo(s).on("click",()=>l.currentTime=0);e.html(`已跳转到上次历史记录${n[0]}`)}else{s.find(".bilibili-player-video-toast-item-close").get(0).click()}}function n(){SpinQuery.condition(()=>$(".bilibili-player-video-toast-item-text"),e=>e.text().indexOf("上次看到")!==-1,e=>i(e.filter((e,t)=>t.innerText.indexOf("上次看到")!==-1)))}Observer.childListSubtree("#bofqi",n)}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-description.min.css"] = `.video-desc .info{height:auto!important}.video-desc .btn{display:none!important}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-description.min.js"] = (()=>{return(e,p)=>{p.applyStyle("expandDescriptionStyle")}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-danmaku-settings.min.js"] = (()=>{return(e,n)=>{async function t(e,n){const t=await SpinQuery.select(()=>document.querySelector(e));if(!t){return}t.checked=n;raiseEvent(t,"change")}const i={enableDanmaku:".bilibili-player-video-danmaku-switch>input",settingsIcon:".bilibili-player-video-danmaku-setting"};if(!e.enableDanmaku){t(i.enableDanmaku,false)}if(e.rememberDanmakuBlock){for(const n in e.danmakuBlockSettings){i[n]=`.bilibili-player-block-filter-type[ftype=${n}]`}async function a(){await SpinQuery.unsafeJquery();const n=await SpinQuery.any(()=>unsafeWindow.$(i.settingsIcon));n.mouseover().mouseout();for(const[n,t]of Object.entries(e.danmakuBlockSettings)){if(t===true){const e=await SpinQuery.select(()=>document.querySelector(i[n]));e.click()}}}async function c(){for(const n in e.danmakuBlockSettings){const t=await SpinQuery.select(()=>document.querySelector(i[n]));t.addEventListener("click",()=>{e.danmakuBlockSettings[n]=t.classList.contains("disabled");saveSettings(e)})}}a();c()}}})(); diff --git a/bilibili-evolved.preview-offline.user.js b/bilibili-evolved.preview-offline.user.js index 9f4d08fe7..a054cae29 100644 --- a/bilibili-evolved.preview-offline.user.js +++ b/bilibili-evolved.preview-offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Preview Offline) -// @version 191.96 +// @version 192.03 // @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howrad (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -1180,19 +1180,19 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/new-styles.min.js"] = (()=>{return(e,t)=>{if(document.URL===`https://h.bilibili.com/`){return}SpinQuery.any(()=>$(".custom-scrollbar"),e=>e.removeClass("custom-scrollbar"));SpinQuery.any(()=>$("#banner_link"),()=>t.removeStyle("tweetsStyle"));const l={selectors:["div.nav-con.fl","#link-navbar-vm",".link-navbar",".nav-header-wrapper",".z_top .z_header"],get allSelectors(){return this.selectors.reduce((e,t)=>e+","+t)},get navbar(){let e=null;for(const t of this.selectors){e=e||document.querySelector(t)}return e},supports(e){if(e instanceof Element){const t=parseInt(window.getComputedStyle(e).height);const l=[60,50,0,56];return l.indexOf(t)!==-1}return false}};SpinQuery.any(()=>$(l.allSelectors),()=>{const e=l.navbar;if(l.supports(e)){t.applyStyle("style","bilibili-style-optimization")}else{t.applyStyle("oldStyle","bilibili-style-optimization")}})}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/override-navbar.min.js"] = (()=>{return(e,n)=>{new SpinQuery(()=>$(".head-content.bili-wrapper>div.search:not(.filter-item)"),e=>e.length>0&&$(".nav-con.fr").filter((e,n)=>n.innerText).length>0,e=>{const n=$(".nav-con.fr").filter((e,n)=>n.innerText);e.detach().insertAfter(n)}).start();SpinQuery.any(()=>$("#banner_link"),()=>n.removeStyle("tweetsStyle"));if(e.preserveRank){SpinQuery.any(()=>$(".head-content.bili-wrapper>div.search:not(.filter-item) .searchform,.nav-con #nav_searchform"),e=>{e.addClass("preserve-rank");if(e.find("a.icons-enabled").length===0){e.prepend(`\n \n \n \n `)}})}else{SpinQuery.any(()=>$(".head-content.bili-wrapper>div.search:not(.filter-item) .searchform,.nav-con #nav_searchform"),e=>{e.removeClass("preserve-rank");e.find("a.icons-enabled").remove()})}if(!e.showBanner){n.applyStyle("noBannerStyle")}else{n.removeStyle("noBannerStyle")}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-navbar.min.js"] = (()=>{return()=>{SpinQuery.count(()=>$("ul.fr>li.nav-item").not(".profile-info"),6,n=>{const r=(n,r)=>{const t=$(r);t.css("cursor","pointer");const o=t.find("a.t");o.removeAttr("href")};n.each(r)})}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-player.min.js"] = (()=>{return(t,i)=>{const e=t=>{let i=0;let e=0;while(t&&!isNaN(t.offsetLeft)&&!isNaN(t.offsetTop)){i+=t.offsetLeft-t.scrollLeft;e+=t.offsetTop-t.scrollTop;t=t.offsetParent}return{x:i,y:e}};const o=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let s=fixed(o)+"秒";if(e>0){s=e+"分"+s}if(i>0){s=i+"时"+s}return s};const s=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let s=(o<10?"0":"")+fixed(o);s=(e<10?"0":"")+e+":"+s;s=(i<10?"0":"")+i+":"+s;return s};class n{constructor(t){this.action=new l(t);this.onTouchStart=null;this.onTouchEnd=null;this.direction=null;t.addEventListener("touchstart",t=>{this.xDown=t.touches[0].clientX;this.yDown=t.touches[0].clientY;if(this.onTouchStart){this.onTouchStart(t)}});t.addEventListener("touchmove",i=>{if(!this.xDown||!this.yDown){return}const o=i.touches[0].clientX;const s=i.touches[0].clientY;const n=e(t);const l={x:(i.touches[0].pageX-n.x)/t.clientWidth,y:(i.touches[0].pageY-n.y)/t.clientHeight,width:t.clientWidth,height:t.clientHeight};const a=this.xDown-o;const c=this.yDown-s;if(!this.direction){let t="";if(Math.abs(a)>Math.abs(c)){t="horizontal"}else{t="vertical"}this.direction=t;i.preventDefault()}else{if(this.direction==="vertical"){this.action.startAction(this.direction,c,l)}else if(this.direction==="horizontal"){this.action.startAction(this.direction,-a,l)}i.preventDefault()}});t.addEventListener("touchend",t=>{this.xDown=null;this.yDown=null;this.direction=null;if(this.onTouchEnd){this.onTouchEnd(t)}})}}class l{constructor(t){this.lowSpeedForward=null;this.lowSpeedBackward=null;this.mediumSpeedForward=null;this.mediumSpeedBackward=null;this.highSpeedForward=null;this.highSpeedBackward=null;this.lowVolumeUp=null;this.lowVolumeDown=null;this.mediumVolumeUp=null;this.mediumVolumeDown=null;this.highVolumeUp=null;this.highVolumeDown=null;this.speedCancel=null;this.volumeCancel=null;this.minSwipeDistance=20;this.onActionStart=null;this.onActionEnd=null;this.element=t;this.touchStart=false;this.startPosition=null;this.lastAction=null;t.addEventListener("touchstart",t=>{this.touchStart=true});t.addEventListener("touchend",t=>{this.startPosition=null;this.onActionEnd&&this.onActionEnd(this.lastAction);this.lastAction=null})}startAction(t,i,e){if(this.touchStart){this.onActionStart&&this.onActionStart(t);this.startPosition=e;this.touchStart=false}if(t==="vertical"){if(Math.abs(i)=1/3&&this.startPosition.x<=2/3){t=1;o=this.mediumVolumeUp;s=this.mediumVolumeDown}else{t=2;o=this.highVolumeUp;s=this.highVolumeDown}if(i>0){const s=Math.round(t*100*(i-this.minSwipeDistance)/(1.5*e.height));o&&o(s);this.lastAction={type:"volume",volume:s}}else{const o=Math.round(t*100*(i+this.minSwipeDistance)/(1.5*e.height));s&&s(o);this.lastAction={type:"volume",volume:o}}}}else if(t==="horizontal"){if(e.y<1/3&&(e.x<.1||e.x>.9)||Math.abs(i)=1/3&&this.startPosition.y<=2/3){t=.2;e=this.mediumSpeedForward;o=this.mediumSpeedBackward}else{t=1;e=this.highSpeedForward;o=this.highSpeedBackward}if(i>0){const o=(i-this.minSwipeDistance)*t;e&&e(o);this.lastAction={type:"playback",seconds:o}}else{const e=(i+this.minSwipeDistance)*t;o&&o(e);this.lastAction={type:"playback",seconds:e}}}}}}class a{constructor(){this.aid=unsafeWindow.aid;this.cid=unsafeWindow.cid;this.cidData=null;this.supportWebp=a.supportWebp}getVideoshot(t,i){if(!this.cidData){downloadText(`https://api.bilibili.com/x/player/videoshot?aid=${this.aid}&cid=${this.cid}&index=1`).then(e=>{this.cidData=JSON.parse(e).data;this.getVideoshot(t,i)})}else{const e=this.cidData;const o=e.index;let s=0;for(let i=0;i=o[i]&&tt.replace(".jpg",".jpg@.webp"))}const l=parseInt(e.pv_x_len)||10;const a=parseInt(e.pv_y_len)||10;const c=parseInt(e.pv_x_size)||160;const r=parseInt(e.pv_y_size)||90;const h=-(s%100%l)*c;const d=-Math.floor(s%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(s/100)]})`,backgroundPosition:`${h}px ${d}px`})}}static get supportWebp(){try{const t=document.createElement("canvas");if(t.getContext&&t.getContext("2d"))try{return t.toDataURL("image/webp").indexOf("data:image/webp")===0}catch(t){return false}else return false}catch(t){return false}}}function c(t){t.unbind("click")}function r(i){if($(".touch-video-box").length!==0){return}$(".bilibili-player-video-subtitle").before(`\n \n \n \n \n \n `);const e=$("video");const l=e.prop("duration");const c=new n(i.get(0));const r=document.getElementsByClassName("touch-video-info")[0];const h=document.getElementsByClassName("touch-video-box")[0];let d=Math.round(e.prop("volume")*100);const u=t=>{t/=100;if(t<0){t=0}else if(t>1){t=1}e.prop("volume",t);$(".bilibili-player-video-volume-num").text(Math.round(t*100));$(".bui-thumb").css("transform",`translateY(-${48*t}px)`);$(".bui-track-vertical .bui-bar").css("transform",`scaleY(${t})`);if(t===0){$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",true)}else if(t===1){$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-max");e.prop("muted",false)}else{$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",false)}};if(t.touchVideoPlayerAnimation){h.classList.add("animation")}c.action.onActionStart=(t=>{h.classList.add("adjust-opened");r.innerHTML="";d=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");let a=n+i;let c=fixed(100*a/l);let h=i;if(a>l){a=l;c=100;h=l-n}else if(a<0){a=0;c=0;h=n}const d=`${s(n)} →${s(a)} (${c}%)`;const u=`\n \n \n ${t}速\n \n \n 进度: ${i>0?"+":"-"}${o(h)}\n \n \n \n \n \n \n \n ${d}\n \n \n `;r.innerHTML=u;p.getVideoshot(a,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${c/100})`)}};c.action.lowSpeedBackward=m("低");c.action.lowSpeedForward=m("低");c.action.mediumSpeedBackward=m("中");c.action.mediumSpeedForward=m("中");c.action.highSpeedBackward=m("高");c.action.highSpeedForward=m("高");const v=t=>{return i=>{let e=d+i;let o=Math.abs(i);if(e>100){e=100;o=100-d}else if(e<0){e=0;o=d}const s=`${d} → ${e}`;u(e);const n=`\n \n \n ${t}速\n \n \n 音量: ${i>0?"+":"-"}${o}\n \n \n \n \n ${s}\n \n \n `;r.innerHTML=n;$(".touch-progress").css("transform",`scaleX(${e/100})`)}};c.action.lowVolumeUp=v("低");c.action.lowVolumeDown=v("低");c.action.mediumVolumeUp=v("中");c.action.mediumVolumeDown=v("中");c.action.highVolumeUp=v("高");c.action.highVolumeDown=v("高");c.action.speedCancel=(()=>{r.innerHTML=`松开手指,取消进退`;$(".touch-progress").css("transform","scaleX(0)")});c.action.volumeCancel=(()=>{r.innerHTML=`松开手指,取消调整`;$(".touch-progress").css("transform","scaleX(0)");u(d)});if(!unsafeWindow.TOUCH_PLAYER_DEBUG){c.action.onActionEnd=(t=>{r.innerHTML="";if(t){if(t.type==="playback"){let i=e.prop("currentTime");i+=t.seconds;if(i<0){i=0}else if(i>l){i=l}e.prop("currentTime",i)}}h.classList.remove("adjust-opened")})}}function h(t){if(!t.hasClass("disable-original-hover")){t.addClass("disable-original-hover");const i=unsafeWindow.$(".bilibili-player-video");const e="touch-video-control-show";const o=i.data("events").click[0].handler;const s=new DoubleClickEvent(t=>o(t),()=>t.toggleClass(e));i.unbind("click");s.bind(i[0])}}function d(){SpinQuery.any(()=>$(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),c);new SpinQuery(()=>$(".bilibili-player-video"),t=>t.length>0&&$("video").length>0&&$("video").prop("duration"),r).start();if(t.touchVideoPlayerDoubleTapControl){new SpinQuery(()=>$(".bilibili-player-area"),t=>t.length>0&&unsafeWindow.$&&unsafeWindow.$(".bilibili-player-video").data("events"),h).start()}}(Observer.childList||Observer.subtree)("#bofqi",()=>d());i.applyStyle("touchPlayerStyle")}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-danmaku.min.js"] = (()=>{return()=>{(Observer.childList||Observer.subtree)("#bofqi",()=>{SpinQuery.any(()=>$(".bui-collapse-header"),e=>{if(parseInt($(".bui-collapse-body").css("height"))===0&&$(".bui-collapse-arrow-text").text()==="展开"){e.click()}})})}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-player.min.js"] = (()=>{return(t,i)=>{const e=t=>{let i=0;let e=0;while(t&&!isNaN(t.offsetLeft)&&!isNaN(t.offsetTop)){i+=t.offsetLeft-t.scrollLeft;e+=t.offsetTop-t.scrollTop;t=t.offsetParent}return{x:i,y:e}};const o=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let s=fixed(o)+"秒";if(e>0){s=e+"分"+s}if(i>0){s=i+"时"+s}return s};const s=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let s=(o<10?"0":"")+fixed(o);s=(e<10?"0":"")+e+":"+s;s=(i<10?"0":"")+i+":"+s;return s};class n{constructor(t){this.action=new l(t);this.onTouchStart=null;this.onTouchEnd=null;this.direction=null;t.addEventListener("touchstart",t=>{this.xDown=t.touches[0].clientX;this.yDown=t.touches[0].clientY;if(this.onTouchStart){this.onTouchStart(t)}});t.addEventListener("touchmove",i=>{if(!this.xDown||!this.yDown){return}const o=i.touches[0].clientX;const s=i.touches[0].clientY;const n=e(t);const l={x:(i.touches[0].pageX-n.x)/t.clientWidth,y:(i.touches[0].pageY-n.y)/t.clientHeight,width:t.clientWidth,height:t.clientHeight};const a=this.xDown-o;const c=this.yDown-s;if(!this.direction){let t="";if(Math.abs(a)>Math.abs(c)){t="horizontal"}else{t="vertical"}this.direction=t;i.preventDefault()}else{if(this.direction==="vertical"){this.action.startAction(this.direction,c,l)}else if(this.direction==="horizontal"){this.action.startAction(this.direction,-a,l)}i.preventDefault()}});t.addEventListener("touchend",t=>{this.xDown=null;this.yDown=null;this.direction=null;if(this.onTouchEnd){this.onTouchEnd(t)}})}}class l{constructor(t){this.lowSpeedForward=null;this.lowSpeedBackward=null;this.mediumSpeedForward=null;this.mediumSpeedBackward=null;this.highSpeedForward=null;this.highSpeedBackward=null;this.lowVolumeUp=null;this.lowVolumeDown=null;this.mediumVolumeUp=null;this.mediumVolumeDown=null;this.highVolumeUp=null;this.highVolumeDown=null;this.speedCancel=null;this.volumeCancel=null;this.minSwipeDistance=20;this.onActionStart=null;this.onActionEnd=null;this.element=t;this.touchStart=false;this.startPosition=null;this.lastAction=null;t.addEventListener("touchstart",t=>{this.touchStart=true});t.addEventListener("touchend",t=>{this.startPosition=null;this.onActionEnd&&this.onActionEnd(this.lastAction);this.lastAction=null})}startAction(t,i,e){if(this.touchStart){this.onActionStart&&this.onActionStart(t);this.startPosition=e;this.touchStart=false}if(t==="vertical"){if(Math.abs(i)=1/3&&this.startPosition.x<=2/3){t=1;o=this.mediumVolumeUp;s=this.mediumVolumeDown}else{t=2;o=this.highVolumeUp;s=this.highVolumeDown}if(i>0){const s=Math.round(t*100*(i-this.minSwipeDistance)/(1.5*e.height));o&&o(s);this.lastAction={type:"volume",volume:s}}else{const o=Math.round(t*100*(i+this.minSwipeDistance)/(1.5*e.height));s&&s(o);this.lastAction={type:"volume",volume:o}}}}else if(t==="horizontal"){if(e.y<1/3&&(e.x<.1||e.x>.9)||Math.abs(i)=1/3&&this.startPosition.y<=2/3){t=.2;e=this.mediumSpeedForward;o=this.mediumSpeedBackward}else{t=1;e=this.highSpeedForward;o=this.highSpeedBackward}if(i>0){const o=(i-this.minSwipeDistance)*t;e&&e(o);this.lastAction={type:"playback",seconds:o}}else{const e=(i+this.minSwipeDistance)*t;o&&o(e);this.lastAction={type:"playback",seconds:e}}}}}}class a{constructor(){this.aid=unsafeWindow.aid;this.cid=unsafeWindow.cid;this.cidData=null;this.supportWebp=a.supportWebp}getVideoshot(t,i){if(!this.cidData){downloadText(`https://api.bilibili.com/x/player/videoshot?aid=${this.aid}&cid=${this.cid}&index=1`).then(e=>{this.cidData=JSON.parse(e).data;this.getVideoshot(t,i)})}else{const e=this.cidData;const o=e.index;let s=0;for(let i=0;i=o[i]&&tt.replace(".jpg",".jpg@.webp"))}const l=parseInt(e.pv_x_len)||10;const a=parseInt(e.pv_y_len)||10;const c=parseInt(e.pv_x_size)||160;const r=parseInt(e.pv_y_size)||90;const h=-(s%100%l)*c;const d=-Math.floor(s%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(s/100)]})`,backgroundPosition:`${h}px ${d}px`})}}static get supportWebp(){try{const t=document.createElement("canvas");if(t.getContext&&t.getContext("2d"))try{return t.toDataURL("image/webp").indexOf("data:image/webp")===0}catch(t){return false}else return false}catch(t){return false}}}function c(t){t.unbind("click")}function r(i){if($(".touch-video-box").length!==0){return}$(".bilibili-player-video-subtitle").before(`\n \n \n \n \n \n `);const e=$("video");const l=e.prop("duration");const c=new n(i.get(0));const r=document.getElementsByClassName("touch-video-info")[0];const h=document.getElementsByClassName("touch-video-box")[0];let d=Math.round(e.prop("volume")*100);const u=t=>{t/=100;if(t<0){t=0}else if(t>1){t=1}e.prop("volume",t);$(".bilibili-player-video-volume-num").text(Math.round(t*100));$(".bui-thumb").css("transform",`translateY(-${48*t}px)`);$(".bui-track-vertical .bui-bar").css("transform",`scaleY(${t})`);if(t===0){$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",true)}else if(t===1){$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-max");e.prop("muted",false)}else{$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",false)}};if(t.touchVideoPlayerAnimation){h.classList.add("animation")}c.action.onActionStart=(t=>{h.classList.add("adjust-opened");r.innerHTML="";d=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");let a=n+i;let c=fixed(100*a/l);let h=i;if(a>l){a=l;c=100;h=l-n}else if(a<0){a=0;c=0;h=n}const d=`${s(n)} →${s(a)} (${c}%)`;const u=`\n \n \n ${t}速\n \n \n 进度: ${i>0?"+":"-"}${o(h)}\n \n \n \n \n \n \n \n ${d}\n \n \n `;r.innerHTML=u;p.getVideoshot(a,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${c/100})`)}};c.action.lowSpeedBackward=m("低");c.action.lowSpeedForward=m("低");c.action.mediumSpeedBackward=m("中");c.action.mediumSpeedForward=m("中");c.action.highSpeedBackward=m("高");c.action.highSpeedForward=m("高");const v=t=>{return i=>{let e=d+i;let o=Math.abs(i);if(e>100){e=100;o=100-d}else if(e<0){e=0;o=d}const s=`${d} → ${e}`;u(e);const n=`\n \n \n ${t}速\n \n \n 音量: ${i>0?"+":"-"}${o}\n \n \n \n \n ${s}\n \n \n `;r.innerHTML=n;$(".touch-progress").css("transform",`scaleX(${e/100})`)}};c.action.lowVolumeUp=v("低");c.action.lowVolumeDown=v("低");c.action.mediumVolumeUp=v("中");c.action.mediumVolumeDown=v("中");c.action.highVolumeUp=v("高");c.action.highVolumeDown=v("高");c.action.speedCancel=(()=>{r.innerHTML=`松开手指,取消进退`;$(".touch-progress").css("transform","scaleX(0)")});c.action.volumeCancel=(()=>{r.innerHTML=`松开手指,取消调整`;$(".touch-progress").css("transform","scaleX(0)");u(d)});if(!unsafeWindow.TOUCH_PLAYER_DEBUG){c.action.onActionEnd=(t=>{r.innerHTML="";if(t){if(t.type==="playback"){let i=e.prop("currentTime");i+=t.seconds;if(i<0){i=0}else if(i>l){i=l}e.prop("currentTime",i)}}h.classList.remove("adjust-opened")})}}function h(t){if(!t.hasClass("disable-original-hover")){t.addClass("disable-original-hover");const i=unsafeWindow.$(".bilibili-player-video");const e="touch-video-control-show";const o=i.data("events").click[0].handler;const s=new DoubleClickEvent(t=>o(t),()=>t.toggleClass(e));i.unbind("click");s.bind(i[0])}}function d(){SpinQuery.any(()=>$(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),c);new SpinQuery(()=>$(".bilibili-player-video"),t=>t.length>0&&$("video").length>0&&$("video").prop("duration"),r).start();if(t.touchVideoPlayerDoubleTapControl){new SpinQuery(()=>$(".bilibili-player-area"),t=>t.length>0&&unsafeWindow.$&&unsafeWindow.$(".bilibili-player-video").data("events"),h).start()}}Observer.childListSubtree("#bofqi",()=>d());i.applyStyle("touchPlayerStyle")}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-danmaku.min.js"] = (()=>{return()=>{Observer.childListSubtree("#bofqi",()=>{SpinQuery.any(()=>$(".bui-collapse-header"),e=>{if(parseInt($(".bui-collapse-body").css("height"))===0&&$(".bui-collapse-arrow-text").text()==="展开"){e.click()}})})}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/remove-promotions.min.js"] = (()=>{return(n,i)=>{SpinQuery.any(()=>$(".gg-pic").parent("a"),n=>{n.css("display","none");n.each((n,i)=>{const e=$(i).index()+1;const c=$(i).parent().parent().find(`.pic li:nth-child(${e})`);$(c).css("visibility","hidden")})})}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater.min.js"] = (()=>{return()=>{const e=e=>{const t=e.match(/(av[\d]+)\/p([\d]+)/);if(t){return`https://www.bilibili.com/video/${t[1]}/?p=${t[2]}`}else{return"javascript:;"}};const t=t=>{const r=t.map(t=>{const r=t.getAttribute("href");if(!r){return"javascript:;"}if(r.match(/.*watchlater.*|javascript:;/g)){return e(r)}if(r.indexOf("video/av")!==-1){return r}});t.forEach((e,t)=>$(e).attr("href",r[t]).attr("target","_blank"))};const r=(...e)=>{for(const r of e){SpinQuery.select(()=>document.querySelectorAll(r),e=>t([...e]))}};SpinQuery.any(()=>$(".watch-later-list"),()=>{(Observer.childListSubtree||Observer.subtree)("#viewlater-app",()=>{SpinQuery.condition(()=>document.URL.match(/(av[\d]+)\/p([\d]+)/),e=>e&&document.URL.indexOf("watchlater")!==-1,()=>{const t=e(document.URL);if(t!==null){window.location.replace(t)}});SpinQuery.any(()=>$("#viewlater-app .s-btn[href='#/']"),e=>e.remove());r(".av-pic",".av-about>a")})});SpinQuery.any(()=>$("li.nav-item[report-id*=watchlater]"),()=>{(Observer.childListSubtree||Observer.subtree)("li.nav-item[report-id*=watchlater]",()=>{r(".av-item>a",".av-about>a","div.watch-later-m>ul>div>li>a");SpinQuery.any(()=>$(".read-more.mr"),e=>e.remove());SpinQuery.any(()=>$(".read-more-grp>.read-more"),e=>e.css({float:"none",width:"auto"}))})})}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/hide-top-search.min.js"] = (()=>{return()=>{const e=[".nav-search-keyword",".search-keyword"];for(const r of e){new SpinQuery(()=>$(r),e=>e!==undefined&&e.length>0&&e.attr("placeholder").length>0,e=>e.attr("placeholder","搜索")).start()}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/haruna-scale.min.js"] = (()=>{return(n,t)=>{const a="bilibili-haruna-scale";if($(a).length===0){t.applyStyleFromText(`\n \n `)}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/remove-watermark.min.js"] = (()=>{return(i,l)=>{const n="bilibili-live-watermark";if($(`#${n}`).length===0){l.applyStyleFromText(`\n \n `)}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/full-tweets-title.min.js"] = (()=>{return(e,l)=>{l.applyStyle("fullTweetsTitleStyle")}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{const n=t.attributes.videoInfo.export.VideoInfo;class i{constructor(e){this.url=e;if($(".image-viewer").length===0){this.createDom()}this.viewer=$(".image-viewer-container");this.downloadImage()}createDom(){$("body").append(t.data.imageViewerDom.text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","");const n=URL.createObjectURL(e.response);this.imageData=n;this.viewer.find(".download").attr("href",n).attr("download",t);this.viewer.find(".image").prop("src",n)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}if($("meta[itemprop='image'],meta[property='og:image']").length>0){return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.condition(()=>(unsafeWindow||window).aid,e=>e!==undefined);return e!=="undefined"},success:async()=>{async function e(){const e=(unsafeWindow||window).aid;const t=new n(e);await t.fetchInfo();return t.coverUrl}let t=new i(await e());$("#view-cover").on("click",()=>{t.show()});(Observer.childList||Observer.subtree)("#bofqi",async()=>{t=new i(await e())})}}}}else{return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.any(()=>$(".header-info-ctnr .room-cover"));return typeof e!=="undefined"},success:async()=>{const e=$(".header-info-ctnr .room-cover");const t=e.attr("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const n=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const o=await downloadText(n);const s=JSON.parse(o).data.cover;const a=new i(s);$("#view-cover").on("click",()=>{a.show()})}}}}}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{const n=t.attributes.videoInfo.export.VideoInfo;class i{constructor(e){this.url=e;if($(".image-viewer").length===0){this.createDom()}this.viewer=$(".image-viewer-container");this.downloadImage()}createDom(){$("body").append(t.data.imageViewerDom.text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","");const n=URL.createObjectURL(e.response);this.imageData=n;this.viewer.find(".download").attr("href",n).attr("download",t);this.viewer.find(".image").prop("src",n)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}if($("meta[itemprop='image'],meta[property='og:image']").length>0){return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.condition(()=>(unsafeWindow||window).aid,e=>e!==undefined);return e!=="undefined"},success:async()=>{async function e(){const e=(unsafeWindow||window).aid;const t=new n(e);await t.fetchInfo();return t.coverUrl}let t=new i(await e());$("#view-cover").on("click",()=>{t.show()});Observer.childListSubtree("#bofqi",async()=>{t=new i(await e())})}}}}else{return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.any(()=>$(".header-info-ctnr .room-cover"));return typeof e!=="undefined"},success:async()=>{const e=$(".header-info-ctnr .room-cover");const t=e.attr("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const n=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const o=await downloadText(n);const a=JSON.parse(o).data.cover;const s=new i(a);$("#view-cover").on("click",()=>{s.show()})}}}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/notify-new-version.min.js"] = (()=>{return(e,n)=>{const t={less:-1,equal:0,greater:1,incomparable:NaN};class s{constructor(e){this.parts=e.split(".").map(e=>parseInt(e));this.versionString=e}compareTo(e){for(let n=0;ne.parts[n]){return t.greater}return t.less}if(this.parts.length!==e.parts.length){return t.less}return t.equal}greaterThan(e){return this.compareTo(e)===t.greater}lessThan(e){return this.compareTo(e)===t.less}equals(e){return this.compareTo(e)===t.equal}}const r=new s(n.data.latestVersion.text);const i=new s(e.currentVersion);if(r.greaterThan(i)){const n=`新版本${r.versionString}已发布. 安装查看`;const t=Toast.info(n,"检查更新");$("#new-version-link").on("click",()=>t&&t.dismiss());return{widget:{content:`\n \n \n \n 安装更新\n \n \n \n \n 查看更新\n \n `,success:()=>{$("#new-version-update").on("click",()=>document.querySelector("#new-version-update a").click());$("#new-version-info").on("click",()=>document.querySelector("#new-version-info a").click())}}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/toast.min.js"] = (()=>{return(t,s)=>{class e{constructor(t="",s="",e="default"){this.type=e;this.message=t;this.title=s;this.duration=3e3;this.element=$(this.cardHtml)[0];this.$element=$(this.element);$(".toast-card-container").append(this.$element)}show(){this.element.classList.add("visible");this.$element.find(".toast-card-dismiss").on("click",()=>this.dismiss());if(this.duration){setTimeout(()=>this.dismiss(),this.duration)}}dismiss(){if(this.element.classList.contains("visible")){this.$element.on("transitionend",()=>this.$element.remove());this.element.classList.remove("visible")}}get cardHtml(){return`\n \n \n ${this.title}\n \n \n \n \n ${this.message}\n \n `}static get container(){return $(".toast-card-container")}static createToastContainer(){if($(".toast-card-container").length===0){$("body").append(``)}}static internalShow(t,s,i,n){const a=new e(t,s,n);a.duration=i;a.show();return a}static show(t,s,e){return this.internalShow(t,s,e,"default")}static info(t,s,e){return this.internalShow(t,s,e,"info")}static success(t,s,e){return this.internalShow(t,s,e,"success")}static error(t,s,e){return this.internalShow(t,s,e,"error")}}s.applyStyle("toastStyle");e.createToastContainer();return{export:e}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/remove-top-mask.min.js"] = (()=>{return(i,n)=>{const l="bilibili-video-top-mask";if($(`#${l}`).length===0){n.applyStyleFromText(`\n \n `)}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/blur-video-control.min.js"] = (()=>{return(r,e)=>{(Observer.childListSubtree||Observer.subtree)("#bofqi",()=>{SpinQuery.count(()=>$(".bui-slider .bui-track.bui-track-video-progress,.bilibili-player-video-control-bottom"),2,r=>{if(!r.hasClass("video-control-blur-container")){r.addClass("video-control-blur-container");r.prepend(``)}})});e.applyStyle("blurVideoControlStyle")}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/blur-video-control.min.js"] = (()=>{return(r,i)=>{Observer.childListSubtree("#bofqi",()=>{SpinQuery.count(()=>$(".bui-slider .bui-track.bui-track-video-progress,.bilibili-player-video-control-bottom"),2,r=>{if(!r.hasClass("video-control-blur-container")){r.addClass("video-control-blur-container");r.prepend(``)}})});i.applyStyle("blurVideoControlStyle")}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/dark-schedule.min.js"] = (()=>{return(e,t)=>{class s{constructor(...e){if(e.length===0){const e=new Date;this.hour=e.getHours();this.minute=e.getMinutes()}else if(e.length===1){const[t]=e;[this.hour,this.minute]=t.split(":").slice(0,2).map(e=>this.validatePart(e));this.normalize()}else if(v.length===2){[this.hour,this.minute]=e}}validatePart(e){const t=parseInt(e);if(!isNaN(t)&&0<=t&&t<=59){return t}else{return null}}normalize(){while(this.minute<0){this.minute+=60;this.hour-=1}while(this.minute>=60){this.minute-=60;this.hour+=1}while(this.hour<0){this.hour+=24}while(this.hour>=24){this.hour-=24}}lessThan(e){if(this.houre.hour||this.hour===e.hour&&this.minute>e.minute){return true}return false}equals(e){return this.hour===e.hour&&this.minute===e.minute}isInRange(e,t){if(e.equals(t)){return false}let s=this.greaterThan(e)&&this.lessThan(t);if(e.greaterThan(t)){s=this.greaterThan(e)||this.lessThan(t)}const i=s||this.equals(e);return i}static millisecondsBefore(e){const t=new s;const i=(new Date).getSeconds();const r=1e3*(t.hour*3600+t.minute*60+i);const n=1e3*(e.hour*3600+e.minute*60);let h=n-r;if(t.greaterThan(e)||t.equals(e)&&i!==0){h+=24*3600*1e3}return h}}function i(){if(e.darkSchedule){const t=new s(e.darkScheduleStart);const r=new s(e.darkScheduleEnd);const n=new s;const h=n.isInRange(t,r);if(e.useDarkStyle!==h){e.useDarkStyle=h;saveSettings(e)}let u=0;if(h){u=s.millisecondsBefore(r)}else{u=s.millisecondsBefore(t)}if(u!==0){setTimeout(()=>i(),u)}}}i();return{export:s}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/clear-cache.min.js"] = (()=>{return(n,c)=>{return{widget:{content:`\n \n \n 清除缓存\n `,condition:()=>typeof offlineData==="undefined",success:()=>{$("#clear-cache").on("click",()=>{n.cache={};saveSettings(n);Toast.success("已删除全部缓存.","清除缓存",5e3)})}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.js"] = (()=>{return(e,t)=>{const s={entity:null,aid:undefined,cid:undefined,isOldBangumi:false,isStardustBangumi:false};const n=[];class i{constructor(){this.menuPanel=document.querySelector(".download-video-panel");this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}addMenuClass(){this.menuPanel.classList.remove(...this.menuClasses);this.menuPanel.classList.add(this.currentMenuClass);return this.currentMenuClass}resetMenuClass(){[this.currentMenuClass]=this.menuClasses;this.addMenuClass()}nextMenuClass(){const e=this.menuClasses.indexOf(this.currentMenuClass)+1;const t=this.menuClasses[e>=this.menuClasses.length?0:e];this.currentMenuClass=t;this.addMenuClass();return t}addError(){this.menuPanel.classList.add("error")}removeError(){this.menuPanel.classList.remove("error");this.resetMenuClass()}async getUrl(e){if(e){return`https://api.bilibili.com/x/player/playurl?avid=${s.aid}&cid=${s.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${s.aid}&cid=${s.cid}&otype=json`}}}class o extends i{constructor(){super();this.menuClasses=["action","progress"];this.currentMenuClass="action"}async getUrl(){const e=await SpinQuery.select(()=>n[0]).catch(()=>logError("获取番剧下载链接失败."));return e}}class a extends i{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${s.aid}&cid=${s.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${s.aid}&cid=${s.cid}&qn=&otype=json`}}}class r{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new c(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{s.entity.getUrl().then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText);if(s.code!==0){t("获取清晰度信息失败.")}const i=s.data||s.result||s;const o=i.accept_quality;const a=i.accept_format.split(",");const l=i.accept_description;const c=[];while(o.length>0){const e=new r(o.pop(),a.pop(),l.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class l{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class c{constructor(e,t){this.format=e;this.fragments=t||[];this.progress=null;this.loaded=0;this.totalSize=null;this.workingXhr=null;this.fragmentSplitFactor=6*5}fetchVideoInfo(){return new Promise((e,t)=>{s.entity.getUrl(this.format.quality).then(n=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{const n=JSON.parse(i.responseText.replace(/http:/g,"https:"));const o=n.data||n.result||n;if(!s.isOldBangumi&&o.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const a=o.durl;this.fragments=a.map(e=>new l(e.length,e.size,e.url,e.backup_url));e(this.fragments)});i.withCredentials=true;i.open("GET",n);i.send()})})}cancelDownload(){if("forEach"in this.workingXhr){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];const s=Math.round(e.size/this.fragmentSplitFactor);let n=0;while(n{let n=0;const o=new XMLHttpRequest;o.open("GET",e.url);o.responseType="arraybuffer";o.withCredentials=false;o.addEventListener("progress",e=>{this.loaded+=e.loaded-n;n=e.loaded;this.progress&&this.progress(this.loaded/this.totalSize)});o.addEventListener("load",()=>{if((""+o.status)[0]==="2"){t(o.response)}else{s(`请求失败.`)}});o.addEventListener("abort",()=>s("下载已取消."));o.addEventListener("error",()=>s(`下载失败.`));o.setRequestHeader("Range",i);o.send();this.workingXhr.push(o)}));n=Math.round(n+s)+1}return Promise.all(t)}copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t=null){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=$("a#video-complete").attr("href");if(e&&$(`.link[href=${e}]`).length===0){URL.revokeObjectURL(e)}}downloadSingle(e){const[t]=e;const s=this.makeBlob(t);const n=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","")+this.extension();return[s,n]}async downloadMultiple(e){const t=new JSZip;const s=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","");if(e.length>1){e.forEach((e,n)=>{const i=this.fragments[n];t.file(`${s} - ${n+1}${this.extension(i)}`,this.makeBlob(e,i))})}else{const[n]=e;t.file(`${s}${this.extension()}`,this.makeBlob(n))}const n=await t.generateAsync({type:"blob"});const i=s+".zip";return[n,i]}async download(){const e=[];this.loaded=0;this.totalSize=this.fragments.map(e=>e.size).reduce((e,t)=>e+t);for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let t=null;let s=null;if(e.length===1){[t,s]=this.downloadSingle(e)}else{[t,s]=await this.downloadMultiple(e)}const n=URL.createObjectURL(t);this.cleanUpOldBlobUrl();this.progress&&this.progress(0);return{url:n,filename:s}}}async function d(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);s.aid=e;s.cid=t;if(document.URL.indexOf("bangumi")!==-1){const e=await SpinQuery.select(()=>document.querySelector("#bofqi"));if(!e.classList.contains("stardust-player")){s.isOldBangumi=true;s.entity=new o;await SpinQuery.unsafeJquery();unsafeWindow.$(unsafeWindow.document).ajaxSend((e,t,s)=>{if(s.url.indexOf("https://bangumi.bilibili.com/player/web_api/v2/playurl")!==-1){n.unshift(s.url)}})}else{s.isStardustBangumi=true;s.entity=new a}}else{s.entity=new i}return e!==undefined&&t!==undefined}async function u(){await d();const e=await r.availableFormats;let[n]=e;const i=()=>n.downloadInfo().catch(e=>{s.entity.addError();$(".video-error").text(e)});async function o(){if(!n){return}s.entity.nextMenuClass();const e=await i();e.progress=(e=>{$(".download-progress-value").text(`${fixed(e*100)}`);$(".download-progress-foreground").css("transform",`scaleX(${e})`)});document.querySelector(".download-progress-cancel>span").onclick=(()=>e.cancelDownload());const t=await e.download().catch(e=>{s.entity.addError();$(".video-error").text(e)});if(!t){return}const o=document.getElementById("video-complete");o.setAttribute("href",t.url);o.setAttribute("download",t.filename);o.click();const a=`下载完成. 再次保存`;Toast.success(a,"下载视频");s.entity.resetMenuClass()}async function a(){if(!n){return}const e=await i();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);s.entity.resetMenuClass()}$(".video-action>#video-action-download").on("click",o);$(".video-action>#video-action-copy").on("click",a);e.forEach(e=>{$(`${e.displayName}`).on("click",()=>{n=e;s.entity.nextMenuClass()}).prependTo("ol.video-quality")});t.applyStyle("downloadVideoStyle");const l=document.querySelector(".download-video-panel");const c=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!l.contains(e.target)){c()}});$(".video-error").on("click",()=>{$(".video-error").text("");s.entity.removeError()});s.entity.addMenuClass()}return{widget:{content:t.data.downloadVideoDom.text,condition:d,success:u}}}})(); @@ -1204,10 +1204,10 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/about.min.js"] = (()=>{return(e,i)=>{$("body").append(i.data.aboutDom.text);const n=GM_info.script.name.replace("Bilibili Evolved","").replace(/^[\(\) ]+|[\(\) ]+$/g,"")+" · "+e.currentVersion;$(".bilibili-evolved-version").text(n);const o=[{name:"jQuery",homepage:"https://jquery.com/",license:"MIT",version:"3.2.1"},{name:"JSZip",homepage:"https://stuk.github.io/jszip/",license:"MIT",version:"3.1.5"}];o.forEach(e=>{$(".open-source-components").append(`\n \n \n ${e.name}\n ${e.version} · ${e.license}\n \n \n `)});function t(){$("#about-close").on("click",()=>{$(".bilibili-evolved-about").toggleClass("opened")});$(".gui-settings").on("click",e=>{if(e.shiftKey===true){$(".bilibili-evolved-about").toggleClass("opened")}})}return{widget:{success:t}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/custom-control-background.min.css"] = `.bilibili-player-video-control-mask{background:0 0!important}.bilibili-player-video-control-bottom,.bui-slider .bui-track.bui-track-video-progress .bui-bar-wrap{background:rgba(0,0,0,var(--custom-control-background-opacity))!important}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/custom-control-background.min.js"] = (()=>{return(o,t)=>{if(o.customControlBackgroundOpacity>0){t.applyStyle("customControlBackgroundStyle");if(!o.touchVideoPlayer){t.applyImportantStyleFromText(`\n\n `)}}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-player-mode.min.js"] = (()=>{return(e,i)=>{const n=[{name:"常规",action:()=>{}},{name:"宽屏",action:()=>{$(".bilibili-player-video-btn-widescreen").click()}},{name:"网页全屏",action:()=>{$(".bilibili-player-video-web-fullscreen").click()}}];let t=()=>{};async function l(){if(e.autoLightOff){await SpinQuery.unsafeJquery();const e=await SpinQuery.any(()=>unsafeWindow.$(".bilibili-player-video-btn-setting"));e.mouseover().mouseout();t=(()=>{SpinQuery.any(()=>$(".bilibili-player-video-btn-setting-panel-others-content-lightoff .bui-checkbox-input"),e=>{const i=e[0];i.checked=true;raiseEvent(i,"change")})})}}async function a(){await l();await SpinQuery.condition(()=>$(".bilibili-player-video,.bilibili-player-video-btn-start,.bilibili-player-area"),e=>e.length===3&&$("video").length>0&&$("video").prop("duration"));const i=document.querySelector("video");if(i.length===0){return}const a=n.find(i=>i.name===e.defaultPlayerMode);if(a.name==="全屏"){const e=await SpinQuery.unsafeJquery();const i=document.querySelector(".bilibili-player-video-btn-start");const n=()=>{const t=e(".bilibili-player-video-btn-fullscreen").data("events");if(t.click&&t.click[0]&&t.click[0].handler){const i=e(".bilibili-player-video-btn-fullscreen").data("events").click[0].handler;console.log(i);i()}i.removeEventListener("click",n)};i.addEventListener("click",n)}else{const n=()=>{if(a&&$("#bilibiliPlayer[class*=mode-]").length===0){a.action()}t();if(e.applyPlayerModeOnPlay){i.removeEventListener("play",n)}};if(e.applyPlayerModeOnPlay){i.addEventListener("play",n)}else{n()}}}(Observer.childList||Observer.subtree)("#bofqi",()=>a())}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-video-quality.min.js"] = (()=>{return(e,a)=>{const t=[{name:"1080P60",value:116},{name:"1080P+",value:112},{name:"1080P",value:80},{name:"720P60",value:74},{name:"720P",value:64},{name:"480P",value:32},{name:"360P",value:15},{name:"自动",value:0}];async function i(){const a=await SpinQuery.any(()=>$(".bilibili-player-video-quality-menu .bui-select-list>li.bui-select-item"));const i=(e,a)=>a-e;const[n]=a.toArray().map(e=>parseInt(e.getAttribute("data-value"))).sort(i);const[l]=t.filter(a=>a.name===e.defaultVideoQuality).map(e=>e.value).sort(i);const[o]=t.map(e=>e.value).filter(e=>e<=Math.min(l,n)).sort(i);console.info(`[Video Quality] availableHighestQualities=${n}`);console.info(`[Video Quality] targetQuality=${l}`);console.info(`[Video Quality] finalQuality=${o}`);const u=await SpinQuery.condition(()=>document.querySelector("video"),e=>e);function s(){a.each((e,a)=>{if(parseInt(a.getAttribute("data-value"))===o){a.click()}});this.removeEventListener("play",s)}u.addEventListener("play",s)}(Observer.childList||Observer.subtree)("#bofqi",()=>i())}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-player-mode.min.js"] = (()=>{return(e,i)=>{const n=[{name:"常规",action:()=>{}},{name:"宽屏",action:()=>{$(".bilibili-player-video-btn-widescreen").click()}},{name:"网页全屏",action:()=>{$(".bilibili-player-video-web-fullscreen").click()}}];let t=()=>{};async function l(){if(e.autoLightOff){await SpinQuery.unsafeJquery();const e=await SpinQuery.any(()=>unsafeWindow.$(".bilibili-player-video-btn-setting"));e.mouseover().mouseout();t=(()=>{SpinQuery.any(()=>$(".bilibili-player-video-btn-setting-panel-others-content-lightoff .bui-checkbox-input"),e=>{const i=e[0];i.checked=true;raiseEvent(i,"change")})})}}async function a(){await l();await SpinQuery.condition(()=>$(".bilibili-player-video,.bilibili-player-video-btn-start,.bilibili-player-area"),e=>e.length===3&&$("video").length>0&&$("video").prop("duration"));const i=document.querySelector("video");if(i.length===0){return}const a=n.find(i=>i.name===e.defaultPlayerMode);if(a.name==="全屏"){const e=await SpinQuery.unsafeJquery();const i=document.querySelector(".bilibili-player-video-btn-start");const n=()=>{const t=e(".bilibili-player-video-btn-fullscreen").data("events");if(t.click&&t.click[0]&&t.click[0].handler){const i=e(".bilibili-player-video-btn-fullscreen").data("events").click[0].handler;console.log(i);i()}i.removeEventListener("click",n)};i.addEventListener("click",n)}else{const n=()=>{if(a&&$("#bilibiliPlayer[class*=mode-]").length===0){a.action()}t();if(e.applyPlayerModeOnPlay){i.removeEventListener("play",n)}};if(e.applyPlayerModeOnPlay){i.addEventListener("play",n)}else{n()}}}Observer.childListSubtree("#bofqi",()=>a())}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-video-quality.min.js"] = (()=>{return(e,a)=>{const t=[{name:"1080P60",value:116},{name:"1080P+",value:112},{name:"1080P",value:80},{name:"720P60",value:74},{name:"720P",value:64},{name:"480P",value:32},{name:"360P",value:15},{name:"自动",value:0}];async function i(){const a=await SpinQuery.any(()=>$(".bilibili-player-video-quality-menu .bui-select-list>li.bui-select-item"));const i=(e,a)=>a-e;const[n]=a.toArray().map(e=>parseInt(e.getAttribute("data-value"))).sort(i);const[l]=t.filter(a=>a.name===e.defaultVideoQuality).map(e=>e.value).sort(i);const[o]=t.map(e=>e.value).filter(e=>e<=Math.min(l,n)).sort(i);console.info(`[Video Quality] availableHighestQualities=${n}`);console.info(`[Video Quality] targetQuality=${l}`);console.info(`[Video Quality] finalQuality=${o}`);const u=await SpinQuery.condition(()=>document.querySelector("video"),e=>e);function s(){a.each((e,a)=>{if(parseInt(a.getAttribute("data-value"))===o){a.click()}});this.removeEventListener("play",s)}u.addEventListener("play",s)}Observer.childListSubtree("#bofqi",()=>i())}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/combo-like.min.js"] = (()=>{return(e,t)=>{(async()=>{const e=await SpinQuery.select(()=>document.querySelector(".ops span.like"));e.style.userSelect="none";function t(t,n){const s=new CustomEvent(t,n);e.dispatchEvent(s)}const n=200;let s=true;e.addEventListener("touchstart",e=>{e.preventDefault();s=true;setTimeout(()=>s=false,n);t("mousedown",e)});e.addEventListener("touchend",e=>{e.preventDefault();t("mouseup",e);if(s===true){t("click",e)}})})()}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/auto-continue.min.js"] = (()=>{return(e,t)=>{function i(e){const t=/((\d)*:)?(\d)*:(\d)*/g;const i=e.text();const n=i.match(t);if(!n){return}const r=n[0].split(":");const o=(()=>{if(r.length===3){const[e,t,i]=r.map(e=>parseInt(e));return e*60*60+t*60+i}else if(r.length===2){const[e,t]=r.map(e=>parseInt(e));return e*60+t}else{logError(`解析历史时间发生错误: historyTime=${JSON.stringify(r)}`);return NaN}})();const s=e.parent();const l=document.querySelector("video");if(o从头开始`);t.appendTo(s).on("click",()=>l.currentTime=0);e.html(`已跳转到上次历史记录${n[0]}`)}else{s.find(".bilibili-player-video-toast-item-close").get(0).click()}}function n(){SpinQuery.condition(()=>$(".bilibili-player-video-toast-item-text"),e=>e.text().indexOf("上次看到")!==-1,e=>i(e.filter((e,t)=>t.innerText.indexOf("上次看到")!==-1)))}(Observer.childList||Observer.subtree)("#bofqi",n)}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/auto-continue.min.js"] = (()=>{return(e,t)=>{function i(e){const t=/((\d)*:)?(\d)*:(\d)*/g;const i=e.text();const n=i.match(t);if(!n){return}const r=n[0].split(":");const o=(()=>{if(r.length===3){const[e,t,i]=r.map(e=>parseInt(e));return e*60*60+t*60+i}else if(r.length===2){const[e,t]=r.map(e=>parseInt(e));return e*60+t}else{logError(`解析历史时间发生错误: historyTime=${JSON.stringify(r)}`);return NaN}})();const s=e.parent();const l=document.querySelector("video");if(o从头开始`);t.appendTo(s).on("click",()=>l.currentTime=0);e.html(`已跳转到上次历史记录${n[0]}`)}else{s.find(".bilibili-player-video-toast-item-close").get(0).click()}}function n(){SpinQuery.condition(()=>$(".bilibili-player-video-toast-item-text"),e=>e.text().indexOf("上次看到")!==-1,e=>i(e.filter((e,t)=>t.innerText.indexOf("上次看到")!==-1)))}Observer.childListSubtree("#bofqi",n)}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-description.min.css"] = `.video-desc .info{height:auto!important}.video-desc .btn{display:none!important}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-description.min.js"] = (()=>{return(e,p)=>{p.applyStyle("expandDescriptionStyle")}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-danmaku-settings.min.js"] = (()=>{return(e,n)=>{async function t(e,n){const t=await SpinQuery.select(()=>document.querySelector(e));if(!t){return}t.checked=n;raiseEvent(t,"change")}const i={enableDanmaku:".bilibili-player-video-danmaku-switch>input",settingsIcon:".bilibili-player-video-danmaku-setting"};if(!e.enableDanmaku){t(i.enableDanmaku,false)}if(e.rememberDanmakuBlock){for(const n in e.danmakuBlockSettings){i[n]=`.bilibili-player-block-filter-type[ftype=${n}]`}async function a(){await SpinQuery.unsafeJquery();const n=await SpinQuery.any(()=>unsafeWindow.$(i.settingsIcon));n.mouseover().mouseout();for(const[n,t]of Object.entries(e.danmakuBlockSettings)){if(t===true){const e=await SpinQuery.select(()=>document.querySelector(i[n]));e.click()}}}async function c(){for(const n in e.danmakuBlockSettings){const t=await SpinQuery.select(()=>document.querySelector(i[n]));t.addEventListener("click",()=>{e.danmakuBlockSettings[n]=t.classList.contains("disabled");saveSettings(e)})}}a();c()}}})(); diff --git a/min/auto-continue.min.js b/min/auto-continue.min.js index 435819f10..59e5f1f4e 100644 --- a/min/auto-continue.min.js +++ b/min/auto-continue.min.js @@ -1 +1 @@ -(()=>{return(e,t)=>{function i(e){const t=/((\d)*:)?(\d)*:(\d)*/g;const i=e.text();const n=i.match(t);if(!n){return}const r=n[0].split(":");const o=(()=>{if(r.length===3){const[e,t,i]=r.map(e=>parseInt(e));return e*60*60+t*60+i}else if(r.length===2){const[e,t]=r.map(e=>parseInt(e));return e*60+t}else{logError(`解析历史时间发生错误: historyTime=${JSON.stringify(r)}`);return NaN}})();const s=e.parent();const l=document.querySelector("video");if(o从头开始`);t.appendTo(s).on("click",()=>l.currentTime=0);e.html(`已跳转到上次历史记录${n[0]}`)}else{s.find(".bilibili-player-video-toast-item-close").get(0).click()}}function n(){SpinQuery.condition(()=>$(".bilibili-player-video-toast-item-text"),e=>e.text().indexOf("上次看到")!==-1,e=>i(e.filter((e,t)=>t.innerText.indexOf("上次看到")!==-1)))}(Observer.childList||Observer.subtree)("#bofqi",n)}})(); \ No newline at end of file +(()=>{return(e,t)=>{function i(e){const t=/((\d)*:)?(\d)*:(\d)*/g;const i=e.text();const n=i.match(t);if(!n){return}const r=n[0].split(":");const o=(()=>{if(r.length===3){const[e,t,i]=r.map(e=>parseInt(e));return e*60*60+t*60+i}else if(r.length===2){const[e,t]=r.map(e=>parseInt(e));return e*60+t}else{logError(`解析历史时间发生错误: historyTime=${JSON.stringify(r)}`);return NaN}})();const s=e.parent();const l=document.querySelector("video");if(o从头开始`);t.appendTo(s).on("click",()=>l.currentTime=0);e.html(`已跳转到上次历史记录${n[0]}`)}else{s.find(".bilibili-player-video-toast-item-close").get(0).click()}}function n(){SpinQuery.condition(()=>$(".bilibili-player-video-toast-item-text"),e=>e.text().indexOf("上次看到")!==-1,e=>i(e.filter((e,t)=>t.innerText.indexOf("上次看到")!==-1)))}Observer.childListSubtree("#bofqi",n)}})(); \ No newline at end of file diff --git a/min/blur-video-control.min.js b/min/blur-video-control.min.js index 6d06d586c..4cb116672 100644 --- a/min/blur-video-control.min.js +++ b/min/blur-video-control.min.js @@ -1 +1 @@ -(()=>{return(r,e)=>{(Observer.childListSubtree||Observer.subtree)("#bofqi",()=>{SpinQuery.count(()=>$(".bui-slider .bui-track.bui-track-video-progress,.bilibili-player-video-control-bottom"),2,r=>{if(!r.hasClass("video-control-blur-container")){r.addClass("video-control-blur-container");r.prepend(``)}})});e.applyStyle("blurVideoControlStyle")}})(); \ No newline at end of file +(()=>{return(r,i)=>{Observer.childListSubtree("#bofqi",()=>{SpinQuery.count(()=>$(".bui-slider .bui-track.bui-track-video-progress,.bilibili-player-video-control-bottom"),2,r=>{if(!r.hasClass("video-control-blur-container")){r.addClass("video-control-blur-container");r.prepend(``)}})});i.applyStyle("blurVideoControlStyle")}})(); \ No newline at end of file diff --git a/min/default-player-mode.min.js b/min/default-player-mode.min.js index 92cd9cf83..37a98c4e3 100644 --- a/min/default-player-mode.min.js +++ b/min/default-player-mode.min.js @@ -1 +1 @@ -(()=>{return(e,i)=>{const n=[{name:"常规",action:()=>{}},{name:"宽屏",action:()=>{$(".bilibili-player-video-btn-widescreen").click()}},{name:"网页全屏",action:()=>{$(".bilibili-player-video-web-fullscreen").click()}}];let t=()=>{};async function l(){if(e.autoLightOff){await SpinQuery.unsafeJquery();const e=await SpinQuery.any(()=>unsafeWindow.$(".bilibili-player-video-btn-setting"));e.mouseover().mouseout();t=(()=>{SpinQuery.any(()=>$(".bilibili-player-video-btn-setting-panel-others-content-lightoff .bui-checkbox-input"),e=>{const i=e[0];i.checked=true;raiseEvent(i,"change")})})}}async function a(){await l();await SpinQuery.condition(()=>$(".bilibili-player-video,.bilibili-player-video-btn-start,.bilibili-player-area"),e=>e.length===3&&$("video").length>0&&$("video").prop("duration"));const i=document.querySelector("video");if(i.length===0){return}const a=n.find(i=>i.name===e.defaultPlayerMode);if(a.name==="全屏"){const e=await SpinQuery.unsafeJquery();const i=document.querySelector(".bilibili-player-video-btn-start");const n=()=>{const t=e(".bilibili-player-video-btn-fullscreen").data("events");if(t.click&&t.click[0]&&t.click[0].handler){const i=e(".bilibili-player-video-btn-fullscreen").data("events").click[0].handler;console.log(i);i()}i.removeEventListener("click",n)};i.addEventListener("click",n)}else{const n=()=>{if(a&&$("#bilibiliPlayer[class*=mode-]").length===0){a.action()}t();if(e.applyPlayerModeOnPlay){i.removeEventListener("play",n)}};if(e.applyPlayerModeOnPlay){i.addEventListener("play",n)}else{n()}}}(Observer.childList||Observer.subtree)("#bofqi",()=>a())}})(); \ No newline at end of file +(()=>{return(e,i)=>{const n=[{name:"常规",action:()=>{}},{name:"宽屏",action:()=>{$(".bilibili-player-video-btn-widescreen").click()}},{name:"网页全屏",action:()=>{$(".bilibili-player-video-web-fullscreen").click()}}];let t=()=>{};async function l(){if(e.autoLightOff){await SpinQuery.unsafeJquery();const e=await SpinQuery.any(()=>unsafeWindow.$(".bilibili-player-video-btn-setting"));e.mouseover().mouseout();t=(()=>{SpinQuery.any(()=>$(".bilibili-player-video-btn-setting-panel-others-content-lightoff .bui-checkbox-input"),e=>{const i=e[0];i.checked=true;raiseEvent(i,"change")})})}}async function a(){await l();await SpinQuery.condition(()=>$(".bilibili-player-video,.bilibili-player-video-btn-start,.bilibili-player-area"),e=>e.length===3&&$("video").length>0&&$("video").prop("duration"));const i=document.querySelector("video");if(i.length===0){return}const a=n.find(i=>i.name===e.defaultPlayerMode);if(a.name==="全屏"){const e=await SpinQuery.unsafeJquery();const i=document.querySelector(".bilibili-player-video-btn-start");const n=()=>{const t=e(".bilibili-player-video-btn-fullscreen").data("events");if(t.click&&t.click[0]&&t.click[0].handler){const i=e(".bilibili-player-video-btn-fullscreen").data("events").click[0].handler;console.log(i);i()}i.removeEventListener("click",n)};i.addEventListener("click",n)}else{const n=()=>{if(a&&$("#bilibiliPlayer[class*=mode-]").length===0){a.action()}t();if(e.applyPlayerModeOnPlay){i.removeEventListener("play",n)}};if(e.applyPlayerModeOnPlay){i.addEventListener("play",n)}else{n()}}}Observer.childListSubtree("#bofqi",()=>a())}})(); \ No newline at end of file diff --git a/min/default-video-quality.min.js b/min/default-video-quality.min.js index 46350c943..950e0f5ec 100644 --- a/min/default-video-quality.min.js +++ b/min/default-video-quality.min.js @@ -1 +1 @@ -(()=>{return(e,a)=>{const t=[{name:"1080P60",value:116},{name:"1080P+",value:112},{name:"1080P",value:80},{name:"720P60",value:74},{name:"720P",value:64},{name:"480P",value:32},{name:"360P",value:15},{name:"自动",value:0}];async function i(){const a=await SpinQuery.any(()=>$(".bilibili-player-video-quality-menu .bui-select-list>li.bui-select-item"));const i=(e,a)=>a-e;const[n]=a.toArray().map(e=>parseInt(e.getAttribute("data-value"))).sort(i);const[l]=t.filter(a=>a.name===e.defaultVideoQuality).map(e=>e.value).sort(i);const[o]=t.map(e=>e.value).filter(e=>e<=Math.min(l,n)).sort(i);console.info(`[Video Quality] availableHighestQualities=${n}`);console.info(`[Video Quality] targetQuality=${l}`);console.info(`[Video Quality] finalQuality=${o}`);const u=await SpinQuery.condition(()=>document.querySelector("video"),e=>e);function s(){a.each((e,a)=>{if(parseInt(a.getAttribute("data-value"))===o){a.click()}});this.removeEventListener("play",s)}u.addEventListener("play",s)}(Observer.childList||Observer.subtree)("#bofqi",()=>i())}})(); \ No newline at end of file +(()=>{return(e,a)=>{const t=[{name:"1080P60",value:116},{name:"1080P+",value:112},{name:"1080P",value:80},{name:"720P60",value:74},{name:"720P",value:64},{name:"480P",value:32},{name:"360P",value:15},{name:"自动",value:0}];async function i(){const a=await SpinQuery.any(()=>$(".bilibili-player-video-quality-menu .bui-select-list>li.bui-select-item"));const i=(e,a)=>a-e;const[n]=a.toArray().map(e=>parseInt(e.getAttribute("data-value"))).sort(i);const[l]=t.filter(a=>a.name===e.defaultVideoQuality).map(e=>e.value).sort(i);const[o]=t.map(e=>e.value).filter(e=>e<=Math.min(l,n)).sort(i);console.info(`[Video Quality] availableHighestQualities=${n}`);console.info(`[Video Quality] targetQuality=${l}`);console.info(`[Video Quality] finalQuality=${o}`);const u=await SpinQuery.condition(()=>document.querySelector("video"),e=>e);function s(){a.each((e,a)=>{if(parseInt(a.getAttribute("data-value"))===o){a.click()}});this.removeEventListener("play",s)}u.addEventListener("play",s)}Observer.childListSubtree("#bofqi",()=>i())}})(); \ No newline at end of file diff --git a/min/expand-danmaku.min.js b/min/expand-danmaku.min.js index 660558d6a..a935eab90 100644 --- a/min/expand-danmaku.min.js +++ b/min/expand-danmaku.min.js @@ -1 +1 @@ -(()=>{return()=>{(Observer.childList||Observer.subtree)("#bofqi",()=>{SpinQuery.any(()=>$(".bui-collapse-header"),e=>{if(parseInt($(".bui-collapse-body").css("height"))===0&&$(".bui-collapse-arrow-text").text()==="展开"){e.click()}})})}})(); \ No newline at end of file +(()=>{return()=>{Observer.childListSubtree("#bofqi",()=>{SpinQuery.any(()=>$(".bui-collapse-header"),e=>{if(parseInt($(".bui-collapse-body").css("height"))===0&&$(".bui-collapse-arrow-text").text()==="展开"){e.click()}})})}})(); \ No newline at end of file diff --git a/min/touch-player.min.js b/min/touch-player.min.js index 332ff191b..bdf210672 100644 --- a/min/touch-player.min.js +++ b/min/touch-player.min.js @@ -1 +1 @@ -(()=>{return(t,i)=>{const e=t=>{let i=0;let e=0;while(t&&!isNaN(t.offsetLeft)&&!isNaN(t.offsetTop)){i+=t.offsetLeft-t.scrollLeft;e+=t.offsetTop-t.scrollTop;t=t.offsetParent}return{x:i,y:e}};const o=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let s=fixed(o)+"秒";if(e>0){s=e+"分"+s}if(i>0){s=i+"时"+s}return s};const s=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let s=(o<10?"0":"")+fixed(o);s=(e<10?"0":"")+e+":"+s;s=(i<10?"0":"")+i+":"+s;return s};class n{constructor(t){this.action=new l(t);this.onTouchStart=null;this.onTouchEnd=null;this.direction=null;t.addEventListener("touchstart",t=>{this.xDown=t.touches[0].clientX;this.yDown=t.touches[0].clientY;if(this.onTouchStart){this.onTouchStart(t)}});t.addEventListener("touchmove",i=>{if(!this.xDown||!this.yDown){return}const o=i.touches[0].clientX;const s=i.touches[0].clientY;const n=e(t);const l={x:(i.touches[0].pageX-n.x)/t.clientWidth,y:(i.touches[0].pageY-n.y)/t.clientHeight,width:t.clientWidth,height:t.clientHeight};const a=this.xDown-o;const c=this.yDown-s;if(!this.direction){let t="";if(Math.abs(a)>Math.abs(c)){t="horizontal"}else{t="vertical"}this.direction=t;i.preventDefault()}else{if(this.direction==="vertical"){this.action.startAction(this.direction,c,l)}else if(this.direction==="horizontal"){this.action.startAction(this.direction,-a,l)}i.preventDefault()}});t.addEventListener("touchend",t=>{this.xDown=null;this.yDown=null;this.direction=null;if(this.onTouchEnd){this.onTouchEnd(t)}})}}class l{constructor(t){this.lowSpeedForward=null;this.lowSpeedBackward=null;this.mediumSpeedForward=null;this.mediumSpeedBackward=null;this.highSpeedForward=null;this.highSpeedBackward=null;this.lowVolumeUp=null;this.lowVolumeDown=null;this.mediumVolumeUp=null;this.mediumVolumeDown=null;this.highVolumeUp=null;this.highVolumeDown=null;this.speedCancel=null;this.volumeCancel=null;this.minSwipeDistance=20;this.onActionStart=null;this.onActionEnd=null;this.element=t;this.touchStart=false;this.startPosition=null;this.lastAction=null;t.addEventListener("touchstart",t=>{this.touchStart=true});t.addEventListener("touchend",t=>{this.startPosition=null;this.onActionEnd&&this.onActionEnd(this.lastAction);this.lastAction=null})}startAction(t,i,e){if(this.touchStart){this.onActionStart&&this.onActionStart(t);this.startPosition=e;this.touchStart=false}if(t==="vertical"){if(Math.abs(i)=1/3&&this.startPosition.x<=2/3){t=1;o=this.mediumVolumeUp;s=this.mediumVolumeDown}else{t=2;o=this.highVolumeUp;s=this.highVolumeDown}if(i>0){const s=Math.round(t*100*(i-this.minSwipeDistance)/(1.5*e.height));o&&o(s);this.lastAction={type:"volume",volume:s}}else{const o=Math.round(t*100*(i+this.minSwipeDistance)/(1.5*e.height));s&&s(o);this.lastAction={type:"volume",volume:o}}}}else if(t==="horizontal"){if(e.y<1/3&&(e.x<.1||e.x>.9)||Math.abs(i)=1/3&&this.startPosition.y<=2/3){t=.2;e=this.mediumSpeedForward;o=this.mediumSpeedBackward}else{t=1;e=this.highSpeedForward;o=this.highSpeedBackward}if(i>0){const o=(i-this.minSwipeDistance)*t;e&&e(o);this.lastAction={type:"playback",seconds:o}}else{const e=(i+this.minSwipeDistance)*t;o&&o(e);this.lastAction={type:"playback",seconds:e}}}}}}class a{constructor(){this.aid=unsafeWindow.aid;this.cid=unsafeWindow.cid;this.cidData=null;this.supportWebp=a.supportWebp}getVideoshot(t,i){if(!this.cidData){downloadText(`https://api.bilibili.com/x/player/videoshot?aid=${this.aid}&cid=${this.cid}&index=1`).then(e=>{this.cidData=JSON.parse(e).data;this.getVideoshot(t,i)})}else{const e=this.cidData;const o=e.index;let s=0;for(let i=0;i=o[i]&&tt.replace(".jpg",".jpg@.webp"))}const l=parseInt(e.pv_x_len)||10;const a=parseInt(e.pv_y_len)||10;const c=parseInt(e.pv_x_size)||160;const r=parseInt(e.pv_y_size)||90;const h=-(s%100%l)*c;const d=-Math.floor(s%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(s/100)]})`,backgroundPosition:`${h}px ${d}px`})}}static get supportWebp(){try{const t=document.createElement("canvas");if(t.getContext&&t.getContext("2d"))try{return t.toDataURL("image/webp").indexOf("data:image/webp")===0}catch(t){return false}else return false}catch(t){return false}}}function c(t){t.unbind("click")}function r(i){if($(".touch-video-box").length!==0){return}$(".bilibili-player-video-subtitle").before(`\n \n \n \n \n \n `);const e=$("video");const l=e.prop("duration");const c=new n(i.get(0));const r=document.getElementsByClassName("touch-video-info")[0];const h=document.getElementsByClassName("touch-video-box")[0];let d=Math.round(e.prop("volume")*100);const u=t=>{t/=100;if(t<0){t=0}else if(t>1){t=1}e.prop("volume",t);$(".bilibili-player-video-volume-num").text(Math.round(t*100));$(".bui-thumb").css("transform",`translateY(-${48*t}px)`);$(".bui-track-vertical .bui-bar").css("transform",`scaleY(${t})`);if(t===0){$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",true)}else if(t===1){$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-max");e.prop("muted",false)}else{$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",false)}};if(t.touchVideoPlayerAnimation){h.classList.add("animation")}c.action.onActionStart=(t=>{h.classList.add("adjust-opened");r.innerHTML="";d=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");let a=n+i;let c=fixed(100*a/l);let h=i;if(a>l){a=l;c=100;h=l-n}else if(a<0){a=0;c=0;h=n}const d=`${s(n)} →${s(a)} (${c}%)`;const u=`\n \n \n ${t}速\n \n \n 进度: ${i>0?"+":"-"}${o(h)}\n \n \n \n \n \n \n \n ${d}\n \n \n `;r.innerHTML=u;p.getVideoshot(a,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${c/100})`)}};c.action.lowSpeedBackward=m("低");c.action.lowSpeedForward=m("低");c.action.mediumSpeedBackward=m("中");c.action.mediumSpeedForward=m("中");c.action.highSpeedBackward=m("高");c.action.highSpeedForward=m("高");const v=t=>{return i=>{let e=d+i;let o=Math.abs(i);if(e>100){e=100;o=100-d}else if(e<0){e=0;o=d}const s=`${d} → ${e}`;u(e);const n=`\n \n \n ${t}速\n \n \n 音量: ${i>0?"+":"-"}${o}\n \n \n \n \n ${s}\n \n \n `;r.innerHTML=n;$(".touch-progress").css("transform",`scaleX(${e/100})`)}};c.action.lowVolumeUp=v("低");c.action.lowVolumeDown=v("低");c.action.mediumVolumeUp=v("中");c.action.mediumVolumeDown=v("中");c.action.highVolumeUp=v("高");c.action.highVolumeDown=v("高");c.action.speedCancel=(()=>{r.innerHTML=`松开手指,取消进退`;$(".touch-progress").css("transform","scaleX(0)")});c.action.volumeCancel=(()=>{r.innerHTML=`松开手指,取消调整`;$(".touch-progress").css("transform","scaleX(0)");u(d)});if(!unsafeWindow.TOUCH_PLAYER_DEBUG){c.action.onActionEnd=(t=>{r.innerHTML="";if(t){if(t.type==="playback"){let i=e.prop("currentTime");i+=t.seconds;if(i<0){i=0}else if(i>l){i=l}e.prop("currentTime",i)}}h.classList.remove("adjust-opened")})}}function h(t){if(!t.hasClass("disable-original-hover")){t.addClass("disable-original-hover");const i=unsafeWindow.$(".bilibili-player-video");const e="touch-video-control-show";const o=i.data("events").click[0].handler;const s=new DoubleClickEvent(t=>o(t),()=>t.toggleClass(e));i.unbind("click");s.bind(i[0])}}function d(){SpinQuery.any(()=>$(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),c);new SpinQuery(()=>$(".bilibili-player-video"),t=>t.length>0&&$("video").length>0&&$("video").prop("duration"),r).start();if(t.touchVideoPlayerDoubleTapControl){new SpinQuery(()=>$(".bilibili-player-area"),t=>t.length>0&&unsafeWindow.$&&unsafeWindow.$(".bilibili-player-video").data("events"),h).start()}}(Observer.childList||Observer.subtree)("#bofqi",()=>d());i.applyStyle("touchPlayerStyle")}})(); \ No newline at end of file +(()=>{return(t,i)=>{const e=t=>{let i=0;let e=0;while(t&&!isNaN(t.offsetLeft)&&!isNaN(t.offsetTop)){i+=t.offsetLeft-t.scrollLeft;e+=t.offsetTop-t.scrollTop;t=t.offsetParent}return{x:i,y:e}};const o=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let s=fixed(o)+"秒";if(e>0){s=e+"分"+s}if(i>0){s=i+"时"+s}return s};const s=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const o=t-i*3600-e*60;let s=(o<10?"0":"")+fixed(o);s=(e<10?"0":"")+e+":"+s;s=(i<10?"0":"")+i+":"+s;return s};class n{constructor(t){this.action=new l(t);this.onTouchStart=null;this.onTouchEnd=null;this.direction=null;t.addEventListener("touchstart",t=>{this.xDown=t.touches[0].clientX;this.yDown=t.touches[0].clientY;if(this.onTouchStart){this.onTouchStart(t)}});t.addEventListener("touchmove",i=>{if(!this.xDown||!this.yDown){return}const o=i.touches[0].clientX;const s=i.touches[0].clientY;const n=e(t);const l={x:(i.touches[0].pageX-n.x)/t.clientWidth,y:(i.touches[0].pageY-n.y)/t.clientHeight,width:t.clientWidth,height:t.clientHeight};const a=this.xDown-o;const c=this.yDown-s;if(!this.direction){let t="";if(Math.abs(a)>Math.abs(c)){t="horizontal"}else{t="vertical"}this.direction=t;i.preventDefault()}else{if(this.direction==="vertical"){this.action.startAction(this.direction,c,l)}else if(this.direction==="horizontal"){this.action.startAction(this.direction,-a,l)}i.preventDefault()}});t.addEventListener("touchend",t=>{this.xDown=null;this.yDown=null;this.direction=null;if(this.onTouchEnd){this.onTouchEnd(t)}})}}class l{constructor(t){this.lowSpeedForward=null;this.lowSpeedBackward=null;this.mediumSpeedForward=null;this.mediumSpeedBackward=null;this.highSpeedForward=null;this.highSpeedBackward=null;this.lowVolumeUp=null;this.lowVolumeDown=null;this.mediumVolumeUp=null;this.mediumVolumeDown=null;this.highVolumeUp=null;this.highVolumeDown=null;this.speedCancel=null;this.volumeCancel=null;this.minSwipeDistance=20;this.onActionStart=null;this.onActionEnd=null;this.element=t;this.touchStart=false;this.startPosition=null;this.lastAction=null;t.addEventListener("touchstart",t=>{this.touchStart=true});t.addEventListener("touchend",t=>{this.startPosition=null;this.onActionEnd&&this.onActionEnd(this.lastAction);this.lastAction=null})}startAction(t,i,e){if(this.touchStart){this.onActionStart&&this.onActionStart(t);this.startPosition=e;this.touchStart=false}if(t==="vertical"){if(Math.abs(i)=1/3&&this.startPosition.x<=2/3){t=1;o=this.mediumVolumeUp;s=this.mediumVolumeDown}else{t=2;o=this.highVolumeUp;s=this.highVolumeDown}if(i>0){const s=Math.round(t*100*(i-this.minSwipeDistance)/(1.5*e.height));o&&o(s);this.lastAction={type:"volume",volume:s}}else{const o=Math.round(t*100*(i+this.minSwipeDistance)/(1.5*e.height));s&&s(o);this.lastAction={type:"volume",volume:o}}}}else if(t==="horizontal"){if(e.y<1/3&&(e.x<.1||e.x>.9)||Math.abs(i)=1/3&&this.startPosition.y<=2/3){t=.2;e=this.mediumSpeedForward;o=this.mediumSpeedBackward}else{t=1;e=this.highSpeedForward;o=this.highSpeedBackward}if(i>0){const o=(i-this.minSwipeDistance)*t;e&&e(o);this.lastAction={type:"playback",seconds:o}}else{const e=(i+this.minSwipeDistance)*t;o&&o(e);this.lastAction={type:"playback",seconds:e}}}}}}class a{constructor(){this.aid=unsafeWindow.aid;this.cid=unsafeWindow.cid;this.cidData=null;this.supportWebp=a.supportWebp}getVideoshot(t,i){if(!this.cidData){downloadText(`https://api.bilibili.com/x/player/videoshot?aid=${this.aid}&cid=${this.cid}&index=1`).then(e=>{this.cidData=JSON.parse(e).data;this.getVideoshot(t,i)})}else{const e=this.cidData;const o=e.index;let s=0;for(let i=0;i=o[i]&&tt.replace(".jpg",".jpg@.webp"))}const l=parseInt(e.pv_x_len)||10;const a=parseInt(e.pv_y_len)||10;const c=parseInt(e.pv_x_size)||160;const r=parseInt(e.pv_y_size)||90;const h=-(s%100%l)*c;const d=-Math.floor(s%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(s/100)]})`,backgroundPosition:`${h}px ${d}px`})}}static get supportWebp(){try{const t=document.createElement("canvas");if(t.getContext&&t.getContext("2d"))try{return t.toDataURL("image/webp").indexOf("data:image/webp")===0}catch(t){return false}else return false}catch(t){return false}}}function c(t){t.unbind("click")}function r(i){if($(".touch-video-box").length!==0){return}$(".bilibili-player-video-subtitle").before(`\n \n \n \n \n \n `);const e=$("video");const l=e.prop("duration");const c=new n(i.get(0));const r=document.getElementsByClassName("touch-video-info")[0];const h=document.getElementsByClassName("touch-video-box")[0];let d=Math.round(e.prop("volume")*100);const u=t=>{t/=100;if(t<0){t=0}else if(t>1){t=1}e.prop("volume",t);$(".bilibili-player-video-volume-num").text(Math.round(t*100));$(".bui-thumb").css("transform",`translateY(-${48*t}px)`);$(".bui-track-vertical .bui-bar").css("transform",`scaleY(${t})`);if(t===0){$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",true)}else if(t===1){$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").addClass(".video-state-volume-max");e.prop("muted",false)}else{$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass(".video-state-volume-max");e.prop("muted",false)}};if(t.touchVideoPlayerAnimation){h.classList.add("animation")}c.action.onActionStart=(t=>{h.classList.add("adjust-opened");r.innerHTML="";d=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");let a=n+i;let c=fixed(100*a/l);let h=i;if(a>l){a=l;c=100;h=l-n}else if(a<0){a=0;c=0;h=n}const d=`${s(n)} →${s(a)} (${c}%)`;const u=`\n \n \n ${t}速\n \n \n 进度: ${i>0?"+":"-"}${o(h)}\n \n \n \n \n \n \n \n ${d}\n \n \n `;r.innerHTML=u;p.getVideoshot(a,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${c/100})`)}};c.action.lowSpeedBackward=m("低");c.action.lowSpeedForward=m("低");c.action.mediumSpeedBackward=m("中");c.action.mediumSpeedForward=m("中");c.action.highSpeedBackward=m("高");c.action.highSpeedForward=m("高");const v=t=>{return i=>{let e=d+i;let o=Math.abs(i);if(e>100){e=100;o=100-d}else if(e<0){e=0;o=d}const s=`${d} → ${e}`;u(e);const n=`\n \n \n ${t}速\n \n \n 音量: ${i>0?"+":"-"}${o}\n \n \n \n \n ${s}\n \n \n `;r.innerHTML=n;$(".touch-progress").css("transform",`scaleX(${e/100})`)}};c.action.lowVolumeUp=v("低");c.action.lowVolumeDown=v("低");c.action.mediumVolumeUp=v("中");c.action.mediumVolumeDown=v("中");c.action.highVolumeUp=v("高");c.action.highVolumeDown=v("高");c.action.speedCancel=(()=>{r.innerHTML=`松开手指,取消进退`;$(".touch-progress").css("transform","scaleX(0)")});c.action.volumeCancel=(()=>{r.innerHTML=`松开手指,取消调整`;$(".touch-progress").css("transform","scaleX(0)");u(d)});if(!unsafeWindow.TOUCH_PLAYER_DEBUG){c.action.onActionEnd=(t=>{r.innerHTML="";if(t){if(t.type==="playback"){let i=e.prop("currentTime");i+=t.seconds;if(i<0){i=0}else if(i>l){i=l}e.prop("currentTime",i)}}h.classList.remove("adjust-opened")})}}function h(t){if(!t.hasClass("disable-original-hover")){t.addClass("disable-original-hover");const i=unsafeWindow.$(".bilibili-player-video");const e="touch-video-control-show";const o=i.data("events").click[0].handler;const s=new DoubleClickEvent(t=>o(t),()=>t.toggleClass(e));i.unbind("click");s.bind(i[0])}}function d(){SpinQuery.any(()=>$(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),c);new SpinQuery(()=>$(".bilibili-player-video"),t=>t.length>0&&$("video").length>0&&$("video").prop("duration"),r).start();if(t.touchVideoPlayerDoubleTapControl){new SpinQuery(()=>$(".bilibili-player-area"),t=>t.length>0&&unsafeWindow.$&&unsafeWindow.$(".bilibili-player-video").data("events"),h).start()}}Observer.childListSubtree("#bofqi",()=>d());i.applyStyle("touchPlayerStyle")}})(); \ No newline at end of file diff --git a/min/view-cover.min.js b/min/view-cover.min.js index e437ec0a1..653d8b33c 100644 --- a/min/view-cover.min.js +++ b/min/view-cover.min.js @@ -1 +1 @@ -(()=>{return(e,t)=>{const n=t.attributes.videoInfo.export.VideoInfo;class i{constructor(e){this.url=e;if($(".image-viewer").length===0){this.createDom()}this.viewer=$(".image-viewer-container");this.downloadImage()}createDom(){$("body").append(t.data.imageViewerDom.text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","");const n=URL.createObjectURL(e.response);this.imageData=n;this.viewer.find(".download").attr("href",n).attr("download",t);this.viewer.find(".image").prop("src",n)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}if($("meta[itemprop='image'],meta[property='og:image']").length>0){return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.condition(()=>(unsafeWindow||window).aid,e=>e!==undefined);return e!=="undefined"},success:async()=>{async function e(){const e=(unsafeWindow||window).aid;const t=new n(e);await t.fetchInfo();return t.coverUrl}let t=new i(await e());$("#view-cover").on("click",()=>{t.show()});(Observer.childList||Observer.subtree)("#bofqi",async()=>{t=new i(await e())})}}}}else{return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.any(()=>$(".header-info-ctnr .room-cover"));return typeof e!=="undefined"},success:async()=>{const e=$(".header-info-ctnr .room-cover");const t=e.attr("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const n=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const o=await downloadText(n);const s=JSON.parse(o).data.cover;const a=new i(s);$("#view-cover").on("click",()=>{a.show()})}}}}}}})(); \ No newline at end of file +(()=>{return(e,t)=>{const n=t.attributes.videoInfo.export.VideoInfo;class i{constructor(e){this.url=e;if($(".image-viewer").length===0){this.createDom()}this.viewer=$(".image-viewer-container");this.downloadImage()}createDom(){$("body").append(t.data.imageViewerDom.text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","");const n=URL.createObjectURL(e.response);this.imageData=n;this.viewer.find(".download").attr("href",n).attr("download",t);this.viewer.find(".image").prop("src",n)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}if($("meta[itemprop='image'],meta[property='og:image']").length>0){return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.condition(()=>(unsafeWindow||window).aid,e=>e!==undefined);return e!=="undefined"},success:async()=>{async function e(){const e=(unsafeWindow||window).aid;const t=new n(e);await t.fetchInfo();return t.coverUrl}let t=new i(await e());$("#view-cover").on("click",()=>{t.show()});Observer.childListSubtree("#bofqi",async()=>{t=new i(await e())})}}}}else{return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.any(()=>$(".header-info-ctnr .room-cover"));return typeof e!=="undefined"},success:async()=>{const e=$(".header-info-ctnr .room-cover");const t=e.attr("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const n=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const o=await downloadText(n);const a=JSON.parse(o).data.cover;const s=new i(a);$("#view-cover").on("click",()=>{s.show()})}}}}}}})(); \ No newline at end of file diff --git a/style/blur-video-control/blur-video-control.js b/style/blur-video-control/blur-video-control.js index 06263fb89..1dacb4da5 100644 --- a/style/blur-video-control/blur-video-control.js +++ b/style/blur-video-control/blur-video-control.js @@ -2,7 +2,7 @@ { return (_, resources) => { - (Observer.childListSubtree || Observer.subtree)("#bofqi", () => + Observer.childListSubtree("#bofqi", () => { SpinQuery.count( () => $(".bui-slider .bui-track.bui-track-video-progress,.bilibili-player-video-control-bottom"), diff --git a/touch/player/touch-player.js b/touch/player/touch-player.js index 6be6280ab..f20e450aa 100644 --- a/touch/player/touch-player.js +++ b/touch/player/touch-player.js @@ -599,7 +599,7 @@ } } - (Observer.childList || Observer.subtree)("#bofqi", () => main()); + Observer.childListSubtree("#bofqi", () => main()); resources.applyStyle("touchPlayerStyle"); }; })(); diff --git a/video/auto-continue.js b/video/auto-continue.js index a6cf1a08f..12cbd7ec1 100644 --- a/video/auto-continue.js +++ b/video/auto-continue.js @@ -54,6 +54,6 @@ it => continuePlay(it.filter((_, e) => e.innerText.indexOf("上次看到") !== -1)), ); } - (Observer.childList || Observer.subtree)("#bofqi", findHistoryToast); + Observer.childListSubtree("#bofqi", findHistoryToast); }; })(); \ No newline at end of file diff --git a/video/default-player-mode.js b/video/default-player-mode.js index 6071652f3..17bf7d6b3 100644 --- a/video/default-player-mode.js +++ b/video/default-player-mode.js @@ -102,6 +102,6 @@ } } } - (Observer.childList || Observer.subtree)("#bofqi", () => main()); + Observer.childListSubtree("#bofqi", () => main()); }; })(); \ No newline at end of file diff --git a/video/default-video-quality.js b/video/default-video-quality.js index ff56c99e3..80afaef26 100644 --- a/video/default-video-quality.js +++ b/video/default-video-quality.js @@ -71,6 +71,6 @@ } video.addEventListener("play", onplay); } - (Observer.childList || Observer.subtree)("#bofqi", () => applyQuality()); + Observer.childListSubtree("#bofqi", () => applyQuality()); }; })(); \ No newline at end of file diff --git a/video/expand-danmaku.js b/video/expand-danmaku.js index 472902e1b..ab2fda63e 100644 --- a/video/expand-danmaku.js +++ b/video/expand-danmaku.js @@ -2,7 +2,7 @@ { return () => { - (Observer.childList || Observer.subtree)("#bofqi", () => + Observer.childListSubtree("#bofqi", () => { SpinQuery.any( () => $(".bui-collapse-header"), diff --git a/video/view-cover/view-cover.js b/video/view-cover/view-cover.js index a9ccb9f68..f716d2306 100644 --- a/video/view-cover/view-cover.js +++ b/video/view-cover/view-cover.js @@ -86,7 +86,7 @@ { imageViewer.show(); }); - (Observer.childList || Observer.subtree)("#bofqi", async () => + Observer.childListSubtree("#bofqi", async () => { imageViewer = new ImageViewer(await getUrl()); });
${this.message}