diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index e7adeee48..4bd8deca2 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Offline) -// @version 193.41 +// @version 193.85 // @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howrad (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -1205,22 +1205,22 @@ 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 d=-(s%100%l)*c;const h=-Math.floor(s%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(s/100)]})`,backgroundPosition:`${d}px ${h}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 d=document.getElementsByClassName("touch-video-box")[0];let h=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){d.classList.add("animation")}c.action.onActionStart=(t=>{d.classList.add("adjust-opened");r.innerHTML="";h=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");const a=fixed(100*n/l);let c=n+i;let d=fixed(100*c/l);let h=i;if(c>l){c=l;d=100;h=l-n}else if(c<0){c=0;d=0;h=n}const u=`${s(n)} (${a}%)
👇
${s(c)} (${d}%)`;const m=`\n
\n
\n ${t}速\n
\n
\n 进度: ${i>0?"+":"-"}${o(h)}\n
\n
\n
\n
\n
\n
\n
\n ${u}\n
\n
\n `;r.innerHTML=m;p.getVideoshot(c,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${d/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=h+i;let o=Math.abs(i);if(e>100){e=100;o=100-h}else if(e<0){e=0;o=h}const s=`${h} 👉 ${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(h)});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)}}d.classList.remove("adjust-opened")})}}function d(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 h(){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"),d).start()}}Observer.childListSubtree("#bofqi",()=>h());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/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 d=-(s%100%l)*c;const h=-Math.floor(s%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(s/100)]})`,backgroundPosition:`${d}px ${h}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 d=document.getElementsByClassName("touch-video-box")[0];let h=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){d.classList.add("animation")}c.action.onActionStart=(t=>{d.classList.add("adjust-opened");r.innerHTML="";h=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");const a=fixed(100*n/l);let c=n+i;let d=fixed(100*c/l);let h=i;if(c>l){c=l;d=100;h=l-n}else if(c<0){c=0;d=0;h=n}const u=`${s(n)} (${a}%)
👇
${s(c)} (${d}%)`;const m=`\n
\n
\n ${t}速\n
\n
\n 进度: ${i>0?"+":"-"}${o(h)}\n
\n
\n
\n
\n
\n
\n
\n ${u}\n
\n
\n `;r.innerHTML=m;p.getVideoshot(c,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${d/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=h+i;let o=Math.abs(i);if(e>100){e=100;o=100-h}else if(e<0){e=0;o=h}const s=`${h} 👉 ${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(h)});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)}}d.classList.remove("adjust-opened")})}}function d(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 h(){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"),d).start()}}Observer.childList("#bofqi",()=>h());i.applyStyle("touchPlayerStyle")}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-danmaku.min.js"] = (()=>{return()=>{Observer.childList("#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.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/view-cover.min.js"] = (()=>{return(e,n)=>{const t=n.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(n.data.imageViewerDom.text);$(".image-viewer-container .close").on("click",()=>this.hide());n.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const n=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","");const t=URL.createObjectURL(e.response);this.imageData=t;this.viewer.find(".download").attr("href",t).attr("download",n);this.viewer.find(".image").prop("src",t)});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 n=new t(e);await n.fetchInfo();return n.coverUrl}let n=new i(await e());$("#view-cover").on("click",()=>{n.show()});Observer.childList("#bofqi",async()=>{n=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 n=e.attr("href").match(/space\.bilibili\.com\/([\d]+)/);if(n&&n[1]){const e=n[1];const t=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const o=await downloadText(t);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,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/blur-video-control.min.js"] = (()=>{return(r,i)=>{Observer.childList("#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=[];let i=false;class a{constructor(){this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}get menuPanel(){return document.querySelector(".download-video-panel")}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 a{constructor(){super();this.menuClasses=["action","progress"];this.currentMenuClass="action"}async getUrl(){const e=await SpinQuery.select(()=>n[0]).catch(()=>logError("获取番剧下载链接失败."));return e}}class r extends a{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 l{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new d(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 a=i.accept_quality;const o=i.accept_format.split(",");const r=i.accept_description;const c=[];while(a.length>0){const e=new l(a.pop(),o.pop(),r.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class c{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class d{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 a=n.data||n.result||n;if(!s.isOldBangumi&&a.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const o=a.durl;this.fragments=o.map(e=>new c(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 a=new XMLHttpRequest;a.open("GET",e.url);a.responseType="arraybuffer";a.withCredentials=false;a.addEventListener("progress",e=>{this.loaded+=e.loaded-n;n=e.loaded;this.progress&&this.progress(this.loaded/this.totalSize)});a.addEventListener("load",()=>{if((""+a.status)[0]==="2"){t(a.response)}else{s(`请求失败.`)}});a.addEventListener("abort",()=>s("下载已取消."));a.addEventListener("error",()=>s(`下载失败.`));a.setRequestHeader("Range",i);a.send();this.workingXhr.push(a)}));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 u(){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;if(i===false){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)}});i=true}}else{s.isStardustBangumi=true;s.entity=new r}}else{s.entity=new a}return e!==undefined&&t!==undefined}async function h(){let e=await l.availableFormats;let[n]=e;const i=async()=>{await u();e=await l.availableFormats;const t=$("ol.video-quality");t.html("");e.forEach(e=>{$(`
  • ${e.displayName}
  • `).on("click",()=>{n=e;s.entity.nextMenuClass()}).prependTo(t)})};Observer.childListSubtree("#bofqi",i);const a=()=>n.downloadInfo().catch(e=>{s.entity.addError();$(".video-error").text(e)});async function o(){if(!n){return}s.entity.nextMenuClass();const e=await a();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 i=document.getElementById("video-complete");i.setAttribute("href",t.url);i.setAttribute("download",t.filename);i.click();const o=`下载完成. 再次保存`;Toast.success(o,"下载视频");s.entity.resetMenuClass()}async function r(){if(!n){return}const e=await a();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);s.entity.resetMenuClass()}$(".video-action>#video-action-download").on("click",o);$(".video-action>#video-action-copy").on("click",r);t.applyStyle("downloadVideoStyle");const c=document.querySelector(".download-video-panel");const d=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!c.contains(e.target)){d()}});$(".video-error").on("click",()=>{$(".video-error").text("");s.entity.removeError()});await SpinQuery.select(()=>document.querySelector(".download-video-panel"));s.entity.addMenuClass()}return{widget:{content:t.data.downloadVideoDom.text,condition:u,success:h}}}})(); +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=[];let i=false;class a{constructor(){this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}get menuPanel(){return document.querySelector(".download-video-panel")}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 a{constructor(){super();this.menuClasses=["action","progress"];this.currentMenuClass="action"}async getUrl(){const e=await SpinQuery.select(()=>n[0]).catch(()=>logError("获取番剧下载链接失败."));return e}}class r extends a{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 l{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new d(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 a=i.accept_quality;const o=i.accept_format.split(",");const r=i.accept_description;const c=[];while(a.length>0){const e=new l(a.pop(),o.pop(),r.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class c{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class d{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 a=n.data||n.result||n;if(!s.isOldBangumi&&a.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const o=a.durl;this.fragments=o.map(e=>new c(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 a=new XMLHttpRequest;a.open("GET",e.url);a.responseType="arraybuffer";a.withCredentials=false;a.addEventListener("progress",e=>{this.loaded+=e.loaded-n;n=e.loaded;this.progress&&this.progress(this.loaded/this.totalSize)});a.addEventListener("load",()=>{if((""+a.status)[0]==="2"){t(a.response)}else{s(`请求失败.`)}});a.addEventListener("abort",()=>s("下载已取消."));a.addEventListener("error",()=>s(`下载失败.`));a.setRequestHeader("Range",i);a.send();this.workingXhr.push(a)}));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 u(){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;if(i===false){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)}});i=true}}else{s.isStardustBangumi=true;s.entity=new r}}else{s.entity=new a}return e!==undefined&&t!==undefined}async function h(){let e=await l.availableFormats;let[n]=e;const i=async()=>{await u();e=await l.availableFormats;const t=$("ol.video-quality");t.html("");e.forEach(e=>{$(`
  • ${e.displayName}
  • `).on("click",()=>{n=e;s.entity.nextMenuClass()}).prependTo(t)})};Observer.childList("#bofqi",i);const a=()=>n.downloadInfo().catch(e=>{s.entity.addError();$(".video-error").text(e)});async function o(){if(!n){return}s.entity.nextMenuClass();const e=await a();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 i=document.getElementById("video-complete");i.setAttribute("href",t.url);i.setAttribute("download",t.filename);i.click();const o=`下载完成. 再次保存`;Toast.success(o,"下载视频");s.entity.resetMenuClass()}async function r(){if(!n){return}const e=await a();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);s.entity.resetMenuClass()}$(".video-action>#video-action-download").on("click",o);$(".video-action>#video-action-copy").on("click",r);t.applyStyle("downloadVideoStyle");const c=document.querySelector(".download-video-panel");const d=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!c.contains(e.target)){d()}});$(".video-error").on("click",()=>{$(".video-error").text("");s.entity.removeError()});await SpinQuery.select(()=>document.querySelector(".download-video-panel"));s.entity.addMenuClass()}return{widget:{content:t.data.downloadVideoDom.text,condition:u,success:h}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-danmaku.min.js"] = (()=>{return(e,t)=>{const{DanmakuInfo:n}=t.import("videoInfo");const{DanmakuConverter:i}=t.import("danmakuConverter");async function o(e,t){const o=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","");const a=new n((unsafeWindow||window).cid);await a.fetchInfo();const l=await(async()=>{if(t===true){let e={};try{await loadLazyPanel(".bilibili-player-video-danmaku-setting");const t=e=>{const t=parseFloat(document.querySelector(e).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const n={0:0,44:1,94:2,144:3,188:4}[t];return n};e.font=document.querySelector(".bilibili-player-video-danmaku-setting-right-font .bui-select-result").innerText;e.alpha=parseFloat(document.querySelector(".bilibili-player-setting-opacity .bui-bar").style.transform.replace(/scaleX\(([\d\.]+)\)/,"$1"));e.duration=(()=>{const e=[10,8,6,4,2][t(".bilibili-player-setting-speedplus .bui-thumb")];return t=>{switch(t.type){case 4:case 5:return 4;default:return e}}})();e.blockTypes=(()=>{let e=[];const t={".bilibili-player-block-filter-type[ftype=scroll]":[1,2,3],".bilibili-player-block-filter-type[ftype=top]":[5],".bilibili-player-block-filter-type[ftype=bottom]":[4],".bilibili-player-block-filter-type[ftype=color]":["color"],".bilibili-player-block-filter-type[ftype=special]":[7,8]};for(const[n,i]of Object.entries(t)){if(document.querySelector(n).classList.contains("disabled")){e=e.concat(i)}}return e})();const n=[1.4,1.2,1,.8,.6][t(".bilibili-player-setting-fontsize .bui-thumb")];e.resolution={x:1920*n,y:1080*n};e.bottomMarginPercent=[.75,.5,.25,.15,.15][t(".bilibili-player-setting-area .bui-thumb")];e.bold=document.querySelector(".bilibili-player-video-danmaku-setting-right-font-bold input").checked}catch(t){e={font:"微软雅黑",alpha:.6,duration:e=>{switch(e.type){case 4:case 5:return 4;default:return 6}},blockTypes:[],resolution:{x:1920,y:1080},bottomMarginPercent:.15,bold:false}}const t=new i(e);const n=t.convertToAssDocument(a.rawXML);return new Blob([n.generateAss()],{type:"text/plain"})}else{return new Blob([a.rawXML],{type:"text/plain"})}})();const r=URL.createObjectURL(l);const c=$("#danmaku-link");const s=c.attr("href");if(s){URL.revokeObjectURL(s)}clearTimeout(e);document.querySelector("#download-danmaku>span").innerHTML="下载弹幕";c.attr("download",`${o}.${t?"ass":"xml"}`).attr("href",r).get(0).click()}return{widget:{content:`\n \n \n 下载弹幕\n \n `,condition:async()=>{let e=await SpinQuery.condition(()=>(unsafeWindow||window).cid,e=>e!==undefined);return e!==undefined},success:()=>{const e=document.querySelector("#danmaku-link");$("#download-danmaku").on("click",t=>{if(t.target!==e){const e=setTimeout(()=>document.querySelector("#download-danmaku>span").innerHTML="请稍侯...",200);o(e,t.shiftKey)}})}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/danmaku-converter.min.js"] = (()=>{return(t,e)=>{class i{constructor(t,e,i,s,n){this.content=t;this.time=e;this.type=parseInt(i);this.fontSize=parseFloat(s);this.color=parseInt(n)}}class s extends i{constructor({content:t,time:e,type:i,fontSize:s,color:n,timeStamp:r,pool:a,userHash:o,rowId:c}){super(t,e,i,s,n);this.timeStamp=parseInt(r);this.pool=parseInt(a);this.userHash=o;this.rowId=parseInt(c);this.time=parseFloat(this.time);this.pDataArray=[e,i,s,n,r,a,o,c]}text(){const t=this.pDataArray.join(",");return`${this.content}`}static parse(t){const e=t.getAttribute("p");const[i,n,r,a,o,c,h,l]=e.split(",");const u=t.innerHTML;return new s({content:u,time:i,type:n,fontSize:r,color:a,timeStamp:o,pool:c,userHash:h,rowId:l})}}class n{constructor(t){this.xml=t;const e=(new DOMParser).parseFromString(t,"application/xml").documentElement;this.danmakus=[...e.querySelectorAll("d[p]")].map(t=>s.parse(t))}}class r extends i{constructor({content:t,time:e,type:i,fontSize:s,color:n,typeTag:r,colorTag:a,endTime:o}){super(t,e,i,s,n);this.typeTag=r;this.colorTag=a;this.endTime=o}text(t){const e=t[this.fontSize].match(/Style:(.*?),/)[1].trim();return`Dialogue: 0,${this.time},${this.endTime},${e},,0,0,0,,{${this.typeTag}${this.colorTag}}${this.content}`}}class a{constructor({danmakus:t,title:e,fontStyles:i,blockTypes:s,resolution:n}){this.danmakus=t;this.title=e;this.fontStyles=i;this.blockTypes=s;this.resolution=n}generateAss(){const t=`\n[Script Info]\n; Script generated by Bilibili Evolved Danmaku Converter\n; https://github.com/the1812/Bilibili-Evolved/\nTitle: ${this.title}\nScriptType: v4.00+\nPlayResX: ${this.resolution.x}\nPlayResY: ${this.resolution.y}\nTimer: 10.0000\nWrapStyle: 2\nScaledBorderAndShadow: no\n\n[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\n${Object.values(this.fontStyles).join("\n")}\n\n[Events]\nFormat: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\n `.trim();return t+"\n"+this.danmakus.map(t=>t.text(this.fontStyles,this.blockTypes)).filter(t=>t!=="").join("\n")}}class o{constructor(t,e,i,s){this.horizontalDanmakus=[];this.horizontalTrack=[];this.verticalDanmakus=[];this.verticalTrack=[];this.resolution=e;this.duration=i;this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");this.fontSizes={25:`52px ${t}`,18:`36px ${t}`};this.danmakuType={1:"normal",2:"normal",3:"normal",4:"bottom",5:"top",6:"reversed",7:"special",8:"special"};this.bottomMarginPercent=s;this.margin=4;this.nextDanmakuDelay=.05;this.generateTracks()}generateTracks(){const t=52;this.danmakuHeight=t;this.trackHeight=this.margin*2+t;this.trackCount=parseInt(fixed(this.resolution.y*(1-this.bottomMarginPercent)/this.trackHeight,0))}getTextSize(t){this.context.font=this.fontSizes[t.fontSize];const e=this.context.measureText(t.content);const i=e.width/2;return[i,this.danmakuHeight/2]}getTags(t,{targetTrack:e,initTrack:i,nextTrack:s,isClosestDanmaku:n,getTrackItem:r,getTag:a}){const[o,c]=this.getTextSize(t);const h=o*2;const l=this.duration(t)*h/(this.resolution.x+h)+this.nextDanmakuDelay;let u=i;let m=null;do{m=e.find(t=>n({it:t,track:u,width:h}));u+=s}while(m&&u<=this.trackCount&&u>=0);if(u>this.trackCount||u<0){return`\\pos(0,-999)`}u-=s;e.push(r({track:u,width:h,visibleTime:l}));return a({track:u,x:o,y:c})}getHorizonalTags(t){return this.getTags(t,{targetTrack:this.horizontalTrack,initTrack:0,nextTrack:1,isClosestDanmaku:({it:e,track:i,width:s})=>{if(e.track!==i){return false}if(e.widtht.time}},getTrackItem:({track:e,width:i,visibleTime:s})=>{return{width:i,start:t.time,visible:t.time+s,end:t.time+this.duration(t),track:e}},getTag:({track:e,x:i,y:s})=>{return`\\move(${this.resolution.x+i},${e*this.trackHeight+this.margin+s},${-i},${e*this.trackHeight+this.margin+s},0,${this.duration(t)*1e3})`}})}getVerticalTags(t){const e=this.danmakuType[t.type]==="top";return this.getTags(t,{targetTrack:this.verticalTrack,initTrack:e?0:this.trackCount-1,nextTrack:e?1:-1,isClosestDanmaku:({it:e,track:i})=>{if(e.track!==i){return false}return e.end>t.time},getTrackItem:({track:e})=>{return{start:t.time,end:t.time+this.duration(t),track:e}},getTag:({track:t,y:i})=>{if(e){return`\\pos(${this.resolution.x/2},${t*this.trackHeight+this.margin+i})`}else{return`\\pos(${this.resolution.x/2},${this.resolution.y-this.margin-i-(this.trackCount-1-t)*this.trackHeight})`}}})}push(t){let e=null;let i=null;switch(this.danmakuType[t.type]){case"normal":case"reversed":{e=this.getHorizonalTags(t);i=this.horizontalDanmakus;break}case"top":case"bottom":{e=this.getVerticalTags(t);i=this.verticalDanmakus;break}case"special":default:{return{tags:`\\pos(0,-999)`}}}const s={tags:e};i.push(s);return s}}class c{constructor({title:t,font:e,alpha:i,duration:s,blockTypes:n,resolution:r,bottomMarginPercent:a,bold:c}){this.title=t;this.font=e;this.alpha=Math.round(i*100);this.duration=s;this.blockTypes=n;this.resolution=r;this.bold=c;this.white=16777215;this.danmakuStack=new o(e,r,s,a)}get fontStyles(){return{25:`Style: Medium,${this.font},52,&H${this.alpha}FFFFFF,&H${this.alpha}FFFFFF,&H${this.alpha}000000,&H${this.alpha}000000,${this.bold?"1":"0"},0,0,0,100,100,0,0,1,1.2,0,5,0,0,0,0`,18:`Style: Small,${this.font},36,&H${this.alpha}FFFFFF,&H${this.alpha}FFFFFF,&H${this.alpha}000000,&H${this.alpha}000000,${this.bold?"1":"0"},0,0,0,100,100,0,0,1,1.2,0,5,0,0,0,0`}}convertToAssDocument(t){const e=new n(t);const i=[];for(const t of e.danmakus.sort((t,e)=>t.time-e.time)){if(this.blockTypes.indexOf(t.type)!==-1||this.blockTypes.indexOf("color")!==-1&&t.color!==this.white){continue}const[e,s]=this.convertTime(t.time,this.duration(t));i.push(new r({content:this.convertText(t.content),time:e,endTime:s,type:t.type,fontSize:t.fontSize,color:t.color,typeTag:this.convertType(t),colorTag:this.convertColor(t.color)}))}return new a({danmakus:i,title:this.title,blockTypes:this.blockTypes,fontStyles:this.fontStyles,resolution:this.resolution})}convertText(t){const e={"{":"{","}":"}","&":"&","<":"<",">":">",""":'"',"'":"'"};for(const[i,s]of Object.entries(e)){t=t.replace(new RegExp(i,"g"),s)}return t}convertType(t){return this.danmakuStack.push(t).tags}convertColor(t){if(t===this.white){return""}const e=t.toString(16);const i=e.substring(0,2);const s=e.substring(2,4);const n=e.substring(4,6);return`\\c&H${n}${s}${i}&`}convertTime(t,e){function i(t){const[e,i="00"]=String(t).split(".");return`${e.padStart(2,"0")}.${i.substr(0,2).padEnd(2,"0")}`}function s(t){let e=0;let s=0;while(t>=60){t-=60;s++}while(s>=60){s-=60;e++}return`${e}:${String(s).padStart(2,"0")}:${i(t)}`}return[s(t),s(t+e)]}}return{export:{AssDanmaku:r,AssDanmakuDocument:a,Danmaku:i,DanmakuConverter:c,DanmakuStack:o,XmlDanmaku:s,XmlDanmakuDocument:n}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/video-info.min.js"] = (()=>{return()=>{class t{constructor(t){this.aid=t}async fetchInfo(){const t=JSON.parse(await downloadText(`https://api.bilibili.com/x/web-interface/view?aid=${this.aid}`));if(t.code!==0){throw new Error(t.message)}const i=t.data;this.cid=i.cid;this.pageCount=i.videos;this.coverUrl=i.pic;this.tagId=i.tid;this.tagName=i.tname;this.title=i.title;this.description=i.desc;this.up={uid:i.owner.mid,name:i.owner.name,faceUrl:i.owner.face};this.pages=i.pages.map(t=>{return{cid:t.cid,title:t.part,pageNumber:t.page}});return this}async fetchDanmaku(){this.danmaku=new e(this.cid);return this.danmaku.fetchInfo()}}class i{constructor(t,i){this.text=t;this.p=i}}class e{constructor(t){this.cid=t}async fetchInfo(){const t=await downloadText(`https://api.bilibili.com/x/v1/dm/list.so?oid=${this.cid}`);this.rawXML=t;const e=(new DOMParser).parseFromString(t,"application/xml").documentElement;this.xml=e;this.danmakus=[].map.call(e.querySelectorAll("d[p]"),t=>{return new i(t.innerHTML,t.getAttribute("p"))})}}class a{constructor(t){this.ep=t;this.videos=[]}async fetchInfo(){const i=await downloadText(`https://www.bilibili.com/bangumi/play/ep${this.ep}/`);const e=JSON.parse(i.match(/window\.__INITIAL_STATE__=(.*);\(function\(\){/)[1]);this.title=e.mediaInfo.title;this.cover=e.mediaInfo.cover;this.squareCover=e.mediaInfo.square_cover;this.aid=e.epInfo.aid;this.cid=e.epInfo.cid;this.videos=e.epList.map(async i=>{return{title:i.index_title,aid:i.aid,cid:i.cid,info:await new t(i.aid).fetchInfo()}});return this}}return{export:{VideoInfo:t,BangumiInfo:a,Danmaku:i,DanmakuInfo:e}}}})(); @@ -1229,10 +1229,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.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/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 l=()=>{};async function t(){if(e.autoLightOff){await SpinQuery.unsafeJquery();const e=await SpinQuery.any(()=>unsafeWindow.$(".bilibili-player-video-btn-setting"));e.mouseover().mouseout();l=(()=>{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 t();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 l=e(".bilibili-player-video-btn-fullscreen").data("events");if(l.click&&l.click[0]&&l.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()}l();if(e.applyPlayerModeOnPlay){i.removeEventListener("play",n)}};if(e.applyPlayerModeOnPlay){i.addEventListener("play",n)}else{n()}}}Observer.childList("#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("#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.childListSubtree("#bofqi",n)}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/auto-continue.min.js"] = (()=>{return(i,t)=>{function e(i){const t=/((\d)*:)?(\d)*:(\d)*/g;const e=i.text();const n=e.match(t);if(!n){return}const r=n[0].split(":");const o=(()=>{if(r.length===3){const[i,t,e]=r.map(i=>parseInt(i));return i*60*60+t*60+e}else if(r.length===2){const[i,t]=r.map(i=>parseInt(i));return i*60+t}else{logError(`解析历史时间发生错误: historyTime=${JSON.stringify(r)}`);return NaN}})();const s=i.parent();const l=document.querySelector("video");if(o从头开始`);t.appendTo(s).on("click",()=>l.currentTime=0);i.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"),i=>i.text().indexOf("上次看到")!==-1,i=>e(i.filter((i,t)=>t.innerText.indexOf("上次看到")!==-1)))}Observer.childList("#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 d4fde4b1f..fc68e9bb3 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 193.41 +// @version 193.85 // @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howrad (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -1205,22 +1205,22 @@ 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 d=-(s%100%l)*c;const h=-Math.floor(s%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(s/100)]})`,backgroundPosition:`${d}px ${h}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 d=document.getElementsByClassName("touch-video-box")[0];let h=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){d.classList.add("animation")}c.action.onActionStart=(t=>{d.classList.add("adjust-opened");r.innerHTML="";h=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");const a=fixed(100*n/l);let c=n+i;let d=fixed(100*c/l);let h=i;if(c>l){c=l;d=100;h=l-n}else if(c<0){c=0;d=0;h=n}const u=`${s(n)} (${a}%)
    👇
    ${s(c)} (${d}%)`;const m=`\n
    \n
    \n ${t}速\n
    \n
    \n 进度: ${i>0?"+":"-"}${o(h)}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n ${u}\n
    \n
    \n `;r.innerHTML=m;p.getVideoshot(c,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${d/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=h+i;let o=Math.abs(i);if(e>100){e=100;o=100-h}else if(e<0){e=0;o=h}const s=`${h} 👉 ${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(h)});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)}}d.classList.remove("adjust-opened")})}}function d(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 h(){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"),d).start()}}Observer.childListSubtree("#bofqi",()=>h());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/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 d=-(s%100%l)*c;const h=-Math.floor(s%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(s/100)]})`,backgroundPosition:`${d}px ${h}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 d=document.getElementsByClassName("touch-video-box")[0];let h=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){d.classList.add("animation")}c.action.onActionStart=(t=>{d.classList.add("adjust-opened");r.innerHTML="";h=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");const a=fixed(100*n/l);let c=n+i;let d=fixed(100*c/l);let h=i;if(c>l){c=l;d=100;h=l-n}else if(c<0){c=0;d=0;h=n}const u=`${s(n)} (${a}%)
    👇
    ${s(c)} (${d}%)`;const m=`\n
    \n
    \n ${t}速\n
    \n
    \n 进度: ${i>0?"+":"-"}${o(h)}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n ${u}\n
    \n
    \n `;r.innerHTML=m;p.getVideoshot(c,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${d/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=h+i;let o=Math.abs(i);if(e>100){e=100;o=100-h}else if(e<0){e=0;o=h}const s=`${h} 👉 ${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(h)});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)}}d.classList.remove("adjust-opened")})}}function d(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 h(){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"),d).start()}}Observer.childList("#bofqi",()=>h());i.applyStyle("touchPlayerStyle")}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-danmaku.min.js"] = (()=>{return()=>{Observer.childList("#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.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/view-cover.min.js"] = (()=>{return(e,n)=>{const t=n.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(n.data.imageViewerDom.text);$(".image-viewer-container .close").on("click",()=>this.hide());n.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const n=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","");const t=URL.createObjectURL(e.response);this.imageData=t;this.viewer.find(".download").attr("href",t).attr("download",n);this.viewer.find(".image").prop("src",t)});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 n=new t(e);await n.fetchInfo();return n.coverUrl}let n=new i(await e());$("#view-cover").on("click",()=>{n.show()});Observer.childList("#bofqi",async()=>{n=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 n=e.attr("href").match(/space\.bilibili\.com\/([\d]+)/);if(n&&n[1]){const e=n[1];const t=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const o=await downloadText(t);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,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/blur-video-control.min.js"] = (()=>{return(r,i)=>{Observer.childList("#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=[];let i=false;class a{constructor(){this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}get menuPanel(){return document.querySelector(".download-video-panel")}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 a{constructor(){super();this.menuClasses=["action","progress"];this.currentMenuClass="action"}async getUrl(){const e=await SpinQuery.select(()=>n[0]).catch(()=>logError("获取番剧下载链接失败."));return e}}class r extends a{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 l{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new d(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 a=i.accept_quality;const o=i.accept_format.split(",");const r=i.accept_description;const c=[];while(a.length>0){const e=new l(a.pop(),o.pop(),r.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class c{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class d{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 a=n.data||n.result||n;if(!s.isOldBangumi&&a.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const o=a.durl;this.fragments=o.map(e=>new c(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 a=new XMLHttpRequest;a.open("GET",e.url);a.responseType="arraybuffer";a.withCredentials=false;a.addEventListener("progress",e=>{this.loaded+=e.loaded-n;n=e.loaded;this.progress&&this.progress(this.loaded/this.totalSize)});a.addEventListener("load",()=>{if((""+a.status)[0]==="2"){t(a.response)}else{s(`请求失败.`)}});a.addEventListener("abort",()=>s("下载已取消."));a.addEventListener("error",()=>s(`下载失败.`));a.setRequestHeader("Range",i);a.send();this.workingXhr.push(a)}));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 u(){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;if(i===false){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)}});i=true}}else{s.isStardustBangumi=true;s.entity=new r}}else{s.entity=new a}return e!==undefined&&t!==undefined}async function h(){let e=await l.availableFormats;let[n]=e;const i=async()=>{await u();e=await l.availableFormats;const t=$("ol.video-quality");t.html("");e.forEach(e=>{$(`
  • ${e.displayName}
  • `).on("click",()=>{n=e;s.entity.nextMenuClass()}).prependTo(t)})};Observer.childListSubtree("#bofqi",i);const a=()=>n.downloadInfo().catch(e=>{s.entity.addError();$(".video-error").text(e)});async function o(){if(!n){return}s.entity.nextMenuClass();const e=await a();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 i=document.getElementById("video-complete");i.setAttribute("href",t.url);i.setAttribute("download",t.filename);i.click();const o=`下载完成. 再次保存`;Toast.success(o,"下载视频");s.entity.resetMenuClass()}async function r(){if(!n){return}const e=await a();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);s.entity.resetMenuClass()}$(".video-action>#video-action-download").on("click",o);$(".video-action>#video-action-copy").on("click",r);t.applyStyle("downloadVideoStyle");const c=document.querySelector(".download-video-panel");const d=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!c.contains(e.target)){d()}});$(".video-error").on("click",()=>{$(".video-error").text("");s.entity.removeError()});await SpinQuery.select(()=>document.querySelector(".download-video-panel"));s.entity.addMenuClass()}return{widget:{content:t.data.downloadVideoDom.text,condition:u,success:h}}}})(); +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=[];let i=false;class a{constructor(){this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}get menuPanel(){return document.querySelector(".download-video-panel")}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 a{constructor(){super();this.menuClasses=["action","progress"];this.currentMenuClass="action"}async getUrl(){const e=await SpinQuery.select(()=>n[0]).catch(()=>logError("获取番剧下载链接失败."));return e}}class r extends a{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 l{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new d(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 a=i.accept_quality;const o=i.accept_format.split(",");const r=i.accept_description;const c=[];while(a.length>0){const e=new l(a.pop(),o.pop(),r.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class c{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class d{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 a=n.data||n.result||n;if(!s.isOldBangumi&&a.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const o=a.durl;this.fragments=o.map(e=>new c(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 a=new XMLHttpRequest;a.open("GET",e.url);a.responseType="arraybuffer";a.withCredentials=false;a.addEventListener("progress",e=>{this.loaded+=e.loaded-n;n=e.loaded;this.progress&&this.progress(this.loaded/this.totalSize)});a.addEventListener("load",()=>{if((""+a.status)[0]==="2"){t(a.response)}else{s(`请求失败.`)}});a.addEventListener("abort",()=>s("下载已取消."));a.addEventListener("error",()=>s(`下载失败.`));a.setRequestHeader("Range",i);a.send();this.workingXhr.push(a)}));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 u(){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;if(i===false){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)}});i=true}}else{s.isStardustBangumi=true;s.entity=new r}}else{s.entity=new a}return e!==undefined&&t!==undefined}async function h(){let e=await l.availableFormats;let[n]=e;const i=async()=>{await u();e=await l.availableFormats;const t=$("ol.video-quality");t.html("");e.forEach(e=>{$(`
  • ${e.displayName}
  • `).on("click",()=>{n=e;s.entity.nextMenuClass()}).prependTo(t)})};Observer.childList("#bofqi",i);const a=()=>n.downloadInfo().catch(e=>{s.entity.addError();$(".video-error").text(e)});async function o(){if(!n){return}s.entity.nextMenuClass();const e=await a();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 i=document.getElementById("video-complete");i.setAttribute("href",t.url);i.setAttribute("download",t.filename);i.click();const o=`下载完成. 再次保存`;Toast.success(o,"下载视频");s.entity.resetMenuClass()}async function r(){if(!n){return}const e=await a();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);s.entity.resetMenuClass()}$(".video-action>#video-action-download").on("click",o);$(".video-action>#video-action-copy").on("click",r);t.applyStyle("downloadVideoStyle");const c=document.querySelector(".download-video-panel");const d=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!c.contains(e.target)){d()}});$(".video-error").on("click",()=>{$(".video-error").text("");s.entity.removeError()});await SpinQuery.select(()=>document.querySelector(".download-video-panel"));s.entity.addMenuClass()}return{widget:{content:t.data.downloadVideoDom.text,condition:u,success:h}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-danmaku.min.js"] = (()=>{return(e,t)=>{const{DanmakuInfo:n}=t.import("videoInfo");const{DanmakuConverter:i}=t.import("danmakuConverter");async function o(e,t){const o=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","");const a=new n((unsafeWindow||window).cid);await a.fetchInfo();const l=await(async()=>{if(t===true){let e={};try{await loadLazyPanel(".bilibili-player-video-danmaku-setting");const t=e=>{const t=parseFloat(document.querySelector(e).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const n={0:0,44:1,94:2,144:3,188:4}[t];return n};e.font=document.querySelector(".bilibili-player-video-danmaku-setting-right-font .bui-select-result").innerText;e.alpha=parseFloat(document.querySelector(".bilibili-player-setting-opacity .bui-bar").style.transform.replace(/scaleX\(([\d\.]+)\)/,"$1"));e.duration=(()=>{const e=[10,8,6,4,2][t(".bilibili-player-setting-speedplus .bui-thumb")];return t=>{switch(t.type){case 4:case 5:return 4;default:return e}}})();e.blockTypes=(()=>{let e=[];const t={".bilibili-player-block-filter-type[ftype=scroll]":[1,2,3],".bilibili-player-block-filter-type[ftype=top]":[5],".bilibili-player-block-filter-type[ftype=bottom]":[4],".bilibili-player-block-filter-type[ftype=color]":["color"],".bilibili-player-block-filter-type[ftype=special]":[7,8]};for(const[n,i]of Object.entries(t)){if(document.querySelector(n).classList.contains("disabled")){e=e.concat(i)}}return e})();const n=[1.4,1.2,1,.8,.6][t(".bilibili-player-setting-fontsize .bui-thumb")];e.resolution={x:1920*n,y:1080*n};e.bottomMarginPercent=[.75,.5,.25,.15,.15][t(".bilibili-player-setting-area .bui-thumb")];e.bold=document.querySelector(".bilibili-player-video-danmaku-setting-right-font-bold input").checked}catch(t){e={font:"微软雅黑",alpha:.6,duration:e=>{switch(e.type){case 4:case 5:return 4;default:return 6}},blockTypes:[],resolution:{x:1920,y:1080},bottomMarginPercent:.15,bold:false}}const t=new i(e);const n=t.convertToAssDocument(a.rawXML);return new Blob([n.generateAss()],{type:"text/plain"})}else{return new Blob([a.rawXML],{type:"text/plain"})}})();const r=URL.createObjectURL(l);const c=$("#danmaku-link");const s=c.attr("href");if(s){URL.revokeObjectURL(s)}clearTimeout(e);document.querySelector("#download-danmaku>span").innerHTML="下载弹幕";c.attr("download",`${o}.${t?"ass":"xml"}`).attr("href",r).get(0).click()}return{widget:{content:`\n \n \n 下载弹幕\n \n `,condition:async()=>{let e=await SpinQuery.condition(()=>(unsafeWindow||window).cid,e=>e!==undefined);return e!==undefined},success:()=>{const e=document.querySelector("#danmaku-link");$("#download-danmaku").on("click",t=>{if(t.target!==e){const e=setTimeout(()=>document.querySelector("#download-danmaku>span").innerHTML="请稍侯...",200);o(e,t.shiftKey)}})}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/danmaku-converter.min.js"] = (()=>{return(t,e)=>{class i{constructor(t,e,i,s,n){this.content=t;this.time=e;this.type=parseInt(i);this.fontSize=parseFloat(s);this.color=parseInt(n)}}class s extends i{constructor({content:t,time:e,type:i,fontSize:s,color:n,timeStamp:r,pool:a,userHash:o,rowId:c}){super(t,e,i,s,n);this.timeStamp=parseInt(r);this.pool=parseInt(a);this.userHash=o;this.rowId=parseInt(c);this.time=parseFloat(this.time);this.pDataArray=[e,i,s,n,r,a,o,c]}text(){const t=this.pDataArray.join(",");return`${this.content}`}static parse(t){const e=t.getAttribute("p");const[i,n,r,a,o,c,h,l]=e.split(",");const u=t.innerHTML;return new s({content:u,time:i,type:n,fontSize:r,color:a,timeStamp:o,pool:c,userHash:h,rowId:l})}}class n{constructor(t){this.xml=t;const e=(new DOMParser).parseFromString(t,"application/xml").documentElement;this.danmakus=[...e.querySelectorAll("d[p]")].map(t=>s.parse(t))}}class r extends i{constructor({content:t,time:e,type:i,fontSize:s,color:n,typeTag:r,colorTag:a,endTime:o}){super(t,e,i,s,n);this.typeTag=r;this.colorTag=a;this.endTime=o}text(t){const e=t[this.fontSize].match(/Style:(.*?),/)[1].trim();return`Dialogue: 0,${this.time},${this.endTime},${e},,0,0,0,,{${this.typeTag}${this.colorTag}}${this.content}`}}class a{constructor({danmakus:t,title:e,fontStyles:i,blockTypes:s,resolution:n}){this.danmakus=t;this.title=e;this.fontStyles=i;this.blockTypes=s;this.resolution=n}generateAss(){const t=`\n[Script Info]\n; Script generated by Bilibili Evolved Danmaku Converter\n; https://github.com/the1812/Bilibili-Evolved/\nTitle: ${this.title}\nScriptType: v4.00+\nPlayResX: ${this.resolution.x}\nPlayResY: ${this.resolution.y}\nTimer: 10.0000\nWrapStyle: 2\nScaledBorderAndShadow: no\n\n[V4+ Styles]\nFormat: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding\n${Object.values(this.fontStyles).join("\n")}\n\n[Events]\nFormat: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\n `.trim();return t+"\n"+this.danmakus.map(t=>t.text(this.fontStyles,this.blockTypes)).filter(t=>t!=="").join("\n")}}class o{constructor(t,e,i,s){this.horizontalDanmakus=[];this.horizontalTrack=[];this.verticalDanmakus=[];this.verticalTrack=[];this.resolution=e;this.duration=i;this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");this.fontSizes={25:`52px ${t}`,18:`36px ${t}`};this.danmakuType={1:"normal",2:"normal",3:"normal",4:"bottom",5:"top",6:"reversed",7:"special",8:"special"};this.bottomMarginPercent=s;this.margin=4;this.nextDanmakuDelay=.05;this.generateTracks()}generateTracks(){const t=52;this.danmakuHeight=t;this.trackHeight=this.margin*2+t;this.trackCount=parseInt(fixed(this.resolution.y*(1-this.bottomMarginPercent)/this.trackHeight,0))}getTextSize(t){this.context.font=this.fontSizes[t.fontSize];const e=this.context.measureText(t.content);const i=e.width/2;return[i,this.danmakuHeight/2]}getTags(t,{targetTrack:e,initTrack:i,nextTrack:s,isClosestDanmaku:n,getTrackItem:r,getTag:a}){const[o,c]=this.getTextSize(t);const h=o*2;const l=this.duration(t)*h/(this.resolution.x+h)+this.nextDanmakuDelay;let u=i;let m=null;do{m=e.find(t=>n({it:t,track:u,width:h}));u+=s}while(m&&u<=this.trackCount&&u>=0);if(u>this.trackCount||u<0){return`\\pos(0,-999)`}u-=s;e.push(r({track:u,width:h,visibleTime:l}));return a({track:u,x:o,y:c})}getHorizonalTags(t){return this.getTags(t,{targetTrack:this.horizontalTrack,initTrack:0,nextTrack:1,isClosestDanmaku:({it:e,track:i,width:s})=>{if(e.track!==i){return false}if(e.widtht.time}},getTrackItem:({track:e,width:i,visibleTime:s})=>{return{width:i,start:t.time,visible:t.time+s,end:t.time+this.duration(t),track:e}},getTag:({track:e,x:i,y:s})=>{return`\\move(${this.resolution.x+i},${e*this.trackHeight+this.margin+s},${-i},${e*this.trackHeight+this.margin+s},0,${this.duration(t)*1e3})`}})}getVerticalTags(t){const e=this.danmakuType[t.type]==="top";return this.getTags(t,{targetTrack:this.verticalTrack,initTrack:e?0:this.trackCount-1,nextTrack:e?1:-1,isClosestDanmaku:({it:e,track:i})=>{if(e.track!==i){return false}return e.end>t.time},getTrackItem:({track:e})=>{return{start:t.time,end:t.time+this.duration(t),track:e}},getTag:({track:t,y:i})=>{if(e){return`\\pos(${this.resolution.x/2},${t*this.trackHeight+this.margin+i})`}else{return`\\pos(${this.resolution.x/2},${this.resolution.y-this.margin-i-(this.trackCount-1-t)*this.trackHeight})`}}})}push(t){let e=null;let i=null;switch(this.danmakuType[t.type]){case"normal":case"reversed":{e=this.getHorizonalTags(t);i=this.horizontalDanmakus;break}case"top":case"bottom":{e=this.getVerticalTags(t);i=this.verticalDanmakus;break}case"special":default:{return{tags:`\\pos(0,-999)`}}}const s={tags:e};i.push(s);return s}}class c{constructor({title:t,font:e,alpha:i,duration:s,blockTypes:n,resolution:r,bottomMarginPercent:a,bold:c}){this.title=t;this.font=e;this.alpha=Math.round(i*100);this.duration=s;this.blockTypes=n;this.resolution=r;this.bold=c;this.white=16777215;this.danmakuStack=new o(e,r,s,a)}get fontStyles(){return{25:`Style: Medium,${this.font},52,&H${this.alpha}FFFFFF,&H${this.alpha}FFFFFF,&H${this.alpha}000000,&H${this.alpha}000000,${this.bold?"1":"0"},0,0,0,100,100,0,0,1,1.2,0,5,0,0,0,0`,18:`Style: Small,${this.font},36,&H${this.alpha}FFFFFF,&H${this.alpha}FFFFFF,&H${this.alpha}000000,&H${this.alpha}000000,${this.bold?"1":"0"},0,0,0,100,100,0,0,1,1.2,0,5,0,0,0,0`}}convertToAssDocument(t){const e=new n(t);const i=[];for(const t of e.danmakus.sort((t,e)=>t.time-e.time)){if(this.blockTypes.indexOf(t.type)!==-1||this.blockTypes.indexOf("color")!==-1&&t.color!==this.white){continue}const[e,s]=this.convertTime(t.time,this.duration(t));i.push(new r({content:this.convertText(t.content),time:e,endTime:s,type:t.type,fontSize:t.fontSize,color:t.color,typeTag:this.convertType(t),colorTag:this.convertColor(t.color)}))}return new a({danmakus:i,title:this.title,blockTypes:this.blockTypes,fontStyles:this.fontStyles,resolution:this.resolution})}convertText(t){const e={"{":"{","}":"}","&":"&","<":"<",">":">",""":'"',"'":"'"};for(const[i,s]of Object.entries(e)){t=t.replace(new RegExp(i,"g"),s)}return t}convertType(t){return this.danmakuStack.push(t).tags}convertColor(t){if(t===this.white){return""}const e=t.toString(16);const i=e.substring(0,2);const s=e.substring(2,4);const n=e.substring(4,6);return`\\c&H${n}${s}${i}&`}convertTime(t,e){function i(t){const[e,i="00"]=String(t).split(".");return`${e.padStart(2,"0")}.${i.substr(0,2).padEnd(2,"0")}`}function s(t){let e=0;let s=0;while(t>=60){t-=60;s++}while(s>=60){s-=60;e++}return`${e}:${String(s).padStart(2,"0")}:${i(t)}`}return[s(t),s(t+e)]}}return{export:{AssDanmaku:r,AssDanmakuDocument:a,Danmaku:i,DanmakuConverter:c,DanmakuStack:o,XmlDanmaku:s,XmlDanmakuDocument:n}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/video-info.min.js"] = (()=>{return()=>{class t{constructor(t){this.aid=t}async fetchInfo(){const t=JSON.parse(await downloadText(`https://api.bilibili.com/x/web-interface/view?aid=${this.aid}`));if(t.code!==0){throw new Error(t.message)}const i=t.data;this.cid=i.cid;this.pageCount=i.videos;this.coverUrl=i.pic;this.tagId=i.tid;this.tagName=i.tname;this.title=i.title;this.description=i.desc;this.up={uid:i.owner.mid,name:i.owner.name,faceUrl:i.owner.face};this.pages=i.pages.map(t=>{return{cid:t.cid,title:t.part,pageNumber:t.page}});return this}async fetchDanmaku(){this.danmaku=new e(this.cid);return this.danmaku.fetchInfo()}}class i{constructor(t,i){this.text=t;this.p=i}}class e{constructor(t){this.cid=t}async fetchInfo(){const t=await downloadText(`https://api.bilibili.com/x/v1/dm/list.so?oid=${this.cid}`);this.rawXML=t;const e=(new DOMParser).parseFromString(t,"application/xml").documentElement;this.xml=e;this.danmakus=[].map.call(e.querySelectorAll("d[p]"),t=>{return new i(t.innerHTML,t.getAttribute("p"))})}}class a{constructor(t){this.ep=t;this.videos=[]}async fetchInfo(){const i=await downloadText(`https://www.bilibili.com/bangumi/play/ep${this.ep}/`);const e=JSON.parse(i.match(/window\.__INITIAL_STATE__=(.*);\(function\(\){/)[1]);this.title=e.mediaInfo.title;this.cover=e.mediaInfo.cover;this.squareCover=e.mediaInfo.square_cover;this.aid=e.epInfo.aid;this.cid=e.epInfo.cid;this.videos=e.epList.map(async i=>{return{title:i.index_title,aid:i.aid,cid:i.cid,info:await new t(i.aid).fetchInfo()}});return this}}return{export:{VideoInfo:t,BangumiInfo:a,Danmaku:i,DanmakuInfo:e}}}})(); @@ -1229,10 +1229,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.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/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 l=()=>{};async function t(){if(e.autoLightOff){await SpinQuery.unsafeJquery();const e=await SpinQuery.any(()=>unsafeWindow.$(".bilibili-player-video-btn-setting"));e.mouseover().mouseout();l=(()=>{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 t();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 l=e(".bilibili-player-video-btn-fullscreen").data("events");if(l.click&&l.click[0]&&l.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()}l();if(e.applyPlayerModeOnPlay){i.removeEventListener("play",n)}};if(e.applyPlayerModeOnPlay){i.addEventListener("play",n)}else{n()}}}Observer.childList("#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("#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.childListSubtree("#bofqi",n)}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/auto-continue.min.js"] = (()=>{return(i,t)=>{function e(i){const t=/((\d)*:)?(\d)*:(\d)*/g;const e=i.text();const n=e.match(t);if(!n){return}const r=n[0].split(":");const o=(()=>{if(r.length===3){const[i,t,e]=r.map(i=>parseInt(i));return i*60*60+t*60+e}else if(r.length===2){const[i,t]=r.map(i=>parseInt(i));return i*60+t}else{logError(`解析历史时间发生错误: historyTime=${JSON.stringify(r)}`);return NaN}})();const s=i.parent();const l=document.querySelector("video");if(o从头开始`);t.appendTo(s).on("click",()=>l.currentTime=0);i.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"),i=>i.text().indexOf("上次看到")!==-1,i=>e(i.filter((i,t)=>t.innerText.indexOf("上次看到")!==-1)))}Observer.childList("#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 59e5f1f4e..8861e1c2f 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.childListSubtree("#bofqi",n)}})(); \ No newline at end of file +(()=>{return(i,t)=>{function e(i){const t=/((\d)*:)?(\d)*:(\d)*/g;const e=i.text();const n=e.match(t);if(!n){return}const r=n[0].split(":");const o=(()=>{if(r.length===3){const[i,t,e]=r.map(i=>parseInt(i));return i*60*60+t*60+e}else if(r.length===2){const[i,t]=r.map(i=>parseInt(i));return i*60+t}else{logError(`解析历史时间发生错误: historyTime=${JSON.stringify(r)}`);return NaN}})();const s=i.parent();const l=document.querySelector("video");if(o从头开始`);t.appendTo(s).on("click",()=>l.currentTime=0);i.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"),i=>i.text().indexOf("上次看到")!==-1,i=>e(i.filter((i,t)=>t.innerText.indexOf("上次看到")!==-1)))}Observer.childList("#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 4cb116672..f65571af1 100644 --- a/min/blur-video-control.min.js +++ b/min/blur-video-control.min.js @@ -1 +1 @@ -(()=>{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 +(()=>{return(r,i)=>{Observer.childList("#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 37a98c4e3..cd0950fc9 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.childListSubtree("#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 l=()=>{};async function t(){if(e.autoLightOff){await SpinQuery.unsafeJquery();const e=await SpinQuery.any(()=>unsafeWindow.$(".bilibili-player-video-btn-setting"));e.mouseover().mouseout();l=(()=>{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 t();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 l=e(".bilibili-player-video-btn-fullscreen").data("events");if(l.click&&l.click[0]&&l.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()}l();if(e.applyPlayerModeOnPlay){i.removeEventListener("play",n)}};if(e.applyPlayerModeOnPlay){i.addEventListener("play",n)}else{n()}}}Observer.childList("#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 950e0f5ec..17fcf9742 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.childListSubtree("#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.childList("#bofqi",()=>i())}})(); \ No newline at end of file diff --git a/min/download-video.min.js b/min/download-video.min.js index e3455a77b..cd0daba2b 100644 --- a/min/download-video.min.js +++ b/min/download-video.min.js @@ -1 +1 @@ -(()=>{return(e,t)=>{const s={entity:null,aid:undefined,cid:undefined,isOldBangumi:false,isStardustBangumi:false};const n=[];let i=false;class a{constructor(){this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}get menuPanel(){return document.querySelector(".download-video-panel")}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 a{constructor(){super();this.menuClasses=["action","progress"];this.currentMenuClass="action"}async getUrl(){const e=await SpinQuery.select(()=>n[0]).catch(()=>logError("获取番剧下载链接失败."));return e}}class r extends a{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 l{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new d(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 a=i.accept_quality;const o=i.accept_format.split(",");const r=i.accept_description;const c=[];while(a.length>0){const e=new l(a.pop(),o.pop(),r.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class c{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class d{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 a=n.data||n.result||n;if(!s.isOldBangumi&&a.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const o=a.durl;this.fragments=o.map(e=>new c(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 a=new XMLHttpRequest;a.open("GET",e.url);a.responseType="arraybuffer";a.withCredentials=false;a.addEventListener("progress",e=>{this.loaded+=e.loaded-n;n=e.loaded;this.progress&&this.progress(this.loaded/this.totalSize)});a.addEventListener("load",()=>{if((""+a.status)[0]==="2"){t(a.response)}else{s(`请求失败.`)}});a.addEventListener("abort",()=>s("下载已取消."));a.addEventListener("error",()=>s(`下载失败.`));a.setRequestHeader("Range",i);a.send();this.workingXhr.push(a)}));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 u(){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;if(i===false){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)}});i=true}}else{s.isStardustBangumi=true;s.entity=new r}}else{s.entity=new a}return e!==undefined&&t!==undefined}async function h(){let e=await l.availableFormats;let[n]=e;const i=async()=>{await u();e=await l.availableFormats;const t=$("ol.video-quality");t.html("");e.forEach(e=>{$(`
  • ${e.displayName}
  • `).on("click",()=>{n=e;s.entity.nextMenuClass()}).prependTo(t)})};Observer.childListSubtree("#bofqi",i);const a=()=>n.downloadInfo().catch(e=>{s.entity.addError();$(".video-error").text(e)});async function o(){if(!n){return}s.entity.nextMenuClass();const e=await a();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 i=document.getElementById("video-complete");i.setAttribute("href",t.url);i.setAttribute("download",t.filename);i.click();const o=`下载完成. 再次保存`;Toast.success(o,"下载视频");s.entity.resetMenuClass()}async function r(){if(!n){return}const e=await a();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);s.entity.resetMenuClass()}$(".video-action>#video-action-download").on("click",o);$(".video-action>#video-action-copy").on("click",r);t.applyStyle("downloadVideoStyle");const c=document.querySelector(".download-video-panel");const d=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!c.contains(e.target)){d()}});$(".video-error").on("click",()=>{$(".video-error").text("");s.entity.removeError()});await SpinQuery.select(()=>document.querySelector(".download-video-panel"));s.entity.addMenuClass()}return{widget:{content:t.data.downloadVideoDom.text,condition:u,success:h}}}})(); \ No newline at end of file +(()=>{return(e,t)=>{const s={entity:null,aid:undefined,cid:undefined,isOldBangumi:false,isStardustBangumi:false};const n=[];let i=false;class a{constructor(){this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}get menuPanel(){return document.querySelector(".download-video-panel")}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 a{constructor(){super();this.menuClasses=["action","progress"];this.currentMenuClass="action"}async getUrl(){const e=await SpinQuery.select(()=>n[0]).catch(()=>logError("获取番剧下载链接失败."));return e}}class r extends a{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 l{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new d(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 a=i.accept_quality;const o=i.accept_format.split(",");const r=i.accept_description;const c=[];while(a.length>0){const e=new l(a.pop(),o.pop(),r.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class c{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class d{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 a=n.data||n.result||n;if(!s.isOldBangumi&&a.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const o=a.durl;this.fragments=o.map(e=>new c(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 a=new XMLHttpRequest;a.open("GET",e.url);a.responseType="arraybuffer";a.withCredentials=false;a.addEventListener("progress",e=>{this.loaded+=e.loaded-n;n=e.loaded;this.progress&&this.progress(this.loaded/this.totalSize)});a.addEventListener("load",()=>{if((""+a.status)[0]==="2"){t(a.response)}else{s(`请求失败.`)}});a.addEventListener("abort",()=>s("下载已取消."));a.addEventListener("error",()=>s(`下载失败.`));a.setRequestHeader("Range",i);a.send();this.workingXhr.push(a)}));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 u(){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;if(i===false){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)}});i=true}}else{s.isStardustBangumi=true;s.entity=new r}}else{s.entity=new a}return e!==undefined&&t!==undefined}async function h(){let e=await l.availableFormats;let[n]=e;const i=async()=>{await u();e=await l.availableFormats;const t=$("ol.video-quality");t.html("");e.forEach(e=>{$(`
  • ${e.displayName}
  • `).on("click",()=>{n=e;s.entity.nextMenuClass()}).prependTo(t)})};Observer.childList("#bofqi",i);const a=()=>n.downloadInfo().catch(e=>{s.entity.addError();$(".video-error").text(e)});async function o(){if(!n){return}s.entity.nextMenuClass();const e=await a();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 i=document.getElementById("video-complete");i.setAttribute("href",t.url);i.setAttribute("download",t.filename);i.click();const o=`下载完成. 再次保存`;Toast.success(o,"下载视频");s.entity.resetMenuClass()}async function r(){if(!n){return}const e=await a();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);s.entity.resetMenuClass()}$(".video-action>#video-action-download").on("click",o);$(".video-action>#video-action-copy").on("click",r);t.applyStyle("downloadVideoStyle");const c=document.querySelector(".download-video-panel");const d=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!c.contains(e.target)){d()}});$(".video-error").on("click",()=>{$(".video-error").text("");s.entity.removeError()});await SpinQuery.select(()=>document.querySelector(".download-video-panel"));s.entity.addMenuClass()}return{widget:{content:t.data.downloadVideoDom.text,condition:u,success:h}}}})(); \ No newline at end of file diff --git a/min/expand-danmaku.min.js b/min/expand-danmaku.min.js index a935eab90..1d0fcbbf6 100644 --- a/min/expand-danmaku.min.js +++ b/min/expand-danmaku.min.js @@ -1 +1 @@ -(()=>{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 +(()=>{return()=>{Observer.childList("#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 ea65bc525..6b4b20f09 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 d=-(s%100%l)*c;const h=-Math.floor(s%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(s/100)]})`,backgroundPosition:`${d}px ${h}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 d=document.getElementsByClassName("touch-video-box")[0];let h=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){d.classList.add("animation")}c.action.onActionStart=(t=>{d.classList.add("adjust-opened");r.innerHTML="";h=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");const a=fixed(100*n/l);let c=n+i;let d=fixed(100*c/l);let h=i;if(c>l){c=l;d=100;h=l-n}else if(c<0){c=0;d=0;h=n}const u=`${s(n)} (${a}%)
    👇
    ${s(c)} (${d}%)`;const m=`\n
    \n
    \n ${t}速\n
    \n
    \n 进度: ${i>0?"+":"-"}${o(h)}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n ${u}\n
    \n
    \n `;r.innerHTML=m;p.getVideoshot(c,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${d/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=h+i;let o=Math.abs(i);if(e>100){e=100;o=100-h}else if(e<0){e=0;o=h}const s=`${h} 👉 ${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(h)});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)}}d.classList.remove("adjust-opened")})}}function d(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 h(){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"),d).start()}}Observer.childListSubtree("#bofqi",()=>h());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 d=-(s%100%l)*c;const h=-Math.floor(s%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(s/100)]})`,backgroundPosition:`${d}px ${h}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 d=document.getElementsByClassName("touch-video-box")[0];let h=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){d.classList.add("animation")}c.action.onActionStart=(t=>{d.classList.add("adjust-opened");r.innerHTML="";h=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");const a=fixed(100*n/l);let c=n+i;let d=fixed(100*c/l);let h=i;if(c>l){c=l;d=100;h=l-n}else if(c<0){c=0;d=0;h=n}const u=`${s(n)} (${a}%)
    👇
    ${s(c)} (${d}%)`;const m=`\n
    \n
    \n ${t}速\n
    \n
    \n 进度: ${i>0?"+":"-"}${o(h)}\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n ${u}\n
    \n
    \n `;r.innerHTML=m;p.getVideoshot(c,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${d/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=h+i;let o=Math.abs(i);if(e>100){e=100;o=100-h}else if(e<0){e=0;o=h}const s=`${h} 👉 ${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(h)});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)}}d.classList.remove("adjust-opened")})}}function d(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 h(){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"),d).start()}}Observer.childList("#bofqi",()=>h());i.applyStyle("touchPlayerStyle")}})(); \ No newline at end of file diff --git a/min/view-cover.min.js b/min/view-cover.min.js index 653d8b33c..2987e6af1 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.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 +(()=>{return(e,n)=>{const t=n.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(n.data.imageViewerDom.text);$(".image-viewer-container .close").on("click",()=>this.hide());n.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const n=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","").replace("_番剧_bilibili_哔哩哔哩","");const t=URL.createObjectURL(e.response);this.imageData=t;this.viewer.find(".download").attr("href",t).attr("download",n);this.viewer.find(".image").prop("src",t)});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 n=new t(e);await n.fetchInfo();return n.coverUrl}let n=new i(await e());$("#view-cover").on("click",()=>{n.show()});Observer.childList("#bofqi",async()=>{n=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 n=e.attr("href").match(/space\.bilibili\.com\/([\d]+)/);if(n&&n[1]){const e=n[1];const t=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const o=await downloadText(t);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 1dacb4da5..c02e455c2 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("#bofqi", () => + Observer.childList("#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 ed888b38e..66c514651 100644 --- a/touch/player/touch-player.js +++ b/touch/player/touch-player.js @@ -600,7 +600,7 @@ } } - Observer.childListSubtree("#bofqi", () => main()); + Observer.childList("#bofqi", () => main()); resources.applyStyle("touchPlayerStyle"); }; })(); diff --git a/video/auto-continue.js b/video/auto-continue.js index 12cbd7ec1..bd14089ce 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.childListSubtree("#bofqi", findHistoryToast); + Observer.childList("#bofqi", findHistoryToast); }; })(); \ No newline at end of file diff --git a/video/default-player-mode.js b/video/default-player-mode.js index 17bf7d6b3..e095cfd2c 100644 --- a/video/default-player-mode.js +++ b/video/default-player-mode.js @@ -102,6 +102,6 @@ } } } - Observer.childListSubtree("#bofqi", () => main()); + Observer.childList("#bofqi", () => main()); }; })(); \ No newline at end of file diff --git a/video/default-video-quality.js b/video/default-video-quality.js index 80afaef26..1d9f47b15 100644 --- a/video/default-video-quality.js +++ b/video/default-video-quality.js @@ -71,6 +71,6 @@ } video.addEventListener("play", onplay); } - Observer.childListSubtree("#bofqi", () => applyQuality()); + Observer.childList("#bofqi", () => applyQuality()); }; })(); \ No newline at end of file diff --git a/video/download-video/download-video.js b/video/download-video/download-video.js index e203ca4a5..97a5fedf1 100644 --- a/video/download-video/download-video.js +++ b/video/download-video/download-video.js @@ -405,7 +405,7 @@ .prependTo(list); }); }; - Observer.childListSubtree("#bofqi", loadQualities); + Observer.childList("#bofqi", loadQualities); const getVideoInfo = () => selectedFormat.downloadInfo().catch(error => { pageData.entity.addError(); diff --git a/video/expand-danmaku.js b/video/expand-danmaku.js index ab2fda63e..038cfd387 100644 --- a/video/expand-danmaku.js +++ b/video/expand-danmaku.js @@ -2,7 +2,7 @@ { return () => { - Observer.childListSubtree("#bofqi", () => + Observer.childList("#bofqi", () => { SpinQuery.any( () => $(".bui-collapse-header"), diff --git a/video/view-cover/view-cover.js b/video/view-cover/view-cover.js index f716d2306..ac0e59e95 100644 --- a/video/view-cover/view-cover.js +++ b/video/view-cover/view-cover.js @@ -86,7 +86,7 @@ { imageViewer.show(); }); - Observer.childListSubtree("#bofqi", async () => + Observer.childList("#bofqi", async () => { imageViewer = new ImageViewer(await getUrl()); });