From e30d3395c2005b340331d13ed22dbab2d4e5f6e8 Mon Sep 17 00:00:00 2001 From: the1812 Date: Sun, 1 Sep 2019 23:19:41 +0800 Subject: [PATCH] Refactor download video styles --- bilibili-evolved.offline.user.js | 15 +- bilibili-evolved.preview-offline.user.js | 15 +- bilibili-evolved.preview.user.js | 6 + bilibili-evolved.user.js | 6 + min/download-video.min.css | 2 +- min/download-video.min.js | 2 +- min/v-checkbox.vue.min.js | 1 + min/v-dropdown.vue.min.js | 2 +- src/client/resource-manifest.js | 6 + src/video/download-video/download-video.css | 374 ------------------- src/video/download-video/download-video.scss | 342 +++++++++++++++++ src/video/download-video/download-video.ts | 18 +- src/video/download-video/v-checkbox.vue | 55 +++ src/video/download-video/v-dropdown.vue | 9 + 14 files changed, 452 insertions(+), 401 deletions(-) create mode 100644 min/v-checkbox.vue.min.js delete mode 100644 src/video/download-video/download-video.css create mode 100644 src/video/download-video/download-video.scss create mode 100644 src/video/download-video/v-checkbox.vue diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index 955169e15..30b1a4774 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Offline) -// @version 412.30 +// @version 412.31 // @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -976,9 +976,9 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/double-click-fullscreen.min.js"] = (()=>{return(i,e)=>{(async()=>{const e=["https://www.bilibili.com/bangumi/","https://www.bilibili.com/video/"];if(!e.some(i=>document.URL.startsWith(i))){return}if(i.touchVideoPlayer&&i.touchVideoPlayerDoubleTapControl){Toast.info("在开启了播放器触摸支持-启用双击控制后, 双击全屏功能将无效.","提示");i.doubleClickFullscreen=false;return}await SpinQuery.unsafeJquery();const l=await SpinQuery.condition(()=>dq(".bilibili-player-area"),i=>i!==null&&unsafeWindow.$(".bilibili-player-video").data("events"));if(l===null){return}const n="double-click-fullscreen";if(!l.classList.contains(n)){l.classList.add(n);const i=unsafeWindow.$(".bilibili-player-video");const e=new DoubleClickEvent(()=>dq(".bilibili-player-video-btn-fullscreen").click(),()=>{});e.bind(i[0])}})()}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-audio.min.js"] = (()=>{return(e,t)=>{class n{constructor(){this.sid=null;this.progress=null}async getDownloadUrl(){const e=`https://www.bilibili.com/audio/music-service-c/web/url?sid=${this.sid}&privilege=2&quality=2`;const t=await Ajax.getJsonWithCredentials(e);if(t.code===0){return t.data.cdns.shift()}else{logError("获取下载链接失败, 请确保当前账号有下载权限.","下载音频",1e4);return null}}async download(){const e=await this.getDownloadUrl();return new Promise((t,n)=>{const s=new XMLHttpRequest;s.open("GET",e);s.responseType="blob";s.addEventListener("load",()=>t(s.response));s.addEventListener("error",()=>n(s.status));s.addEventListener("progress",e=>this.progress&&this.progress(100*e.loaded/e.total));s.send()})}}const s="下载音频";return{export:n,widget:{content:`\n \n \n ${s}\n \n `,condition:()=>document.URL.includes("bilibili.com/audio"),success:async()=>{await SpinQuery.select(()=>document.querySelector("#app"));const e=document.querySelector("#download-audio");const t=e.querySelector("span");const o=new n;o.progress=(e=>{t.innerHTML=`${Math.round(e)}%`});const i=document.querySelector("#download-audio-link");e.addEventListener("click",async e=>{if(o.sid===null||e.target===i){return}const n=await o.download();t.innerHTML=s;const r=i.getAttribute("href");if(r){URL.revokeObjectURL(r)}i.setAttribute("href",URL.createObjectURL(n));const d=(()=>{const e=document.querySelector(".song-title");if(e){return e.getAttribute("title")}else{return"神秘音频"}})();i.setAttribute("download",d+".m4a");i.click()});Observer.childList("#app",()=>{const t=document.URL.match(/bilibili\.com\/audio\/au([\d]+)/);if(t&&t[1]){e.disabled=false;o.sid=t[1]}else{e.disabled=true}})}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-danmaku.min.js"] = (()=>{return(t,e)=>{const{getFriendlyTitle:n}=e.import("title");const{DanmakuInfo:i}=e.import("video-info");const{DanmakuConverter:a}=e.import("danmaku-converter");async function o(t){const e=n();let i={title:e};try{await loadDanmakuSettingsPanel();const t=t=>{const e=parseFloat(dq(t).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const n={0:0,44:1,94:2,144:3,188:4}[e];return n};i.font=dq(".bilibili-player-video-danmaku-setting-right-font .bui-select-result").innerText;i.alpha=parseFloat(dq(".bilibili-player-setting-opacity .bui-bar").style.transform.replace(/scaleX\(([\d\.]+)\)/,"$1"));i.duration=(()=>{const e=[18,14,10,8,6][t(".bilibili-player-setting-speedplus .bui-thumb")];return t=>{switch(t.type){case 4:case 5:return 4;default:return e}}})();i.blockTypes=(()=>{let t=[];const e={".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"]};for(const[n,i]of Object.entries(e)){if(dq(n).classList.contains("disabled")){t=t.concat(i)}}return t.concat(7,8)})();const e=[1.4,1.2,1,.8,.6][t(".bilibili-player-setting-fontsize .bui-thumb")];i.resolution={x:1920*e,y:1080*e};i.bottomMarginPercent=[.75,.5,.25,0,0][t(".bilibili-player-setting-area .bui-thumb")];if(i.bottomMarginPercent===0&&dq(".bilibili-player-video-danmaku-setting-left-preventshade input").checked){i.bottomMarginPercent=.15}i.bold=dq(".bilibili-player-video-danmaku-setting-right-font-bold input").checked}catch(t){i={font:"微软雅黑",alpha:.6,duration:t=>{switch(t.type){case 4:case 5:return 4;default:return 6}},blockTypes:[7,8],resolution:{x:1920,y:1080},bottomMarginPercent:.15,bold:false}}const o=new a(i);const l=o.convertToAssDocument(t);return l.generateAss()}async function l(t,e){const a=n();const l=new i((unsafeWindow||window).cid);await l.fetchInfo();const r=await(async()=>{if(t===true){return new Blob([await o(l.rawXML)],{type:"text/plain"})}else{return new Blob([l.rawXML],{type:"text/plain"})}})();const s=URL.createObjectURL(r);const c=dq("#danmaku-link");const d=c.getAttribute("href");if(d){URL.revokeObjectURL(d)}clearTimeout(e);dq("#download-danmaku>span").innerHTML="下载弹幕";c.setAttribute("download",`${a}.${t?"ass":"xml"}`);c.setAttribute("href",s);c.click()}return{export:{downloadDanmaku:l,convertToAss:o},widget:{content:`\n \n \n 下载弹幕\n \n `,condition:async()=>{let t=await SpinQuery.select(()=>(unsafeWindow||window).cid);return Boolean(t)},success:()=>{const t=document.querySelector("#danmaku-link");dq("#download-danmaku").addEventListener("click",e=>{if(e.target!==t){const t=setTimeout(()=>dq("#download-danmaku>span").innerHTML="请稍侯...",200);l(e.shiftKey,t)}})}}}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.css"] = `.download-video.opened{pointer-events:initial;opacity:1;transform:translate(-50%,-50%) scale(1)}.download-video{--download-video-background:white;--download-video-foreground:black;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .title,.round-corner .download-video button,.round-corner .v-dropdown,.round-corner .v-dropdown .dropdown-menu,.round-corner .v-dropdown .dropdown-menu li{border-radius:var(--corner-radius)}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video .cover{width:240px;min-height:135px;background-color:#8882}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video h1{font-size:16pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding-top:12px;font-size:10pt}.download-video .tabs .tab{padding:6px 12px;border-bottom:2px solid transparent;cursor:pointer}.download-video .tab.active{color:var(--theme-color);border-bottom-color:var(--theme-color)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0}.download-video h2{font-size:12pt;font-weight:700;color:var(--download-video-foreground)}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}.download-video .direct-download .progress .percent{width:50px;text-align:right}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(50% - 16px);display:flex;justify-content:center;align-items:center}.download-video i.mdi-alert-circle{font-size:14pt;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:300px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.v-checkbox{font-size:10pt;cursor:pointer;display:flex;align-items:center}.v-checkbox .mdi{font-size:15pt;line-height:1}.v-checkbox .content{flex-grow:1;text-align:left;padding:0 8px}.v-checkbox .mdi-checkbox-marked-circle{color:var(--theme-color);position:absolute;top:0;left:0;transform:scale(0);transition-timing-function:cubic-bezier(.6,-.28,.74,.05)}.v-checkbox .mdi-checkbox-blank-circle-outline{color:#8884;position:relative}.v-checkbox.checked .mdi-checkbox-blank-circle-outline{color:var(--theme-color)}.v-checkbox.checked .mdi-checkbox-marked-circle{transform:scale(1);transition-timing-function:cubic-bezier(.18,.89,.32,1.28)}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:var(--download-video-background);bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%);opacity:0;pointer-events:none;padding:8px;z-index:3}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;pointer-events:initial}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}`; +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.css"] = `.download-video{--download-video-background:white;--download-video-foreground:black;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;max-height:90%;overflow:auto}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translate(-50%,-50%) scale(1)}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{width:240px;min-height:135px;background-color:#8882}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video h1{font-size:16pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding-top:12px;font-size:10pt}.download-video .tabs .tab{padding:6px 12px;border-bottom:2px solid transparent;cursor:pointer}.download-video .tabs .tab.active{color:var(--theme-color);border-bottom-color:var(--theme-color)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video h2{font-size:12pt;font-weight:700;color:var(--download-video-foreground)}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(50% - 16px);display:flex;justify-content:center;align-items:center}.download-video i.mdi-alert-circle{font-size:14pt;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:300px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:var(--download-video-background);bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%);opacity:0;pointer-events:none;padding:8px;z-index:3}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;pointer-events:initial}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.html"] = `

下载视频

单个视频
批量导出
警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项.
预计大小: {{displaySize}}
清晰度
弹幕

直接下载

{{speed}}
{{progressPercent}}%

选集

{{selectedEpisodeCount}}/{{episodeList.length}}

导出

{{showRpcSettings ? '取消' : '导出aria2 RPC'}}

aria2 RPC 配置

主机
端口
密钥
限速
路径
方法
确定
`; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.js"] = (()=>{return(e,t)=>{const{getFriendlyTitle:s}=t.import("title");const{VideoInfo:i,DanmakuInfo:a}=t.import("video-info");class n{constructor(){this.menuClasses=["quality","action","progress"];[this.currentMenuClass]=this.menuClasses}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}closeMenu(){this.menuPanel.classList.remove("opened");setTimeout(()=>this.resetMenuClass(),200)}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=${r.aid}&cid=${r.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${r.aid}&cid=${r.cid}&otype=json`}}}class o extends n{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${r.aid}&cid=${r.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${r.aid}&cid=${r.cid}&qn=&otype=json`}}}const r={entity:new n,aid:"",cid:""};let l=[];let c=null;class d{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new u(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{r.entity.getUrl().then(s=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{const s=JSON.parse(i.responseText);if(s.code!==0){t("获取清晰度信息失败.");return}const a=s.data||s.result||s;const n=a.accept_quality;const o=a.accept_format.split(",");const r=a.accept_description;const l=[];while(n.length>0){const e=new d(n.pop(),o.pop(),r.pop());l.push(e)}e(l.reverse())});i.addEventListener("error",()=>t(`获取清晰度信息失败.`));i.withCredentials=true;i.open("GET",s);i.send()})})}}class h{constructor(e,t,s,i){this.length=e;this.size=t;this.url=s;this.backupUrls=i}}class u{constructor(e,t){this.fragmentSplitFactor=6*5;this.workingXhr=null;this.progressMap=new Map;this.format=e;this.fragments=t||[];this.videoSpeed=new p(this)}get totalSize(){return this.fragments.map(e=>e.size).reduce((e,t)=>e+t)}fetchVideoInfo(){return new Promise((e,t)=>{r.entity.getUrl(this.format.quality).then(s=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{const s=JSON.parse(i.responseText.replace(/http:/g,"https:"));const a=s.data||s.result||s;if(a.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const n=a.durl;this.fragments=n.map(e=>new h(e.length,e.size,e.url,e.backup_url));e(this.fragments)});i.withCredentials=true;i.open("GET",s);i.send()})})}updateProgress(){const e=this.progressMap?[...this.progressMap.values()].reduce((e,t)=>e+t,0)/this.totalSize:0;if(e>1||e<0){console.error(`[下载视频] 进度异常: ${e}`,this.progressMap.values())}this.progress&&this.progress(e)}cancelDownload(){this.videoSpeed.stopMeasure();if(this.workingXhr!==null){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const s=16*1024*1024;let i=0;const a=e=>[...this.progressMap.keys()].indexOf(e)+1;while(i{const i=new XMLHttpRequest;i.open("GET",e.url);i.responseType="arraybuffer";i.withCredentials=false;i.addEventListener("progress",e=>{console.log(`[下载视频] 视频片段${a(i)}下载进度: ${e.loaded}/${r} bytes loaded, ${o}`);this.progressMap.set(i,e.loaded);this.updateProgress()});i.addEventListener("load",()=>{if((""+i.status)[0]==="2"){console.log(`[下载视频] 视频片段${a(i)}下载完成`);t(i.response)}else{s(`视频片段${a(i)}请求失败, response = ${i.status}`)}});i.addEventListener("abort",()=>s("canceled"));i.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${a(i)}下载失败: ${o}`);this.progressMap.set(i,0);this.updateProgress();i.open("GET",e.url);i.setRequestHeader("Range",o);i.send()});i.setRequestHeader("Range",o);this.progressMap.set(i,0);i.send();this.workingXhr.push(i)}));i=Math.round(i+s)+1}return Promise.all(t)}async copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}static downloadBlob(e,t){const s=document.createElement("a");let i;if(typeof e==="string"){i=e}else{i=URL.createObjectURL(e)}s.setAttribute("href",i);s.setAttribute("download",t);document.body.appendChild(s);s.click();s.remove();URL.revokeObjectURL(i)}async exportData(e=false){const t=JSON.stringify([{fragments:this.fragments,title:s(),totalSize:this.fragments.map(e=>e.size).reduce((e,t)=>e+t),referer:document.URL.replace(window.location.search,"")}]);if(e){GM_setClipboard(t,"text")}else{const e=new Blob([t],{type:"text/json"});const i=await this.downloadDanmaku();if(i!==null){const t=new JSZip;t.file(`${s()}.json`,e);t.file(s()+"."+this.danmakuOption.toLowerCase(),i);u.downloadBlob(await t.generateAsync({type:"blob"}),`${s()}.zip`)}else{u.downloadBlob(e,`${s()}.json`)}}}async exportAria2(i=false){if(i){const i=await this.downloadDanmaku();if(i!==null){u.downloadBlob(new Blob([i]),`${s()}.${this.danmakuOption==="ASS"?"ass":"xml"}`)}const a=e.aria2RpcOption;const n=this.fragments.map((e,t)=>{let i="";if(this.fragments.length>1){i=" - "+(t+1)}const n=[];if(a.secretKey!==""){n.push(`token:${a.secretKey}`)}n.push([e.url]);n.push({referer:document.URL.replace(window.location.search,""),"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0",out:`${s()}${i}${this.extension(e)}`,split:this.fragmentSplitFactor,dir:a.dir||undefined,"max-download-limit":a.maxDownloadLimit||undefined});const o=encodeURIComponent(`${s()}${i}`);return{params:n,id:o}});const{sendRpc:o}=await t.importAsync("aria2-rpc");await o(n)}else{const e=`\n# Generated by Bilibili Evolved Video Export\n# https://github.com/the1812/Bilibili-Evolved/\n${this.fragments.map((e,t)=>{let i="";if(this.fragments.length>1){i=" - "+(t+1)}return`\n${e.url}\n referer=${document.URL.replace(window.location.search,"")}\n user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0\n out=${s()}${i}${this.extension(e)}\n split=${this.fragmentSplitFactor}\n `.trim()}).join("\n")}\n `.trim();const t=new Blob([e],{type:"text/plain"});const i=await this.downloadDanmaku();if(i!==null){const e=new JSZip;e.file(`${s()}.txt`,t);e.file(s()+"."+this.danmakuOption.toLowerCase(),i);u.downloadBlob(await e.generateAsync({type:"blob"}),`${s()}.zip`)}else{u.downloadBlob(t,`${s()}.txt`)}}}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=dq("a#video-complete").getAttribute("href");if(e&&!dq(`.link[href="${e}"]`)){URL.revokeObjectURL(e)}dqa(".toast-card-header").filter(e=>e.innerText.includes("下载视频")).forEach(e=>e.querySelector(".toast-card-dismiss").click())}async downloadDanmaku(){if(this.danmakuOption!=="无"){const e=new a(r.cid);await e.fetchInfo();if(this.danmakuOption==="XML"){return e.rawXML}else{const{convertToAss:s}=await t.importAsync("download-danmaku");return s(e.rawXML)}}else{return null}}async downloadSingle(e){const t=await this.downloadDanmaku();const[i]=e;if(t===null){const e=this.makeBlob(i);const t=s()+this.extension();return{blob:e,filename:t}}else{const e=new JSZip;e.file(s()+this.extension(),this.makeBlob(i));e.file(s()+"."+this.danmakuOption.toLowerCase(),t);const a=await e.generateAsync({type:"blob"});const n=s()+".zip";return{blob:a,filename:n}}}async downloadMultiple(e){const t=new JSZip;const i=s();if(e.length>1){e.forEach((e,s)=>{const a=this.fragments[s];t.file(`${i} - ${s+1}${this.extension(a)}`,this.makeBlob(e,a))})}else{const[s]=e;t.file(`${i}${this.extension()}`,this.makeBlob(s))}const a=await this.downloadDanmaku();if(a!==null){t.file(s()+"."+this.danmakuOption.toLowerCase(),a)}const n=await t.generateAsync({type:"blob"});const o=i+".zip";return{blob:n,filename:o}}async download(){const e=[];this.videoSpeed.startMeasure();for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let{blob:t,filename:s}=await(async()=>{if(e.length===1){return await this.downloadSingle(e)}else{return await this.downloadMultiple(e)}})();this.cleanUpOldBlobUrl();const i=URL.createObjectURL(t);this.progress&&this.progress(0);this.videoSpeed.stopMeasure();return{url:i,filename:s}}}class p{constructor(e){this.lastProgress=0;this.measureInterval=1e3;this.workingDownloader=e}startMeasure(){this.intervalTimer=setInterval(()=>{const e=this.workingDownloader.progressMap?[...this.workingDownloader.progressMap.values()].reduce((e,t)=>e+t,0):0;const t=e-this.lastProgress;if(this.speedUpdate!==undefined){this.speedUpdate(formatFileSize(t)+"/s")}this.lastProgress=e},this.measureInterval)}stopMeasure(){clearInterval(this.intervalTimer)}}async function w(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);if(!(e&&t)){return false}r.aid=e;r.cid=t;if(document.URL.indexOf("bangumi")!==-1){r.entity=new o}else{r.entity=new n}try{l=await d.availableFormats}catch(e){return false}return true}async function f(){c=l[0];t.applyStyle("downloadVideoStyle");dq("#download-video").addEventListener("click",()=>{dq(".download-video").classList.toggle("opened");dq(".gui-settings-mask").click()});dq("#download-video").addEventListener("mouseover",()=>{document.body.insertAdjacentHTML("beforeend",t.import("downloadVideoHtml"));m()},{once:true})}async function m(){const n=await t.importAsync("v-dropdown.vue");Vue.component("v-checkbox",{template:`\n
\n \n \n \n {{title}}\n
\n `,props:["checked","title"],methods:{toggleCheck(){this.$emit("update:checked",!this.checked)}}});let o;const h=new Map;const p=new Vue({el:".download-video",components:{"v-dropdown":n},data:{downloadSingle:true,coverUrl:'data:image/svg+xml;utf-8,',aid:r.aid,cid:r.cid,qualityModel:{value:c.displayName,items:l.map(e=>e.displayName)},danmakuModel:{value:e.downloadVideoDefaultDanmaku,items:["无","XML","ASS"]},progressPercent:0,size:"获取大小中",blobUrl:"",episodeList:[],downloading:false,speed:"",batch:false,rpcSettings:e.aria2RpcOption,showRpcSettings:false,busy:false},computed:{displaySize(){if(typeof this.size==="string"){return this.size}return formatFileSize(this.size)},sizeWarning(){if(typeof this.size==="string"){return false}return this.size>1073741824},selectedEpisodeCount(){return this.episodeList.filter(e=>e.checked).length}},methods:{close(){this.$el.classList.remove("opened")},danmakuOptionChange(){e.downloadVideoDefaultDanmaku=this.danmakuModel.value},async formatChange(){const e=this.getFormat();const t=h.get(e);if(t){this.size=t;return}try{this.size="获取大小中";const t=await e.downloadInfo();this.size=t.totalSize;h.set(e,this.size)}catch(e){this.size="获取大小失败"}},getFormat(){const e=l.find(e=>e.displayName===this.qualityModel.value);if(!e){console.error(`No format found. model value = ${this.qualityModel.value}`);return null}return e},async exportData(e){if(this.busy===true){return}try{this.busy=true;if(!this.downloadSingle){await this.exportBatchData(e);return}const t=this.getFormat();const s=await t.downloadInfo();s.danmakuOption=this.danmakuModel.value;switch(e){case"copyLink":await s.copyUrl();Toast.success("已复制链接到剪贴板.","下载视频",3e3);break;case"aria2":await s.exportAria2(false);break;case"aria2RPC":await s.exportAria2(true);break;case"copyVLD":await s.exportData(true);Toast.success("已复制VLD数据到剪贴板.","下载视频",3e3);break;case"exportVLD":await s.exportData(false);break;default:break}}catch(e){logError(e)}finally{this.busy=false}},async exportBatchData(e){const i=this.episodeList;if(i.every(e=>e.checked===false)){Toast.info("请至少选择1集或以上的数量!","批量导出",3e3);return}const n=e=>{const t=i.find(t=>t.cid===e.cid);if(t===undefined){return false}return t.checked};const o=this.getFormat();if(this.danmakuModel.value!=="无"){const e=Toast.info("下载弹幕中...","批量导出");const s=new JSZip;try{if(this.danmakuModel.value==="XML"){for(const e of i.filter(n)){const t=new a(e.cid);await t.fetchInfo();s.file(e.title+".xml",t.rawXML)}}else{const{convertToAss:e}=await t.importAsync("download-danmaku");for(const t of i.filter(n)){const i=new a(t.cid);await i.fetchInfo();s.file(t.title+".ass",await e(i.rawXML))}}u.downloadBlob(await s.generateAsync({type:"blob"}),this.cid+".danmakus.zip")}catch(e){logError(`弹幕下载失败`)}finally{e.dismiss()}}const r=Toast.info("获取链接中...","批量导出");this.batchExtractor.itemFilter=n;let l;try{switch(e){case"aria2":l=await this.batchExtractor.collectAria2(o,r);u.downloadBlob(new Blob([l],{type:"text/plain"}),s(false)+".txt");return;case"aria2RPC":await this.batchExtractor.collectAria2(o,r,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);return;case"copyVLD":GM_setClipboard(await this.batchExtractor.collectData(o,r),{mimetype:"text/plain"});Toast.success("已复制批量vld数据到剪贴板.","批量导出",3e3);return;case"exportVLD":l=await this.batchExtractor.collectData(o,r);u.downloadBlob(new Blob([l],{type:"text/json"}),s(false)+".json");return;default:return}}catch(e){logError(e)}finally{r.dismiss()}},async checkBatch(){const e=["/www.bilibili.com/bangumi","/www.bilibili.com/video/av"];if(!e.some(e=>document.URL.includes(e))){this.batch=false;this.episodeList=[];return}const{BatchExtractor:s}=await t.importAsync("batch-download");if(await s.test()!==true){this.batch=false;this.episodeList=[];return}this.batchExtractor=new s;this.batch=true;this.episodeList=(await this.batchExtractor.getItemList()).map((e,t)=>{return{aid:e.aid,cid:e.cid,title:e.title,index:t,checked:true}})},cancelDownload(){if(o){o.cancelDownload()}},async startDownload(){const e=this.getFormat();try{this.downloading=true;const t=await e.downloadInfo();t.videoSpeed.speedUpdate=(e=>this.speed=e);t.danmakuOption=this.danmakuModel.value;t.progress=(e=>{this.progressPercent=Math.trunc(e*100)});o=t;const s=await t.download();const i=document.getElementById("video-complete");i.setAttribute("href",s.url);i.setAttribute("download",s.filename);i.click();Toast.success(`下载完成: ${s.filename} 再次保存`,"下载视频")}catch(e){if(e!=="canceled"){logError(e)}this.progressPercent=0}finally{this.downloading=false;this.speed=""}},selectAllEpisodes(){this.episodeList.forEach(e=>e.checked=true)},unselectAllEpisodes(){this.episodeList.forEach(e=>e.checked=false)},inverseAllEpisodes(){this.episodeList.forEach(e=>e.checked=!e.checked)},toggleRpcSettings(){this.showRpcSettings=!this.showRpcSettings},saveRpcSettings(){if(this.rpcSettings.host===""){this.rpcSettings.host="127.0.0.1"}if(this.rpcSettings.port===""){this.rpcSettings.port="6800"}e.aria2RpcOption=this.rpcSettings}}});Observer.videoChange(async()=>{p.close();p.batch=false;p.downloadSingle=true;const e=dq("#download-video");const t=await w();e.style.display=t?"flex":"none";if(!t){return}p.aid=r.aid;p.cid=r.cid;const s=new i(r.aid);await s.fetchInfo();p.coverUrl=s.coverUrl.replace("http:","https:");l=await d.availableFormats;[c]=l;p.qualityModel={value:c.displayName,items:l.map(e=>e.displayName)};p.formatChange();await p.checkBatch()})}return{widget:{content:`\n `,condition:w,success:f}}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.js"] = (()=>{return(e,t)=>{const{getFriendlyTitle:s}=t.import("title");const{VideoInfo:a,DanmakuInfo:i}=t.import("video-info");class n{constructor(){this.menuClasses=["quality","action","progress"];[this.currentMenuClass]=this.menuClasses}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}closeMenu(){this.menuPanel.classList.remove("opened");setTimeout(()=>this.resetMenuClass(),200)}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=${r.aid}&cid=${r.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${r.aid}&cid=${r.cid}&otype=json`}}}class o extends n{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${r.aid}&cid=${r.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${r.aid}&cid=${r.cid}&qn=&otype=json`}}}const r={entity:new n,aid:"",cid:""};let l=[];let c=null;class d{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new u(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{r.entity.getUrl().then(s=>{const a=new XMLHttpRequest;a.addEventListener("load",()=>{const s=JSON.parse(a.responseText);if(s.code!==0){t("获取清晰度信息失败.");return}const i=s.data||s.result||s;const n=i.accept_quality;const o=i.accept_format.split(",");const r=i.accept_description;const l=[];while(n.length>0){const e=new d(n.pop(),o.pop(),r.pop());l.push(e)}e(l.reverse())});a.addEventListener("error",()=>t(`获取清晰度信息失败.`));a.withCredentials=true;a.open("GET",s);a.send()})})}}class h{constructor(e,t,s,a){this.length=e;this.size=t;this.url=s;this.backupUrls=a}}class u{constructor(e,t){this.fragmentSplitFactor=6*5;this.workingXhr=null;this.progressMap=new Map;this.format=e;this.fragments=t||[];this.videoSpeed=new p(this)}get totalSize(){return this.fragments.map(e=>e.size).reduce((e,t)=>e+t)}fetchVideoInfo(){return new Promise((e,t)=>{r.entity.getUrl(this.format.quality).then(s=>{const a=new XMLHttpRequest;a.addEventListener("load",()=>{const s=JSON.parse(a.responseText.replace(/http:/g,"https:"));const i=s.data||s.result||s;if(i.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const n=i.durl;this.fragments=n.map(e=>new h(e.length,e.size,e.url,e.backup_url));e(this.fragments)});a.withCredentials=true;a.open("GET",s);a.send()})})}updateProgress(){const e=this.progressMap?[...this.progressMap.values()].reduce((e,t)=>e+t,0)/this.totalSize:0;if(e>1||e<0){console.error(`[下载视频] 进度异常: ${e}`,this.progressMap.values())}this.progress&&this.progress(e)}cancelDownload(){this.videoSpeed.stopMeasure();if(this.workingXhr!==null){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const s=16*1024*1024;let a=0;const i=e=>[...this.progressMap.keys()].indexOf(e)+1;while(a{const a=new XMLHttpRequest;a.open("GET",e.url);a.responseType="arraybuffer";a.withCredentials=false;a.addEventListener("progress",e=>{console.log(`[下载视频] 视频片段${i(a)}下载进度: ${e.loaded}/${r} bytes loaded, ${o}`);this.progressMap.set(a,e.loaded);this.updateProgress()});a.addEventListener("load",()=>{if((""+a.status)[0]==="2"){console.log(`[下载视频] 视频片段${i(a)}下载完成`);t(a.response)}else{s(`视频片段${i(a)}请求失败, response = ${a.status}`)}});a.addEventListener("abort",()=>s("canceled"));a.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${i(a)}下载失败: ${o}`);this.progressMap.set(a,0);this.updateProgress();a.open("GET",e.url);a.setRequestHeader("Range",o);a.send()});a.setRequestHeader("Range",o);this.progressMap.set(a,0);a.send();this.workingXhr.push(a)}));a=Math.round(a+s)+1}return Promise.all(t)}async copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}static downloadBlob(e,t){const s=document.createElement("a");let a;if(typeof e==="string"){a=e}else{a=URL.createObjectURL(e)}s.setAttribute("href",a);s.setAttribute("download",t);document.body.appendChild(s);s.click();s.remove();URL.revokeObjectURL(a)}async exportData(e=false){const t=JSON.stringify([{fragments:this.fragments,title:s(),totalSize:this.fragments.map(e=>e.size).reduce((e,t)=>e+t),referer:document.URL.replace(window.location.search,"")}]);if(e){GM_setClipboard(t,"text")}else{const e=new Blob([t],{type:"text/json"});const a=await this.downloadDanmaku();if(a!==null){const t=new JSZip;t.file(`${s()}.json`,e);t.file(s()+"."+this.danmakuOption.toLowerCase(),a);u.downloadBlob(await t.generateAsync({type:"blob"}),`${s()}.zip`)}else{u.downloadBlob(e,`${s()}.json`)}}}async exportAria2(a=false){if(a){const a=await this.downloadDanmaku();if(a!==null){u.downloadBlob(new Blob([a]),`${s()}.${this.danmakuOption==="ASS"?"ass":"xml"}`)}const i=e.aria2RpcOption;const n=this.fragments.map((e,t)=>{let a="";if(this.fragments.length>1){a=" - "+(t+1)}const n=[];if(i.secretKey!==""){n.push(`token:${i.secretKey}`)}n.push([e.url]);n.push({referer:document.URL.replace(window.location.search,""),"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0",out:`${s()}${a}${this.extension(e)}`,split:this.fragmentSplitFactor,dir:i.dir||undefined,"max-download-limit":i.maxDownloadLimit||undefined});const o=encodeURIComponent(`${s()}${a}`);return{params:n,id:o}});const{sendRpc:o}=await t.importAsync("aria2-rpc");await o(n)}else{const e=`\n# Generated by Bilibili Evolved Video Export\n# https://github.com/the1812/Bilibili-Evolved/\n${this.fragments.map((e,t)=>{let a="";if(this.fragments.length>1){a=" - "+(t+1)}return`\n${e.url}\n referer=${document.URL.replace(window.location.search,"")}\n user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0\n out=${s()}${a}${this.extension(e)}\n split=${this.fragmentSplitFactor}\n `.trim()}).join("\n")}\n `.trim();const t=new Blob([e],{type:"text/plain"});const a=await this.downloadDanmaku();if(a!==null){const e=new JSZip;e.file(`${s()}.txt`,t);e.file(s()+"."+this.danmakuOption.toLowerCase(),a);u.downloadBlob(await e.generateAsync({type:"blob"}),`${s()}.zip`)}else{u.downloadBlob(t,`${s()}.txt`)}}}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=dq("a#video-complete").getAttribute("href");if(e&&!dq(`.link[href="${e}"]`)){URL.revokeObjectURL(e)}dqa(".toast-card-header").filter(e=>e.innerText.includes("下载视频")).forEach(e=>e.querySelector(".toast-card-dismiss").click())}async downloadDanmaku(){if(this.danmakuOption!=="无"){const e=new i(r.cid);await e.fetchInfo();if(this.danmakuOption==="XML"){return e.rawXML}else{const{convertToAss:s}=await t.importAsync("download-danmaku");return s(e.rawXML)}}else{return null}}async downloadSingle(e){const t=await this.downloadDanmaku();const[a]=e;if(t===null){const e=this.makeBlob(a);const t=s()+this.extension();return{blob:e,filename:t}}else{const e=new JSZip;e.file(s()+this.extension(),this.makeBlob(a));e.file(s()+"."+this.danmakuOption.toLowerCase(),t);const i=await e.generateAsync({type:"blob"});const n=s()+".zip";return{blob:i,filename:n}}}async downloadMultiple(e){const t=new JSZip;const a=s();if(e.length>1){e.forEach((e,s)=>{const i=this.fragments[s];t.file(`${a} - ${s+1}${this.extension(i)}`,this.makeBlob(e,i))})}else{const[s]=e;t.file(`${a}${this.extension()}`,this.makeBlob(s))}const i=await this.downloadDanmaku();if(i!==null){t.file(s()+"."+this.danmakuOption.toLowerCase(),i)}const n=await t.generateAsync({type:"blob"});const o=a+".zip";return{blob:n,filename:o}}async download(){const e=[];this.videoSpeed.startMeasure();for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let{blob:t,filename:s}=await(async()=>{if(e.length===1){return await this.downloadSingle(e)}else{return await this.downloadMultiple(e)}})();this.cleanUpOldBlobUrl();const a=URL.createObjectURL(t);this.progress&&this.progress(0);this.videoSpeed.stopMeasure();return{url:a,filename:s}}}class p{constructor(e){this.lastProgress=0;this.measureInterval=1e3;this.workingDownloader=e}startMeasure(){this.intervalTimer=setInterval(()=>{const e=this.workingDownloader.progressMap?[...this.workingDownloader.progressMap.values()].reduce((e,t)=>e+t,0):0;const t=e-this.lastProgress;if(this.speedUpdate!==undefined){this.speedUpdate(formatFileSize(t)+"/s")}this.lastProgress=e},this.measureInterval)}stopMeasure(){clearInterval(this.intervalTimer)}}async function w(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);if(!(e&&t)){return false}r.aid=e;r.cid=t;if(document.URL.indexOf("bangumi")!==-1){r.entity=new o}else{r.entity=new n}try{l=await d.availableFormats}catch(e){return false}return true}async function f(){c=l[0];t.applyStyle("downloadVideoStyle");dq("#download-video").addEventListener("click",()=>{dq(".download-video").classList.toggle("opened");dq(".gui-settings-mask").click()});dq("#download-video").addEventListener("mouseover",()=>{document.body.insertAdjacentHTML("beforeend",t.import("downloadVideoHtml"));m()},{once:true})}async function m(){const n=await t.importAsync("v-dropdown.vue");const o=await t.importAsync("v-checkbox.vue");let h;const p=new Map;const f=new Vue({el:".download-video",components:{"v-dropdown":n,"v-checkbox":o},data:{downloadSingle:true,coverUrl:'data:image/svg+xml;utf-8,',aid:r.aid,cid:r.cid,qualityModel:{value:c.displayName,items:l.map(e=>e.displayName)},danmakuModel:{value:e.downloadVideoDefaultDanmaku,items:["无","XML","ASS"]},progressPercent:0,size:"获取大小中",blobUrl:"",episodeList:[],downloading:false,speed:"",batch:false,rpcSettings:e.aria2RpcOption,showRpcSettings:false,busy:false},computed:{displaySize(){if(typeof this.size==="string"){return this.size}return formatFileSize(this.size)},sizeWarning(){if(typeof this.size==="string"){return false}return this.size>1073741824},selectedEpisodeCount(){return this.episodeList.filter(e=>e.checked).length}},methods:{close(){this.$el.classList.remove("opened")},danmakuOptionChange(){e.downloadVideoDefaultDanmaku=this.danmakuModel.value},async formatChange(){const e=this.getFormat();const t=p.get(e);if(t){this.size=t;return}try{this.size="获取大小中";const t=await e.downloadInfo();this.size=t.totalSize;p.set(e,this.size)}catch(e){this.size="获取大小失败"}},getFormat(){const e=l.find(e=>e.displayName===this.qualityModel.value);if(!e){console.error(`No format found. model value = ${this.qualityModel.value}`);return null}return e},async exportData(e){if(this.busy===true){return}try{this.busy=true;if(!this.downloadSingle){await this.exportBatchData(e);return}const t=this.getFormat();const s=await t.downloadInfo();s.danmakuOption=this.danmakuModel.value;switch(e){case"copyLink":await s.copyUrl();Toast.success("已复制链接到剪贴板.","下载视频",3e3);break;case"aria2":await s.exportAria2(false);break;case"aria2RPC":await s.exportAria2(true);break;case"copyVLD":await s.exportData(true);Toast.success("已复制VLD数据到剪贴板.","下载视频",3e3);break;case"exportVLD":await s.exportData(false);break;default:break}}catch(e){logError(e)}finally{this.busy=false}},async exportBatchData(e){const a=this.episodeList;if(a.every(e=>e.checked===false)){Toast.info("请至少选择1集或以上的数量!","批量导出",3e3);return}const n=e=>{const t=a.find(t=>t.cid===e.cid);if(t===undefined){return false}return t.checked};const o=this.getFormat();if(this.danmakuModel.value!=="无"){const e=Toast.info("下载弹幕中...","批量导出");const s=new JSZip;try{if(this.danmakuModel.value==="XML"){for(const e of a.filter(n)){const t=new i(e.cid);await t.fetchInfo();s.file(e.title+".xml",t.rawXML)}}else{const{convertToAss:e}=await t.importAsync("download-danmaku");for(const t of a.filter(n)){const a=new i(t.cid);await a.fetchInfo();s.file(t.title+".ass",await e(a.rawXML))}}u.downloadBlob(await s.generateAsync({type:"blob"}),this.cid+".danmakus.zip")}catch(e){logError(`弹幕下载失败`)}finally{e.dismiss()}}const r=Toast.info("获取链接中...","批量导出");this.batchExtractor.itemFilter=n;let l;try{switch(e){case"aria2":l=await this.batchExtractor.collectAria2(o,r);u.downloadBlob(new Blob([l],{type:"text/plain"}),s(false)+".txt");return;case"aria2RPC":await this.batchExtractor.collectAria2(o,r,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);return;case"copyVLD":GM_setClipboard(await this.batchExtractor.collectData(o,r),{mimetype:"text/plain"});Toast.success("已复制批量vld数据到剪贴板.","批量导出",3e3);return;case"exportVLD":l=await this.batchExtractor.collectData(o,r);u.downloadBlob(new Blob([l],{type:"text/json"}),s(false)+".json");return;default:return}}catch(e){logError(e)}finally{r.dismiss()}},async checkBatch(){const e=["/www.bilibili.com/bangumi","/www.bilibili.com/video/av"];if(!e.some(e=>document.URL.includes(e))){this.batch=false;this.episodeList=[];return}const{BatchExtractor:s}=await t.importAsync("batch-download");if(await s.test()!==true){this.batch=false;this.episodeList=[];return}this.batchExtractor=new s;this.batch=true;this.episodeList=(await this.batchExtractor.getItemList()).map((e,t)=>{return{aid:e.aid,cid:e.cid,title:e.title,index:t,checked:true}})},cancelDownload(){if(h){h.cancelDownload()}},async startDownload(){const e=this.getFormat();try{this.downloading=true;const t=await e.downloadInfo();t.videoSpeed.speedUpdate=(e=>this.speed=e);t.danmakuOption=this.danmakuModel.value;t.progress=(e=>{this.progressPercent=Math.trunc(e*100)});h=t;const s=await t.download();const a=document.getElementById("video-complete");a.setAttribute("href",s.url);a.setAttribute("download",s.filename);a.click();Toast.success(`下载完成: ${s.filename} 再次保存`,"下载视频")}catch(e){if(e!=="canceled"){logError(e)}this.progressPercent=0}finally{this.downloading=false;this.speed=""}},selectAllEpisodes(){this.episodeList.forEach(e=>e.checked=true)},unselectAllEpisodes(){this.episodeList.forEach(e=>e.checked=false)},inverseAllEpisodes(){this.episodeList.forEach(e=>e.checked=!e.checked)},toggleRpcSettings(){this.showRpcSettings=!this.showRpcSettings},saveRpcSettings(){if(this.rpcSettings.host===""){this.rpcSettings.host="127.0.0.1"}if(this.rpcSettings.port===""){this.rpcSettings.port="6800"}e.aria2RpcOption=this.rpcSettings}}});Observer.videoChange(async()=>{f.close();f.batch=false;f.downloadSingle=true;const e=dq("#download-video");const t=await w();e.style.display=t?"flex":"none";if(!t){return}f.aid=r.aid;f.cid=r.cid;const s=new a(r.aid);await s.fetchInfo();f.coverUrl=s.coverUrl.replace("http:","https:");l=await d.availableFormats;[c]=l;f.qualityModel={value:c.displayName,items:l.map(e=>e.displayName)};f.formatChange();await f.checkBatch()})}return{widget:{content:`\n `,condition:w,success:f}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-danmaku.min.js"] = (()=>{return(e,a)=>{if(typeof isEmbeddedPlayer!=="undefined"&&isEmbeddedPlayer()){return}Observer.videoChange(async()=>{const e=await SpinQuery.select(".bui-collapse-wrap");if(e&&e.classList.contains("bui-collapse-wrap-folded")){const e=await SpinQuery.select(".bui-collapse-header");e.click()}})}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-description.min.css"] = `.play-up-info .play-up-self,.video-desc .info{height:auto!important}.play-up-info .play-up-self-btn,.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")}})(); @@ -1066,7 +1066,8 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-player.min.css"] = `.touch-video-box-wrapper{display:flex;align-items:center;justify-content:center;width:100%;height:100%;position:absolute;top:0;left:0;z-index:14;pointer-events:none}.touch-video-box{display:flex;align-items:center;justify-content:center;width:100%;height:100%;background:rgba(0,0,0,.85);position:relative;max-width:520px;max-height:240px;border:4px solid transparent;transform-origin:center}.round-corner .touch-video-box{border-radius:var(--corner-radius)}.touch-video-box-wrapper.simple{align-items:flex-start}.touch-video-box.animation{transition:.2s cubic-bezier(.18,.89,.32,1.28)}.touch-video-info{color:#fff;font-size:2rem;text-align:center;display:flex;align-items:center;justify-content:center;flex-direction:column;height:100%;width:100%}.touch-row{flex-grow:1;display:flex;align-items:center;justify-content:center;width:100%}.touch-info{display:block;color:var(--theme-color)}.touch-result{display:block;font-size:1.5rem;line-height:150%}.touch-speed{display:block;background:rgba(0,0,0,.1);padding:.5em}.touch-progress{position:absolute;bottom:0;left:0;background:var(--theme-color);width:0;height:4px}.round-corner .touch-progress{border-radius:2px}.touch-row-item{flex:1 0 0;display:none;align-items:center;justify-content:center}.touch-row-item-wide{flex:1.5 0 0;display:flex;align-items:center;justify-content:center}.videoshot{background-color:transparent;background-image:none;transform-origin:center;transform:scale(.9)}.adjust-closed{opacity:0;transform:scale(.9)}.adjust-opened{opacity:1;transform:scale(1)}.touch-video-info.speed .touch-row-item{display:flex}.touch-video-info.cancel .touch-progress,.touch-video-info.cancel .touch-result{opacity:0}.disable-original-hover .bilibili-player-video-control-bottom,.disable-original-hover .bilibili-player-video-control-mask{opacity:0!important;visibility:hidden!important}.disable-original-hover .bilibili-player-video-control-wrap,.disable-original-hover.touch-video-control-show .bilibili-player-video-control-bottom,.disable-original-hover.touch-video-control-show .bilibili-player-video-control-mask{opacity:1!important;visibility:visible!important}.bilibili-player-video-control-top,.disable-original-hover .bilibili-player-video-control-top{left:0!important;right:0!important;bottom:0!important}.bilibili-player-video-control-top,.bilibili-player-video-progress-detail{bottom:0!important}.disable-original-hover.touch-video-control-show .bilibili-player-video-control-top{left:0!important;right:0!important;bottom:38px!important}div.bilibili-player-video-control{height:38px!important;align-items:center!important}.bilibili-player-video-btn{flex-grow:1!important;height:100%!important;display:flex!important;align-items:center!important;justify-content:center!important}.bilibili-player-video-inputbar,.bilibili-player-video-progress{flex-grow:30!important}.bilibili-player-video-quality-menu{display:flex!important;align-items:center!important;justify-content:center!important}.bilibili-player-iconfont-color,.bilibili-player-iconfont-danmaku,.bilibili-player-iconfont-danmaku-off,.bilibili-player-iconfont-fullscreen,.bilibili-player-iconfont-pause,.bilibili-player-iconfont-repeat,.bilibili-player-iconfont-setting,.bilibili-player-iconfont-start,.bilibili-player-iconfont-volume,.bilibili-player-iconfont-volume-max,.bilibili-player-iconfont-volume-min,.bilibili-player-iconfont-web-fullscreen,.bilibili-player-iconfont-widescreen{font-size:2.5rem!important}.bilibili-player-iconfont-next{font-size:2rem!important}.bilibili-player-video-btn-setting-panel,.bilibili-player-video-danmaku-setting-wrap,.bilibili-player.mode-fullscreen .bilibili-player-video-sendbar,.bpui-selectmenu-list{left:unset!important;bottom:38px!important}.bilibili-player-video-volumebar-wrp{left:unset!important}.bilibili-player-video-control-wrap{padding:0!important}.bilibili-player-video-control-bottom{padding:0!important;align-items:center!important}.bilibili-player-iconfont-next,.bilibili-player-iconfont-setting,.bilibili-player-video-btn-volume.video-state-volume-max .bilibili-player-iconfont-volume-max,.bilibili-player-video-btn-volume.video-state-volume-min .bilibili-player-iconfont-volume-min,.bilibili-player-video-btn-volume:not(.video-state-volume-max):not(.video-state-volume-min) .bilibili-player-iconfont-volume,.bilibili-player-video-control-bottom-left{display:flex!important;align-items:center!important}.bilibili-player-video-btn-danmaku{flex-grow:0!important;display:flex!important;align-items:center!important;height:100%!important;margin:0!important;padding:0!important}.bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-right{flex-grow:1!important}.bilibili-player.mode-fullscreen .bilibili-player-video-sendbar{bottom:0!important}.bilibili-player .bilibili-player-area .bilibili-player-video-control .bilibili-player-video-btn.bilibili-player-video-btn-fullscreen{margin-right:0!important;padding-right:8px!important}.bilibili-player .bilibili-player-area .bilibili-player-video-control .bilibili-player-video-btn.bilibili-player-video-btn-start{padding-left:8px!important;flex-grow:1.2!important;margin-right:0!important;margin-left:0!important}.bilibili-player .bilibili-player-area .bilibili-player-video-control .bilibili-player-video-btn{padding:0 3px!important}.bilibili-player .bilibili-player-area .bilibili-player-video-control-bottom,.bilibili-player .bilibili-player-area .bilibili-player-video-control-bottom-right,.bilibili-player-video-control-bottom-left{height:100%!important;margin:0!important}.bilibili-player-video-btn-setting-panel-hover-bridge{display:none!important}.disable-original-hover .bilibili-player-video-control-wrap:hover .bilibili-player-video-control-top .bilibili-player-video-progress-slider,.disable-original-hover.bilibili-player-area.video-control-show .bilibili-player-video-control-top .bilibili-player-video-progress-slider{height:2px!important}.disable-original-hover.bilibili-player-area .bilibili-player-video-control .bilibili-player-video-progress-detail.show{bottom:1px!important}.disable-original-hover.bilibili-player-area .subtitle-position.subtitle-position-bc,.disable-original-hover.bilibili-player-area .subtitle-position.subtitle-position-bl,.disable-original-hover.bilibili-player-area .subtitle-position.subtitle-position-br{bottom:20px!important}.disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-bc,.disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-bl,.disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-br{bottom:44px!important}.bilibili-player.mode-fullscreen .disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-bc,.bilibili-player.mode-fullscreen .disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-bl,.bilibili-player.mode-fullscreen .disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-br,.bilibili-player.mode-webfullscreen .disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-bc,.bilibili-player.mode-webfullscreen .disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-bl,.bilibili-player.mode-webfullscreen .disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-br{bottom:60px!important}.bilibili-player .bilibili-player-area:not(.disable-original-hover) .bilibili-player-video-control-wrap:hover .bilibili-player-video-control-top .bilibili-player-video-progress-slider,.bilibili-player .bilibili-player-area:not(.disable-original-hover).video-control-show .bilibili-player-video-control-top .bilibili-player-video-progress-slider{height:74px!important}.bilibili-player.mode-fullscreen .disable-original-hover .bilibili-player-video-control-top{opacity:1!important}#bofqi *{-webkit-tap-highlight-color:transparent!important}@media screen and (min-width:750px){.bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-center .bilibili-player-video-sendbar .bilibili-player-video-inputbar,.bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-center .bilibili-player-video-sendbar .bilibili-player-video-inputbar{background:#fff1!important}.bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control,.bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control{height:100%!important;margin:0!important}.bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom,.bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom{margin:0!important}.bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-left,.bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-left{height:100%!important}.bilibili-player-video-btn.bilibili-player-video-btn-start{flex-grow:.5!important}.player .bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-top,.player .bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-top{left:0!important;right:0!important}.player .bilibili-player.mode-fullscreen .disable-original-hover.bilibili-player-video-control-wrap .bilibili-player-video-control-top,.player .bilibili-player.mode-webfullscreen .disable-original-hover.bilibili-player-video-control-wrap .bilibili-player-video-control-top{left:0!important;right:0!important;bottom:0!important}.player .bilibili-player.mode-fullscreen .disable-original-hover.touch-video-control-show .bilibili-player-video-control-top,.player .bilibili-player.mode-webfullscreen .disable-original-hover.touch-video-control-show .bilibili-player-video-control-top{left:0!important;right:0!important;bottom:54px!important}.mode-fullscreen .bilibili-player-area.mouse-hover:not(.disable-original-hover) .bilibili-player-video-control-top,.mode-fullscreen .bilibili-player-area.video-control-show:not(.disable-original-hover) .bilibili-player-video-control-top,.mode-webfullscreen .bilibili-player-area.mouse-hover:not(.disable-original-hover) .bilibili-player-video-control-top,.mode-webfullscreen .bilibili-player-area.video-control-show:not(.disable-original-hover) .bilibili-player-video-control-top{left:0!important;right:0!important;bottom:48px!important}}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-player.min.js"] = (()=>{return(t,e)=>{const i=t=>{let e=0;let i=0;while(t&&!isNaN(t.offsetLeft)&&!isNaN(t.offsetTop)){e+=t.offsetLeft-t.scrollLeft;i+=t.offsetTop-t.scrollTop;t=t.offsetParent}return{x:e,y:i}};const s=t=>{t=Math.abs(t);const e=Math.floor(t/3600);const i=Math.floor((t-e*3600)/60);const s=t-e*3600-i*60;let o=fixed(s)+"秒";if(i>0){o=i+"分"+o}if(e>0){o=e+"时"+o}return o};const o=t=>{t=Math.abs(t);const e=Math.floor(t/3600);const i=Math.floor((t-e*3600)/60);const s=t-e*3600-i*60;let o=(s<10?"0":"")+fixed(s);o=(i<10?"0":"")+i+":"+o;o=(e<10?"0":"")+e+":"+o;return o};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",e=>{if(!this.xDown||!this.yDown){return}const s=e.touches[0].clientX;const o=e.touches[0].clientY;const n=i(t);const l={x:(e.touches[0].pageX-n.x)/t.clientWidth,y:(e.touches[0].pageY-n.y)/t.clientHeight,width:t.clientWidth,height:t.clientHeight};const a=this.xDown-s;const c=this.yDown-o;if(!this.direction){let t="";if(Math.abs(a)>Math.abs(c)){t="horizontal"}else{t="vertical"}this.direction=t}else{if(this.direction==="vertical"){this.action.startAction(this.direction,c,l)}else if(this.direction==="horizontal"){this.action.startAction(this.direction,-a,l)}}if(e.cancelable){e.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.volumeUp=null;this.volumeDown=null;this.brightnessUp=null;this.brightnessDown=null;this.speedCancel=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",()=>{this.touchStart=true});t.addEventListener("touchend",()=>{this.startPosition=null;this.onActionEnd&&this.onActionEnd(this.lastAction);this.lastAction=null})}startAction(t,e,i){if(this.touchStart){this.onActionStart&&this.onActionStart(t);this.startPosition=i;this.touchStart=false}if(t==="vertical"){let t;let s;if(this.startPosition.x<1/2){t=this.brightnessUp;s=this.brightnessDown;const o=Math.round(200*(e-this.minSwipeDistance)/(1.5*i.height));if(e>0){t&&t(o)}else{s&&s(o)}this.lastAction={type:"brightness",brightness:o}}else{t=this.volumeUp;s=this.volumeDown;const o=Math.round(200*(e-this.minSwipeDistance)/(1.5*i.height));if(e>0){t&&t(o)}else{s&&s(o)}this.lastAction={type:"volume",volume:o}}}else if(t==="horizontal"){if(i.y<1/3&&(i.x<.1||i.x>.9)){this.speedCancel&&this.speedCancel();this.lastAction=null}else{let t=0;let i;let s;if(this.startPosition.y<1/3){t=.05;i=this.lowSpeedForward;s=this.lowSpeedBackward}else if(this.startPosition.y>=1/3&&this.startPosition.y<=2/3){t=.2;i=this.mediumSpeedForward;s=this.mediumSpeedBackward}else{t=1;i=this.highSpeedForward;s=this.highSpeedBackward}if(e>0){const s=(e-this.minSwipeDistance)*t;i&&i(s);this.lastAction={type:"playback",seconds:s}}else{const i=(e+this.minSwipeDistance)*t;s&&s(i);this.lastAction={type:"playback",seconds:i}}}}}}class a{constructor(){this.aid=unsafeWindow.aid;this.cid=unsafeWindow.cid;this.cidData=null;this.supportWebp=a.supportWebp}getVideoshot(t,e){if(!(this.aid&&this.cid)){return}if(!this.cidData){Ajax.getText(`https://api.bilibili.com/x/player/videoshot?aid=${this.aid}&cid=${this.cid}&index=1`).then(i=>{this.cidData=JSON.parse(i).data;this.getVideoshot(t,e)})}else{const i=this.cidData;const s=i.index;let o=0;for(let e=0;e=s[e]&&tt.replace(".jpg",".jpg@.webp"))}const l=parseInt(i.pv_x_len)||10;const a=parseInt(i.pv_y_len)||10;const c=parseInt(i.pv_x_size)||160;const r=parseInt(i.pv_y_size)||90;const h=-(o%100%l)*c;const d=-Math.floor(o%100/a)*r;e({width:c,height:r,backgroundImage:`url(${n[Math.floor(o/100)]})`,backgroundPosition:`${h}px ${d}px`})}}static get supportWebp(){try{const t=document.createElement("canvas");if(t.getContext&&t.getContext("2d")){try{return t.toDataURL("image/webp").indexOf("data:image/webp")===0}catch(t){return false}}else{return false}}catch(t){return false}}}function c(t){t.unbind("click")}function r(t){if($(".touch-video-box").length!==0){return}$(".bilibili-player-video-subtitle").before(`\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
`);let e=$("video");const i=e.prop("duration");const l=new n(t.get(0));const c=document.querySelector(".touch-video-info");const r=document.querySelector(".touch-video-box");let h=100;let d=Math.round(e.prop("volume")*100);const u=t=>{t/=100;if(t<0){t=0}else if(t>1){t=1}e.prop("volume",t);$(".bilibili-player-video-volume-num").text(Math.round(t*100));$(".bui-thumb").css("transform",`translateY(-${48*t}px)`);$(".bui-track-vertical .bui-bar").css("transform",`scaleY(${t})`);if(t===0){$(".bilibili-player-video-btn-volume").addClass("video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-max");e.prop("muted",true)}else if(t===1){$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-min");$(".bilibili-player-video-btn-volume").addClass("video-state-volume-max");e.prop("muted",false)}else{$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-max");e.prop("muted",false)}};l.action.onActionStart=(t=>{r.classList.add("adjust-opened");c.classList[t==="vertical"?"remove":"add"]("speed");e=$("video");d=Math.round(e.prop("volume")*100);const i=e.css("filter").match(/brightness\((.+)\)/);h=Math.trunc((i?i[1]:1)*100)});const p=new a;const v=t=>{return n=>{const l=e.prop("currentTime");const a=fixed(100*l/i);let r=l+n;let h=fixed(100*r/i);let d=n;if(r>i){r=i;h=100;d=i-l}else if(r<0){r=0;h=0;d=l}const u=`${o(l)} (${a}%)
👇
${o(r)} (${h}%)`;c.classList.remove("cancel");c.querySelector(".touch-speed").innerHTML=`${t}速`;c.querySelector(".touch-info").innerHTML=`进度: ${n>0?"+":"-"}${s(d)}`;c.querySelector(".touch-result").innerHTML=u;p.getVideoshot(r,t=>$(".videoshot").css(t));$(".touch-progress").css("width",`${h}%`)}};l.action.lowSpeedBackward=v("低");l.action.lowSpeedForward=v("低");l.action.mediumSpeedBackward=v("中");l.action.mediumSpeedForward=v("中");l.action.highSpeedBackward=v("高");l.action.highSpeedForward=v("高");const f=t=>{let e=d+t;let i=Math.abs(t);if(e>100){e=100;i=100-d}else if(e<0){e=0;i=d}const s=`${d} 👉 ${e}`;u(e);c.classList.remove("cancel");c.querySelector(".touch-info").innerHTML=`音量: ${t>0?"+":"-"}${i}`;c.querySelector(".touch-result").innerHTML=s;$(".touch-progress").css("width",`${e}%`)};l.action.volumeUp=f;l.action.volumeDown=f;const b=t=>{let i=h+t;let s=Math.abs(t);if(i>100){i=100;s=100-h}else if(i<0){i=0;s=h}const o=`${h} 👉 ${i}`;e.css("filter",`brightness(${i/100})`);c.classList.remove("cancel");c.querySelector(".touch-info").innerHTML=`亮度: ${t>0?"+":"-"}${s}`;c.querySelector(".touch-result").innerHTML=o;$(".touch-progress").css("width",`${i}%`)};l.action.brightnessUp=b;l.action.brightnessDown=b;l.action.speedCancel=(()=>{c.querySelector(".touch-info").innerHTML=`取消时间调整`;c.classList.add("cancel")});l.action.onActionEnd=(t=>{if(!unsafeWindow.touchPlayerDebug){if(t){if(t.type==="playback"){let s=e.prop("currentTime");s+=t.seconds;if(s<0){s=0}else if(s>i){s=i}e.prop("currentTime",s)}else if(t.type==="volume"){const t=JSON.parse(localStorage.bilibili_player_settings);t.video_status.volume=e.prop("volume");localStorage.bilibili_player_settings=JSON.stringify(t)}}r.classList.remove("adjust-opened")}})}function h(t){if(!t.hasClass("disable-original-hover")){t.addClass("disable-original-hover");const e=unsafeWindow.$(".bilibili-player-video");const i="touch-video-control-show";const s=e.data("events").click[0].handler;const o=new DoubleClickEvent(t=>s(t),()=>t.toggleClass(i));e.unbind("click");o.bind(e[0])}}const d=()=>{SpinQuery.any(()=>$(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),c);SpinQuery.condition(()=>$(".bilibili-player-video"),t=>t.length>0&&$("video").length>0&&$("video").prop("duration"),r);if(t.touchVideoPlayerDoubleTapControl){new SpinQuery(()=>$(".bilibili-player-area"),t=>t.length>0&&unsafeWindow.$&&unsafeWindow.$(".bilibili-player-video").data("events"),h).start()}};Observer.videoChange(d);e.applyStyle("touchPlayerStyle")}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/tweets.min.css"] = `.nav-search-submit{display:block!important;color:var(--foreground-color-d)!important;transform:translateX(-125px);-webkit-tap-highlight-color:transparent}.nav-search-submit:hover{color:var(--foreground-color)!important}#nav_searchform{transition:.3s ease-out;box-shadow:none;width:0!important;padding:0!important}.preserve-rank>a{opacity:0!important;pointer-events:none}.showSearch .preserve-rank>a{opacity:.382!important;pointer-events:initial}.showSearch #nav_searchform{box-shadow:0 2px 10px 1px #0002;width:250px!important}.showSearch .nav-search-submit,.showSearch .nav-search-submit:hover{color:#888!important;transform:none}@media only screen and (max-width:1291px){.showSearch #nav_searchform{width:140px!important}}`; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/v-dropdown.vue.min.js"] = (()=>{return(o,e)=>{const n=`
{{ value }}
`;e.applyStyleFromText(`.v-dropdown{position:relative;background-color:#8884;cursor:pointer;display:flex;align-items:center;justify-content:space-between;min-width:100px}.v-dropdown .dropdown-menu{transform-origin:top;transform:scaleY(0) translateX(-50%);position:absolute;top:calc(100% + 2px);left:50%;background-color:var(--download-video-background);z-index:1;transition:.2s cubic-bezier(.6,-.28,.74,.05);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0}.v-dropdown .dropdown-menu.opened{transform:scaleY(1) translateX(-50%);transition-timing-function:cubic-bezier(.18,.89,.32,1.28)}.v-dropdown .dropdown-menu li{padding:4px 8px;white-space:nowrap;min-width:80px;text-align:center;cursor:pointer;color:var(--download-video-foreground);background-color:transparent}.v-dropdown .dropdown-menu li:hover{background-color:rgba(0,0,0,.16)}.v-dropdown .mdi-chevron-down{font-size:16pt;line-height:1;transform:rotate(0)}.v-dropdown .dropdown-menu.opened~.mdi-chevron-down{transform:rotate(180deg)}.v-dropdown .selected{user-select:none;padding:4px 8px}`,"v-dropdown-style");return{export:Object.assign({template:n},{props:["items","value"],data(){return{dropdownOpen:false}},methods:{toggleDropdown(){this.dropdownOpen=!this.dropdownOpen},select(o){this.$emit("update:value",o);this.$emit("change",o)}}})}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/v-checkbox.vue.min.js"] = (()=>{return(e,c)=>{const i=`
{{title}}
`;c.applyStyleFromText(`.v-checkbox{font-size:10pt;cursor:pointer;display:flex;align-items:center}.v-checkbox .mdi{font-size:15pt;line-height:1}.v-checkbox .content{flex-grow:1;text-align:left;padding:0 8px}.v-checkbox .mdi-checkbox-marked-circle{color:var(--theme-color);position:absolute;top:0;left:0;transform:scale(0);transition-timing-function:cubic-bezier(.6,-.28,.74,.05)}.v-checkbox .mdi-checkbox-blank-circle-outline{color:#8884;position:relative}.v-checkbox.checked .mdi-checkbox-blank-circle-outline{color:var(--theme-color)}.v-checkbox.checked .mdi-checkbox-marked-circle{transform:scale(1);transition-timing-function:cubic-bezier(.18,.89,.32,1.28)}`,"v-checkbox-style");return{export:Object.assign({template:i},{props:["checked","title"],methods:{toggleCheck(){this.$emit("update:checked",!this.checked)}}})}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/v-dropdown.vue.min.js"] = (()=>{return(o,e)=>{const n=`
{{ value }}
`;e.applyStyleFromText(`.v-dropdown{position:relative;background-color:#8884;cursor:pointer;display:flex;align-items:center;justify-content:space-between;min-width:100px}.v-dropdown .dropdown-menu{transform-origin:top;transform:scaleY(0) translateX(-50%);position:absolute;top:calc(100% + 2px);left:50%;background-color:var(--download-video-background);z-index:1;transition:.2s cubic-bezier(.6,-.28,.74,.05);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0}.v-dropdown .dropdown-menu.opened{transform:scaleY(1) translateX(-50%);transition-timing-function:cubic-bezier(.18,.89,.32,1.28)}.v-dropdown .dropdown-menu li{padding:4px 8px;white-space:nowrap;min-width:80px;text-align:center;cursor:pointer;color:var(--download-video-foreground);background-color:transparent}.v-dropdown .dropdown-menu li:hover{background-color:rgba(0,0,0,.16)}.v-dropdown .mdi-chevron-down{font-size:16pt;line-height:1;transform:rotate(0)}.v-dropdown .dropdown-menu.opened~.mdi-chevron-down{transform:rotate(180deg)}.v-dropdown .selected{user-select:none;padding:4px 8px}.round-corner .v-dropdown,.round-corner .v-dropdown .dropdown-menu,.round-corner .v-dropdown .dropdown-menu li{border-radius:var(--corner-radius)}`,"v-dropdown-style");return{export:Object.assign({template:n},{props:["items","value"],data(){return{dropdownOpen:false}},methods:{toggleDropdown(){this.dropdownOpen=!this.dropdownOpen},select(o){this.$emit("update:value",o);this.$emit("change",o)}}})}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/video-info.min.js"] = (()=>{return(t,i)=>{class e{constructor(t){this.aid=t}async fetchInfo(){const t=JSON.parse(await Ajax.getText(`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 s(this.cid.toString());return this.danmaku.fetchInfo()}}class a{constructor(t,i){this.text=t;this.p=i}}class s{constructor(t){this.cid=t}async fetchInfo(){const t=await Ajax.getText(`https://api.bilibili.com/x/v1/dm/list.so?oid=${this.cid}`);this.rawXML=t;const i=(new DOMParser).parseFromString(t,"application/xml").documentElement;this.xml=i;this.danmakus=[...i.querySelectorAll("d[p]")].map(t=>{return new a(t.innerHTML,t.getAttribute("p"))})}}class n{constructor(t){this.ep=t;this.videos=[]}async fetchInfo(){const t=await Ajax.getText(`https://www.bilibili.com/bangumi/play/ep${this.ep}/`);const i=JSON.parse(t.match(/window\.__INITIAL_STATE__=(.*);\(function\(\){/)[1]);this.title=i.mediaInfo.title;this.cover=i.mediaInfo.cover;this.squareCover=i.mediaInfo.square_cover;this.aid=i.epInfo.aid;this.cid=i.epInfo.cid;this.videos=i.epList.map(async t=>{return{title:t.index_title,aid:t.aid,cid:t.cid,info:await new e(t.aid).fetchInfo()}});return this}}return{export:{VideoInfo:e,BangumiInfo:n,Danmaku:a,DanmakuInfo:s}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/video-story.min.js"] = (()=>{return(t,i)=>{class e{constructor(t){this.title=t.option;this.nodeID=t.node_id;this.cid=t.cid;this.default=t.is_default===1}}class s{constructor(t,i,e){this.title=t.title;this.nodeID=t.node_id;this.aid=i;this.cid=t.cid;this.graphVersion=e;this.choices=[];this.choiceTime=-1}async getChoices(){if(this.choices.length>0){return}const t=`https://api.bilibili.com/x/stein/nodeinfo?aid=${this.aid}&node_id=${this.nodeID}&graph_version=504`;const i=await Ajax.getJsonWithCredentials(t);if(i.code!==0){console.error(`获取选项失败: ${i.message}`);return}this.choices=i.data.edges.choices.map(t=>new e(t))}}class o{constructor(t,i){this.nodeList=t;if(i){this.startingNode=i}else{[this.startingNode]=t}}async getAllChoices(){return await Promise.all(this.nodeList.map(t=>t.getChoices()))}}const n=async(t,i)=>{const n=`https://api.bilibili.com/x/stein/nodeinfo?aid=${t}&graph_version=${i}`;const c=await Ajax.getJsonWithCredentials(n);if(c.code!==0){return c.message}const a=c.data.story_list.map(e=>new s(e,t,i));const d=a.find(t=>t.nodeID===c.data.node_id);if(!d){return"获取起始结点失败"}d.choiceTime=c.data.edges.show_time;const r=c.data.edges.choices.map(t=>new e(t));d.choices=r;return new o(a,d)};return{export:{StoryChoice:e,StoryNode:s,Story:o,getStoryNodes:n}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{const{VideoInfo:i}=t.import("video-info");const{getFriendlyTitle:n}=t.import("title");class o{constructor(e){this.url=e;if(document.querySelector(".image-viewer")===null){this.createContainer()}this.viewer=document.querySelector(".image-viewer-container");this.downloadImage();addSettingsListener("filenameFormat",()=>{this.viewer.querySelector(".download").setAttribute("download",this.filename)})}createContainer(){document.body.insertAdjacentHTML("beforeend",t.import("imageViewerHtml"));document.querySelector(".image-viewer-container .close").addEventListener("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){document.querySelector("#view-cover").style.display=this.url?"flex":"none";if(this.url===""){return}const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=URL.createObjectURL(e.response);if(this.imageData){URL.revokeObjectURL(this.imageData)}this.imageData=t;const i=this.viewer.querySelector(".download");i.setAttribute("href",t);i.setAttribute("download",this.filename);this.viewer.querySelector(".copy-link").addEventListener("click",()=>GM_setClipboard(this.url));this.viewer.querySelector(".new-tab").setAttribute("href",this.url);this.viewer.querySelector(".image").src=t});e.send()}show(){this.viewer.classList.add("opened")}hide(){this.viewer.classList.remove("opened")}get filename(){return n(document.URL.includes("/www.bilibili.com/bangumi/"))+this.url.substring(this.url.lastIndexOf("."))}}return(()=>{if(!document.URL.includes("live.bilibili.com")){return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);return Boolean(e)},success:async()=>{async function e(){const e=(unsafeWindow||window).aid;const t=new i(e);try{await t.fetchInfo()}catch(e){return""}return t.coverUrl}let t=new o(await e());document.querySelector("#view-cover").addEventListener("click",()=>{t.show()});const n=async()=>{t=new o(await e())};Observer.videoChange(n)}}}}else{return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.select(()=>document.querySelector(".header-info-ctnr .room-cover"));return Boolean(e)},success:async()=>{const e=document.querySelector(".header-info-ctnr .room-cover");const t=e.getAttribute("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const i=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const n=await Ajax.getJson(i);const r=n.data.cover;const s=new o(r);document.querySelector("#view-cover").addEventListener("click",()=>{s.show()})}}}}}})()}})(); @@ -1901,6 +1902,12 @@ Resource.manifest = { vDropdown: '下拉框组件', }, }, + vCheckbox: { + path: 'v-checkbox.vue.min.js', + displayNames: { + vCheckbox: '复选框组件', + }, + }, doubleClickFullscreen: { path: 'double-click-fullscreen.min.js', displayNames: { diff --git a/bilibili-evolved.preview-offline.user.js b/bilibili-evolved.preview-offline.user.js index 2dc65400a..fe2ed66f1 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 412.30 +// @version 412.31 // @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -976,9 +976,9 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/double-click-fullscreen.min.js"] = (()=>{return(i,e)=>{(async()=>{const e=["https://www.bilibili.com/bangumi/","https://www.bilibili.com/video/"];if(!e.some(i=>document.URL.startsWith(i))){return}if(i.touchVideoPlayer&&i.touchVideoPlayerDoubleTapControl){Toast.info("在开启了播放器触摸支持-启用双击控制后, 双击全屏功能将无效.","提示");i.doubleClickFullscreen=false;return}await SpinQuery.unsafeJquery();const l=await SpinQuery.condition(()=>dq(".bilibili-player-area"),i=>i!==null&&unsafeWindow.$(".bilibili-player-video").data("events"));if(l===null){return}const n="double-click-fullscreen";if(!l.classList.contains(n)){l.classList.add(n);const i=unsafeWindow.$(".bilibili-player-video");const e=new DoubleClickEvent(()=>dq(".bilibili-player-video-btn-fullscreen").click(),()=>{});e.bind(i[0])}})()}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-audio.min.js"] = (()=>{return(e,t)=>{class n{constructor(){this.sid=null;this.progress=null}async getDownloadUrl(){const e=`https://www.bilibili.com/audio/music-service-c/web/url?sid=${this.sid}&privilege=2&quality=2`;const t=await Ajax.getJsonWithCredentials(e);if(t.code===0){return t.data.cdns.shift()}else{logError("获取下载链接失败, 请确保当前账号有下载权限.","下载音频",1e4);return null}}async download(){const e=await this.getDownloadUrl();return new Promise((t,n)=>{const s=new XMLHttpRequest;s.open("GET",e);s.responseType="blob";s.addEventListener("load",()=>t(s.response));s.addEventListener("error",()=>n(s.status));s.addEventListener("progress",e=>this.progress&&this.progress(100*e.loaded/e.total));s.send()})}}const s="下载音频";return{export:n,widget:{content:`\n \n \n ${s}\n \n `,condition:()=>document.URL.includes("bilibili.com/audio"),success:async()=>{await SpinQuery.select(()=>document.querySelector("#app"));const e=document.querySelector("#download-audio");const t=e.querySelector("span");const o=new n;o.progress=(e=>{t.innerHTML=`${Math.round(e)}%`});const i=document.querySelector("#download-audio-link");e.addEventListener("click",async e=>{if(o.sid===null||e.target===i){return}const n=await o.download();t.innerHTML=s;const r=i.getAttribute("href");if(r){URL.revokeObjectURL(r)}i.setAttribute("href",URL.createObjectURL(n));const d=(()=>{const e=document.querySelector(".song-title");if(e){return e.getAttribute("title")}else{return"神秘音频"}})();i.setAttribute("download",d+".m4a");i.click()});Observer.childList("#app",()=>{const t=document.URL.match(/bilibili\.com\/audio\/au([\d]+)/);if(t&&t[1]){e.disabled=false;o.sid=t[1]}else{e.disabled=true}})}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-danmaku.min.js"] = (()=>{return(t,e)=>{const{getFriendlyTitle:n}=e.import("title");const{DanmakuInfo:i}=e.import("video-info");const{DanmakuConverter:a}=e.import("danmaku-converter");async function o(t){const e=n();let i={title:e};try{await loadDanmakuSettingsPanel();const t=t=>{const e=parseFloat(dq(t).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const n={0:0,44:1,94:2,144:3,188:4}[e];return n};i.font=dq(".bilibili-player-video-danmaku-setting-right-font .bui-select-result").innerText;i.alpha=parseFloat(dq(".bilibili-player-setting-opacity .bui-bar").style.transform.replace(/scaleX\(([\d\.]+)\)/,"$1"));i.duration=(()=>{const e=[18,14,10,8,6][t(".bilibili-player-setting-speedplus .bui-thumb")];return t=>{switch(t.type){case 4:case 5:return 4;default:return e}}})();i.blockTypes=(()=>{let t=[];const e={".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"]};for(const[n,i]of Object.entries(e)){if(dq(n).classList.contains("disabled")){t=t.concat(i)}}return t.concat(7,8)})();const e=[1.4,1.2,1,.8,.6][t(".bilibili-player-setting-fontsize .bui-thumb")];i.resolution={x:1920*e,y:1080*e};i.bottomMarginPercent=[.75,.5,.25,0,0][t(".bilibili-player-setting-area .bui-thumb")];if(i.bottomMarginPercent===0&&dq(".bilibili-player-video-danmaku-setting-left-preventshade input").checked){i.bottomMarginPercent=.15}i.bold=dq(".bilibili-player-video-danmaku-setting-right-font-bold input").checked}catch(t){i={font:"微软雅黑",alpha:.6,duration:t=>{switch(t.type){case 4:case 5:return 4;default:return 6}},blockTypes:[7,8],resolution:{x:1920,y:1080},bottomMarginPercent:.15,bold:false}}const o=new a(i);const l=o.convertToAssDocument(t);return l.generateAss()}async function l(t,e){const a=n();const l=new i((unsafeWindow||window).cid);await l.fetchInfo();const r=await(async()=>{if(t===true){return new Blob([await o(l.rawXML)],{type:"text/plain"})}else{return new Blob([l.rawXML],{type:"text/plain"})}})();const s=URL.createObjectURL(r);const c=dq("#danmaku-link");const d=c.getAttribute("href");if(d){URL.revokeObjectURL(d)}clearTimeout(e);dq("#download-danmaku>span").innerHTML="下载弹幕";c.setAttribute("download",`${a}.${t?"ass":"xml"}`);c.setAttribute("href",s);c.click()}return{export:{downloadDanmaku:l,convertToAss:o},widget:{content:`\n \n \n 下载弹幕\n \n `,condition:async()=>{let t=await SpinQuery.select(()=>(unsafeWindow||window).cid);return Boolean(t)},success:()=>{const t=document.querySelector("#danmaku-link");dq("#download-danmaku").addEventListener("click",e=>{if(e.target!==t){const t=setTimeout(()=>dq("#download-danmaku>span").innerHTML="请稍侯...",200);l(e.shiftKey,t)}})}}}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.css"] = `.download-video.opened{pointer-events:initial;opacity:1;transform:translate(-50%,-50%) scale(1)}.download-video{--download-video-background:white;--download-video-foreground:black;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .title,.round-corner .download-video button,.round-corner .v-dropdown,.round-corner .v-dropdown .dropdown-menu,.round-corner .v-dropdown .dropdown-menu li{border-radius:var(--corner-radius)}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video .cover{width:240px;min-height:135px;background-color:#8882}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video h1{font-size:16pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding-top:12px;font-size:10pt}.download-video .tabs .tab{padding:6px 12px;border-bottom:2px solid transparent;cursor:pointer}.download-video .tab.active{color:var(--theme-color);border-bottom-color:var(--theme-color)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0}.download-video h2{font-size:12pt;font-weight:700;color:var(--download-video-foreground)}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}.download-video .direct-download .progress .percent{width:50px;text-align:right}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(50% - 16px);display:flex;justify-content:center;align-items:center}.download-video i.mdi-alert-circle{font-size:14pt;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:300px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.v-checkbox{font-size:10pt;cursor:pointer;display:flex;align-items:center}.v-checkbox .mdi{font-size:15pt;line-height:1}.v-checkbox .content{flex-grow:1;text-align:left;padding:0 8px}.v-checkbox .mdi-checkbox-marked-circle{color:var(--theme-color);position:absolute;top:0;left:0;transform:scale(0);transition-timing-function:cubic-bezier(.6,-.28,.74,.05)}.v-checkbox .mdi-checkbox-blank-circle-outline{color:#8884;position:relative}.v-checkbox.checked .mdi-checkbox-blank-circle-outline{color:var(--theme-color)}.v-checkbox.checked .mdi-checkbox-marked-circle{transform:scale(1);transition-timing-function:cubic-bezier(.18,.89,.32,1.28)}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:var(--download-video-background);bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%);opacity:0;pointer-events:none;padding:8px;z-index:3}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;pointer-events:initial}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}`; +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.css"] = `.download-video{--download-video-background:white;--download-video-foreground:black;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;max-height:90%;overflow:auto}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translate(-50%,-50%) scale(1)}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{width:240px;min-height:135px;background-color:#8882}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video h1{font-size:16pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding-top:12px;font-size:10pt}.download-video .tabs .tab{padding:6px 12px;border-bottom:2px solid transparent;cursor:pointer}.download-video .tabs .tab.active{color:var(--theme-color);border-bottom-color:var(--theme-color)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video h2{font-size:12pt;font-weight:700;color:var(--download-video-foreground)}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(50% - 16px);display:flex;justify-content:center;align-items:center}.download-video i.mdi-alert-circle{font-size:14pt;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:300px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:var(--download-video-background);bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%);opacity:0;pointer-events:none;padding:8px;z-index:3}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;pointer-events:initial}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.html"] = `

下载视频

单个视频
批量导出
警告: 过大的视频大小会在直接下载时占用大量内存, 并可能导致浏览器标签页崩溃. 请考虑降低清晰度或使用导出选项.
预计大小: {{displaySize}}
清晰度
弹幕

直接下载

{{speed}}
{{progressPercent}}%

选集

{{selectedEpisodeCount}}/{{episodeList.length}}

导出

{{showRpcSettings ? '取消' : '导出aria2 RPC'}}

aria2 RPC 配置

主机
端口
密钥
限速
路径
方法
确定
`; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.js"] = (()=>{return(e,t)=>{const{getFriendlyTitle:s}=t.import("title");const{VideoInfo:i,DanmakuInfo:a}=t.import("video-info");class n{constructor(){this.menuClasses=["quality","action","progress"];[this.currentMenuClass]=this.menuClasses}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}closeMenu(){this.menuPanel.classList.remove("opened");setTimeout(()=>this.resetMenuClass(),200)}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=${r.aid}&cid=${r.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${r.aid}&cid=${r.cid}&otype=json`}}}class o extends n{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${r.aid}&cid=${r.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${r.aid}&cid=${r.cid}&qn=&otype=json`}}}const r={entity:new n,aid:"",cid:""};let l=[];let c=null;class d{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new u(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{r.entity.getUrl().then(s=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{const s=JSON.parse(i.responseText);if(s.code!==0){t("获取清晰度信息失败.");return}const a=s.data||s.result||s;const n=a.accept_quality;const o=a.accept_format.split(",");const r=a.accept_description;const l=[];while(n.length>0){const e=new d(n.pop(),o.pop(),r.pop());l.push(e)}e(l.reverse())});i.addEventListener("error",()=>t(`获取清晰度信息失败.`));i.withCredentials=true;i.open("GET",s);i.send()})})}}class h{constructor(e,t,s,i){this.length=e;this.size=t;this.url=s;this.backupUrls=i}}class u{constructor(e,t){this.fragmentSplitFactor=6*5;this.workingXhr=null;this.progressMap=new Map;this.format=e;this.fragments=t||[];this.videoSpeed=new p(this)}get totalSize(){return this.fragments.map(e=>e.size).reduce((e,t)=>e+t)}fetchVideoInfo(){return new Promise((e,t)=>{r.entity.getUrl(this.format.quality).then(s=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{const s=JSON.parse(i.responseText.replace(/http:/g,"https:"));const a=s.data||s.result||s;if(a.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const n=a.durl;this.fragments=n.map(e=>new h(e.length,e.size,e.url,e.backup_url));e(this.fragments)});i.withCredentials=true;i.open("GET",s);i.send()})})}updateProgress(){const e=this.progressMap?[...this.progressMap.values()].reduce((e,t)=>e+t,0)/this.totalSize:0;if(e>1||e<0){console.error(`[下载视频] 进度异常: ${e}`,this.progressMap.values())}this.progress&&this.progress(e)}cancelDownload(){this.videoSpeed.stopMeasure();if(this.workingXhr!==null){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const s=16*1024*1024;let i=0;const a=e=>[...this.progressMap.keys()].indexOf(e)+1;while(i{const i=new XMLHttpRequest;i.open("GET",e.url);i.responseType="arraybuffer";i.withCredentials=false;i.addEventListener("progress",e=>{console.log(`[下载视频] 视频片段${a(i)}下载进度: ${e.loaded}/${r} bytes loaded, ${o}`);this.progressMap.set(i,e.loaded);this.updateProgress()});i.addEventListener("load",()=>{if((""+i.status)[0]==="2"){console.log(`[下载视频] 视频片段${a(i)}下载完成`);t(i.response)}else{s(`视频片段${a(i)}请求失败, response = ${i.status}`)}});i.addEventListener("abort",()=>s("canceled"));i.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${a(i)}下载失败: ${o}`);this.progressMap.set(i,0);this.updateProgress();i.open("GET",e.url);i.setRequestHeader("Range",o);i.send()});i.setRequestHeader("Range",o);this.progressMap.set(i,0);i.send();this.workingXhr.push(i)}));i=Math.round(i+s)+1}return Promise.all(t)}async copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}static downloadBlob(e,t){const s=document.createElement("a");let i;if(typeof e==="string"){i=e}else{i=URL.createObjectURL(e)}s.setAttribute("href",i);s.setAttribute("download",t);document.body.appendChild(s);s.click();s.remove();URL.revokeObjectURL(i)}async exportData(e=false){const t=JSON.stringify([{fragments:this.fragments,title:s(),totalSize:this.fragments.map(e=>e.size).reduce((e,t)=>e+t),referer:document.URL.replace(window.location.search,"")}]);if(e){GM_setClipboard(t,"text")}else{const e=new Blob([t],{type:"text/json"});const i=await this.downloadDanmaku();if(i!==null){const t=new JSZip;t.file(`${s()}.json`,e);t.file(s()+"."+this.danmakuOption.toLowerCase(),i);u.downloadBlob(await t.generateAsync({type:"blob"}),`${s()}.zip`)}else{u.downloadBlob(e,`${s()}.json`)}}}async exportAria2(i=false){if(i){const i=await this.downloadDanmaku();if(i!==null){u.downloadBlob(new Blob([i]),`${s()}.${this.danmakuOption==="ASS"?"ass":"xml"}`)}const a=e.aria2RpcOption;const n=this.fragments.map((e,t)=>{let i="";if(this.fragments.length>1){i=" - "+(t+1)}const n=[];if(a.secretKey!==""){n.push(`token:${a.secretKey}`)}n.push([e.url]);n.push({referer:document.URL.replace(window.location.search,""),"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0",out:`${s()}${i}${this.extension(e)}`,split:this.fragmentSplitFactor,dir:a.dir||undefined,"max-download-limit":a.maxDownloadLimit||undefined});const o=encodeURIComponent(`${s()}${i}`);return{params:n,id:o}});const{sendRpc:o}=await t.importAsync("aria2-rpc");await o(n)}else{const e=`\n# Generated by Bilibili Evolved Video Export\n# https://github.com/the1812/Bilibili-Evolved/\n${this.fragments.map((e,t)=>{let i="";if(this.fragments.length>1){i=" - "+(t+1)}return`\n${e.url}\n referer=${document.URL.replace(window.location.search,"")}\n user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0\n out=${s()}${i}${this.extension(e)}\n split=${this.fragmentSplitFactor}\n `.trim()}).join("\n")}\n `.trim();const t=new Blob([e],{type:"text/plain"});const i=await this.downloadDanmaku();if(i!==null){const e=new JSZip;e.file(`${s()}.txt`,t);e.file(s()+"."+this.danmakuOption.toLowerCase(),i);u.downloadBlob(await e.generateAsync({type:"blob"}),`${s()}.zip`)}else{u.downloadBlob(t,`${s()}.txt`)}}}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=dq("a#video-complete").getAttribute("href");if(e&&!dq(`.link[href="${e}"]`)){URL.revokeObjectURL(e)}dqa(".toast-card-header").filter(e=>e.innerText.includes("下载视频")).forEach(e=>e.querySelector(".toast-card-dismiss").click())}async downloadDanmaku(){if(this.danmakuOption!=="无"){const e=new a(r.cid);await e.fetchInfo();if(this.danmakuOption==="XML"){return e.rawXML}else{const{convertToAss:s}=await t.importAsync("download-danmaku");return s(e.rawXML)}}else{return null}}async downloadSingle(e){const t=await this.downloadDanmaku();const[i]=e;if(t===null){const e=this.makeBlob(i);const t=s()+this.extension();return{blob:e,filename:t}}else{const e=new JSZip;e.file(s()+this.extension(),this.makeBlob(i));e.file(s()+"."+this.danmakuOption.toLowerCase(),t);const a=await e.generateAsync({type:"blob"});const n=s()+".zip";return{blob:a,filename:n}}}async downloadMultiple(e){const t=new JSZip;const i=s();if(e.length>1){e.forEach((e,s)=>{const a=this.fragments[s];t.file(`${i} - ${s+1}${this.extension(a)}`,this.makeBlob(e,a))})}else{const[s]=e;t.file(`${i}${this.extension()}`,this.makeBlob(s))}const a=await this.downloadDanmaku();if(a!==null){t.file(s()+"."+this.danmakuOption.toLowerCase(),a)}const n=await t.generateAsync({type:"blob"});const o=i+".zip";return{blob:n,filename:o}}async download(){const e=[];this.videoSpeed.startMeasure();for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let{blob:t,filename:s}=await(async()=>{if(e.length===1){return await this.downloadSingle(e)}else{return await this.downloadMultiple(e)}})();this.cleanUpOldBlobUrl();const i=URL.createObjectURL(t);this.progress&&this.progress(0);this.videoSpeed.stopMeasure();return{url:i,filename:s}}}class p{constructor(e){this.lastProgress=0;this.measureInterval=1e3;this.workingDownloader=e}startMeasure(){this.intervalTimer=setInterval(()=>{const e=this.workingDownloader.progressMap?[...this.workingDownloader.progressMap.values()].reduce((e,t)=>e+t,0):0;const t=e-this.lastProgress;if(this.speedUpdate!==undefined){this.speedUpdate(formatFileSize(t)+"/s")}this.lastProgress=e},this.measureInterval)}stopMeasure(){clearInterval(this.intervalTimer)}}async function w(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);if(!(e&&t)){return false}r.aid=e;r.cid=t;if(document.URL.indexOf("bangumi")!==-1){r.entity=new o}else{r.entity=new n}try{l=await d.availableFormats}catch(e){return false}return true}async function f(){c=l[0];t.applyStyle("downloadVideoStyle");dq("#download-video").addEventListener("click",()=>{dq(".download-video").classList.toggle("opened");dq(".gui-settings-mask").click()});dq("#download-video").addEventListener("mouseover",()=>{document.body.insertAdjacentHTML("beforeend",t.import("downloadVideoHtml"));m()},{once:true})}async function m(){const n=await t.importAsync("v-dropdown.vue");Vue.component("v-checkbox",{template:`\n
\n \n \n \n {{title}}\n
\n `,props:["checked","title"],methods:{toggleCheck(){this.$emit("update:checked",!this.checked)}}});let o;const h=new Map;const p=new Vue({el:".download-video",components:{"v-dropdown":n},data:{downloadSingle:true,coverUrl:'data:image/svg+xml;utf-8,',aid:r.aid,cid:r.cid,qualityModel:{value:c.displayName,items:l.map(e=>e.displayName)},danmakuModel:{value:e.downloadVideoDefaultDanmaku,items:["无","XML","ASS"]},progressPercent:0,size:"获取大小中",blobUrl:"",episodeList:[],downloading:false,speed:"",batch:false,rpcSettings:e.aria2RpcOption,showRpcSettings:false,busy:false},computed:{displaySize(){if(typeof this.size==="string"){return this.size}return formatFileSize(this.size)},sizeWarning(){if(typeof this.size==="string"){return false}return this.size>1073741824},selectedEpisodeCount(){return this.episodeList.filter(e=>e.checked).length}},methods:{close(){this.$el.classList.remove("opened")},danmakuOptionChange(){e.downloadVideoDefaultDanmaku=this.danmakuModel.value},async formatChange(){const e=this.getFormat();const t=h.get(e);if(t){this.size=t;return}try{this.size="获取大小中";const t=await e.downloadInfo();this.size=t.totalSize;h.set(e,this.size)}catch(e){this.size="获取大小失败"}},getFormat(){const e=l.find(e=>e.displayName===this.qualityModel.value);if(!e){console.error(`No format found. model value = ${this.qualityModel.value}`);return null}return e},async exportData(e){if(this.busy===true){return}try{this.busy=true;if(!this.downloadSingle){await this.exportBatchData(e);return}const t=this.getFormat();const s=await t.downloadInfo();s.danmakuOption=this.danmakuModel.value;switch(e){case"copyLink":await s.copyUrl();Toast.success("已复制链接到剪贴板.","下载视频",3e3);break;case"aria2":await s.exportAria2(false);break;case"aria2RPC":await s.exportAria2(true);break;case"copyVLD":await s.exportData(true);Toast.success("已复制VLD数据到剪贴板.","下载视频",3e3);break;case"exportVLD":await s.exportData(false);break;default:break}}catch(e){logError(e)}finally{this.busy=false}},async exportBatchData(e){const i=this.episodeList;if(i.every(e=>e.checked===false)){Toast.info("请至少选择1集或以上的数量!","批量导出",3e3);return}const n=e=>{const t=i.find(t=>t.cid===e.cid);if(t===undefined){return false}return t.checked};const o=this.getFormat();if(this.danmakuModel.value!=="无"){const e=Toast.info("下载弹幕中...","批量导出");const s=new JSZip;try{if(this.danmakuModel.value==="XML"){for(const e of i.filter(n)){const t=new a(e.cid);await t.fetchInfo();s.file(e.title+".xml",t.rawXML)}}else{const{convertToAss:e}=await t.importAsync("download-danmaku");for(const t of i.filter(n)){const i=new a(t.cid);await i.fetchInfo();s.file(t.title+".ass",await e(i.rawXML))}}u.downloadBlob(await s.generateAsync({type:"blob"}),this.cid+".danmakus.zip")}catch(e){logError(`弹幕下载失败`)}finally{e.dismiss()}}const r=Toast.info("获取链接中...","批量导出");this.batchExtractor.itemFilter=n;let l;try{switch(e){case"aria2":l=await this.batchExtractor.collectAria2(o,r);u.downloadBlob(new Blob([l],{type:"text/plain"}),s(false)+".txt");return;case"aria2RPC":await this.batchExtractor.collectAria2(o,r,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);return;case"copyVLD":GM_setClipboard(await this.batchExtractor.collectData(o,r),{mimetype:"text/plain"});Toast.success("已复制批量vld数据到剪贴板.","批量导出",3e3);return;case"exportVLD":l=await this.batchExtractor.collectData(o,r);u.downloadBlob(new Blob([l],{type:"text/json"}),s(false)+".json");return;default:return}}catch(e){logError(e)}finally{r.dismiss()}},async checkBatch(){const e=["/www.bilibili.com/bangumi","/www.bilibili.com/video/av"];if(!e.some(e=>document.URL.includes(e))){this.batch=false;this.episodeList=[];return}const{BatchExtractor:s}=await t.importAsync("batch-download");if(await s.test()!==true){this.batch=false;this.episodeList=[];return}this.batchExtractor=new s;this.batch=true;this.episodeList=(await this.batchExtractor.getItemList()).map((e,t)=>{return{aid:e.aid,cid:e.cid,title:e.title,index:t,checked:true}})},cancelDownload(){if(o){o.cancelDownload()}},async startDownload(){const e=this.getFormat();try{this.downloading=true;const t=await e.downloadInfo();t.videoSpeed.speedUpdate=(e=>this.speed=e);t.danmakuOption=this.danmakuModel.value;t.progress=(e=>{this.progressPercent=Math.trunc(e*100)});o=t;const s=await t.download();const i=document.getElementById("video-complete");i.setAttribute("href",s.url);i.setAttribute("download",s.filename);i.click();Toast.success(`下载完成: ${s.filename} 再次保存`,"下载视频")}catch(e){if(e!=="canceled"){logError(e)}this.progressPercent=0}finally{this.downloading=false;this.speed=""}},selectAllEpisodes(){this.episodeList.forEach(e=>e.checked=true)},unselectAllEpisodes(){this.episodeList.forEach(e=>e.checked=false)},inverseAllEpisodes(){this.episodeList.forEach(e=>e.checked=!e.checked)},toggleRpcSettings(){this.showRpcSettings=!this.showRpcSettings},saveRpcSettings(){if(this.rpcSettings.host===""){this.rpcSettings.host="127.0.0.1"}if(this.rpcSettings.port===""){this.rpcSettings.port="6800"}e.aria2RpcOption=this.rpcSettings}}});Observer.videoChange(async()=>{p.close();p.batch=false;p.downloadSingle=true;const e=dq("#download-video");const t=await w();e.style.display=t?"flex":"none";if(!t){return}p.aid=r.aid;p.cid=r.cid;const s=new i(r.aid);await s.fetchInfo();p.coverUrl=s.coverUrl.replace("http:","https:");l=await d.availableFormats;[c]=l;p.qualityModel={value:c.displayName,items:l.map(e=>e.displayName)};p.formatChange();await p.checkBatch()})}return{widget:{content:`\n `,condition:w,success:f}}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.js"] = (()=>{return(e,t)=>{const{getFriendlyTitle:s}=t.import("title");const{VideoInfo:a,DanmakuInfo:i}=t.import("video-info");class n{constructor(){this.menuClasses=["quality","action","progress"];[this.currentMenuClass]=this.menuClasses}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}closeMenu(){this.menuPanel.classList.remove("opened");setTimeout(()=>this.resetMenuClass(),200)}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=${r.aid}&cid=${r.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${r.aid}&cid=${r.cid}&otype=json`}}}class o extends n{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${r.aid}&cid=${r.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${r.aid}&cid=${r.cid}&qn=&otype=json`}}}const r={entity:new n,aid:"",cid:""};let l=[];let c=null;class d{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new u(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{r.entity.getUrl().then(s=>{const a=new XMLHttpRequest;a.addEventListener("load",()=>{const s=JSON.parse(a.responseText);if(s.code!==0){t("获取清晰度信息失败.");return}const i=s.data||s.result||s;const n=i.accept_quality;const o=i.accept_format.split(",");const r=i.accept_description;const l=[];while(n.length>0){const e=new d(n.pop(),o.pop(),r.pop());l.push(e)}e(l.reverse())});a.addEventListener("error",()=>t(`获取清晰度信息失败.`));a.withCredentials=true;a.open("GET",s);a.send()})})}}class h{constructor(e,t,s,a){this.length=e;this.size=t;this.url=s;this.backupUrls=a}}class u{constructor(e,t){this.fragmentSplitFactor=6*5;this.workingXhr=null;this.progressMap=new Map;this.format=e;this.fragments=t||[];this.videoSpeed=new p(this)}get totalSize(){return this.fragments.map(e=>e.size).reduce((e,t)=>e+t)}fetchVideoInfo(){return new Promise((e,t)=>{r.entity.getUrl(this.format.quality).then(s=>{const a=new XMLHttpRequest;a.addEventListener("load",()=>{const s=JSON.parse(a.responseText.replace(/http:/g,"https:"));const i=s.data||s.result||s;if(i.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const n=i.durl;this.fragments=n.map(e=>new h(e.length,e.size,e.url,e.backup_url));e(this.fragments)});a.withCredentials=true;a.open("GET",s);a.send()})})}updateProgress(){const e=this.progressMap?[...this.progressMap.values()].reduce((e,t)=>e+t,0)/this.totalSize:0;if(e>1||e<0){console.error(`[下载视频] 进度异常: ${e}`,this.progressMap.values())}this.progress&&this.progress(e)}cancelDownload(){this.videoSpeed.stopMeasure();if(this.workingXhr!==null){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const s=16*1024*1024;let a=0;const i=e=>[...this.progressMap.keys()].indexOf(e)+1;while(a{const a=new XMLHttpRequest;a.open("GET",e.url);a.responseType="arraybuffer";a.withCredentials=false;a.addEventListener("progress",e=>{console.log(`[下载视频] 视频片段${i(a)}下载进度: ${e.loaded}/${r} bytes loaded, ${o}`);this.progressMap.set(a,e.loaded);this.updateProgress()});a.addEventListener("load",()=>{if((""+a.status)[0]==="2"){console.log(`[下载视频] 视频片段${i(a)}下载完成`);t(a.response)}else{s(`视频片段${i(a)}请求失败, response = ${a.status}`)}});a.addEventListener("abort",()=>s("canceled"));a.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${i(a)}下载失败: ${o}`);this.progressMap.set(a,0);this.updateProgress();a.open("GET",e.url);a.setRequestHeader("Range",o);a.send()});a.setRequestHeader("Range",o);this.progressMap.set(a,0);a.send();this.workingXhr.push(a)}));a=Math.round(a+s)+1}return Promise.all(t)}async copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}static downloadBlob(e,t){const s=document.createElement("a");let a;if(typeof e==="string"){a=e}else{a=URL.createObjectURL(e)}s.setAttribute("href",a);s.setAttribute("download",t);document.body.appendChild(s);s.click();s.remove();URL.revokeObjectURL(a)}async exportData(e=false){const t=JSON.stringify([{fragments:this.fragments,title:s(),totalSize:this.fragments.map(e=>e.size).reduce((e,t)=>e+t),referer:document.URL.replace(window.location.search,"")}]);if(e){GM_setClipboard(t,"text")}else{const e=new Blob([t],{type:"text/json"});const a=await this.downloadDanmaku();if(a!==null){const t=new JSZip;t.file(`${s()}.json`,e);t.file(s()+"."+this.danmakuOption.toLowerCase(),a);u.downloadBlob(await t.generateAsync({type:"blob"}),`${s()}.zip`)}else{u.downloadBlob(e,`${s()}.json`)}}}async exportAria2(a=false){if(a){const a=await this.downloadDanmaku();if(a!==null){u.downloadBlob(new Blob([a]),`${s()}.${this.danmakuOption==="ASS"?"ass":"xml"}`)}const i=e.aria2RpcOption;const n=this.fragments.map((e,t)=>{let a="";if(this.fragments.length>1){a=" - "+(t+1)}const n=[];if(i.secretKey!==""){n.push(`token:${i.secretKey}`)}n.push([e.url]);n.push({referer:document.URL.replace(window.location.search,""),"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0",out:`${s()}${a}${this.extension(e)}`,split:this.fragmentSplitFactor,dir:i.dir||undefined,"max-download-limit":i.maxDownloadLimit||undefined});const o=encodeURIComponent(`${s()}${a}`);return{params:n,id:o}});const{sendRpc:o}=await t.importAsync("aria2-rpc");await o(n)}else{const e=`\n# Generated by Bilibili Evolved Video Export\n# https://github.com/the1812/Bilibili-Evolved/\n${this.fragments.map((e,t)=>{let a="";if(this.fragments.length>1){a=" - "+(t+1)}return`\n${e.url}\n referer=${document.URL.replace(window.location.search,"")}\n user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0\n out=${s()}${a}${this.extension(e)}\n split=${this.fragmentSplitFactor}\n `.trim()}).join("\n")}\n `.trim();const t=new Blob([e],{type:"text/plain"});const a=await this.downloadDanmaku();if(a!==null){const e=new JSZip;e.file(`${s()}.txt`,t);e.file(s()+"."+this.danmakuOption.toLowerCase(),a);u.downloadBlob(await e.generateAsync({type:"blob"}),`${s()}.zip`)}else{u.downloadBlob(t,`${s()}.txt`)}}}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=dq("a#video-complete").getAttribute("href");if(e&&!dq(`.link[href="${e}"]`)){URL.revokeObjectURL(e)}dqa(".toast-card-header").filter(e=>e.innerText.includes("下载视频")).forEach(e=>e.querySelector(".toast-card-dismiss").click())}async downloadDanmaku(){if(this.danmakuOption!=="无"){const e=new i(r.cid);await e.fetchInfo();if(this.danmakuOption==="XML"){return e.rawXML}else{const{convertToAss:s}=await t.importAsync("download-danmaku");return s(e.rawXML)}}else{return null}}async downloadSingle(e){const t=await this.downloadDanmaku();const[a]=e;if(t===null){const e=this.makeBlob(a);const t=s()+this.extension();return{blob:e,filename:t}}else{const e=new JSZip;e.file(s()+this.extension(),this.makeBlob(a));e.file(s()+"."+this.danmakuOption.toLowerCase(),t);const i=await e.generateAsync({type:"blob"});const n=s()+".zip";return{blob:i,filename:n}}}async downloadMultiple(e){const t=new JSZip;const a=s();if(e.length>1){e.forEach((e,s)=>{const i=this.fragments[s];t.file(`${a} - ${s+1}${this.extension(i)}`,this.makeBlob(e,i))})}else{const[s]=e;t.file(`${a}${this.extension()}`,this.makeBlob(s))}const i=await this.downloadDanmaku();if(i!==null){t.file(s()+"."+this.danmakuOption.toLowerCase(),i)}const n=await t.generateAsync({type:"blob"});const o=a+".zip";return{blob:n,filename:o}}async download(){const e=[];this.videoSpeed.startMeasure();for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let{blob:t,filename:s}=await(async()=>{if(e.length===1){return await this.downloadSingle(e)}else{return await this.downloadMultiple(e)}})();this.cleanUpOldBlobUrl();const a=URL.createObjectURL(t);this.progress&&this.progress(0);this.videoSpeed.stopMeasure();return{url:a,filename:s}}}class p{constructor(e){this.lastProgress=0;this.measureInterval=1e3;this.workingDownloader=e}startMeasure(){this.intervalTimer=setInterval(()=>{const e=this.workingDownloader.progressMap?[...this.workingDownloader.progressMap.values()].reduce((e,t)=>e+t,0):0;const t=e-this.lastProgress;if(this.speedUpdate!==undefined){this.speedUpdate(formatFileSize(t)+"/s")}this.lastProgress=e},this.measureInterval)}stopMeasure(){clearInterval(this.intervalTimer)}}async function w(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);if(!(e&&t)){return false}r.aid=e;r.cid=t;if(document.URL.indexOf("bangumi")!==-1){r.entity=new o}else{r.entity=new n}try{l=await d.availableFormats}catch(e){return false}return true}async function f(){c=l[0];t.applyStyle("downloadVideoStyle");dq("#download-video").addEventListener("click",()=>{dq(".download-video").classList.toggle("opened");dq(".gui-settings-mask").click()});dq("#download-video").addEventListener("mouseover",()=>{document.body.insertAdjacentHTML("beforeend",t.import("downloadVideoHtml"));m()},{once:true})}async function m(){const n=await t.importAsync("v-dropdown.vue");const o=await t.importAsync("v-checkbox.vue");let h;const p=new Map;const f=new Vue({el:".download-video",components:{"v-dropdown":n,"v-checkbox":o},data:{downloadSingle:true,coverUrl:'data:image/svg+xml;utf-8,',aid:r.aid,cid:r.cid,qualityModel:{value:c.displayName,items:l.map(e=>e.displayName)},danmakuModel:{value:e.downloadVideoDefaultDanmaku,items:["无","XML","ASS"]},progressPercent:0,size:"获取大小中",blobUrl:"",episodeList:[],downloading:false,speed:"",batch:false,rpcSettings:e.aria2RpcOption,showRpcSettings:false,busy:false},computed:{displaySize(){if(typeof this.size==="string"){return this.size}return formatFileSize(this.size)},sizeWarning(){if(typeof this.size==="string"){return false}return this.size>1073741824},selectedEpisodeCount(){return this.episodeList.filter(e=>e.checked).length}},methods:{close(){this.$el.classList.remove("opened")},danmakuOptionChange(){e.downloadVideoDefaultDanmaku=this.danmakuModel.value},async formatChange(){const e=this.getFormat();const t=p.get(e);if(t){this.size=t;return}try{this.size="获取大小中";const t=await e.downloadInfo();this.size=t.totalSize;p.set(e,this.size)}catch(e){this.size="获取大小失败"}},getFormat(){const e=l.find(e=>e.displayName===this.qualityModel.value);if(!e){console.error(`No format found. model value = ${this.qualityModel.value}`);return null}return e},async exportData(e){if(this.busy===true){return}try{this.busy=true;if(!this.downloadSingle){await this.exportBatchData(e);return}const t=this.getFormat();const s=await t.downloadInfo();s.danmakuOption=this.danmakuModel.value;switch(e){case"copyLink":await s.copyUrl();Toast.success("已复制链接到剪贴板.","下载视频",3e3);break;case"aria2":await s.exportAria2(false);break;case"aria2RPC":await s.exportAria2(true);break;case"copyVLD":await s.exportData(true);Toast.success("已复制VLD数据到剪贴板.","下载视频",3e3);break;case"exportVLD":await s.exportData(false);break;default:break}}catch(e){logError(e)}finally{this.busy=false}},async exportBatchData(e){const a=this.episodeList;if(a.every(e=>e.checked===false)){Toast.info("请至少选择1集或以上的数量!","批量导出",3e3);return}const n=e=>{const t=a.find(t=>t.cid===e.cid);if(t===undefined){return false}return t.checked};const o=this.getFormat();if(this.danmakuModel.value!=="无"){const e=Toast.info("下载弹幕中...","批量导出");const s=new JSZip;try{if(this.danmakuModel.value==="XML"){for(const e of a.filter(n)){const t=new i(e.cid);await t.fetchInfo();s.file(e.title+".xml",t.rawXML)}}else{const{convertToAss:e}=await t.importAsync("download-danmaku");for(const t of a.filter(n)){const a=new i(t.cid);await a.fetchInfo();s.file(t.title+".ass",await e(a.rawXML))}}u.downloadBlob(await s.generateAsync({type:"blob"}),this.cid+".danmakus.zip")}catch(e){logError(`弹幕下载失败`)}finally{e.dismiss()}}const r=Toast.info("获取链接中...","批量导出");this.batchExtractor.itemFilter=n;let l;try{switch(e){case"aria2":l=await this.batchExtractor.collectAria2(o,r);u.downloadBlob(new Blob([l],{type:"text/plain"}),s(false)+".txt");return;case"aria2RPC":await this.batchExtractor.collectAria2(o,r,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);return;case"copyVLD":GM_setClipboard(await this.batchExtractor.collectData(o,r),{mimetype:"text/plain"});Toast.success("已复制批量vld数据到剪贴板.","批量导出",3e3);return;case"exportVLD":l=await this.batchExtractor.collectData(o,r);u.downloadBlob(new Blob([l],{type:"text/json"}),s(false)+".json");return;default:return}}catch(e){logError(e)}finally{r.dismiss()}},async checkBatch(){const e=["/www.bilibili.com/bangumi","/www.bilibili.com/video/av"];if(!e.some(e=>document.URL.includes(e))){this.batch=false;this.episodeList=[];return}const{BatchExtractor:s}=await t.importAsync("batch-download");if(await s.test()!==true){this.batch=false;this.episodeList=[];return}this.batchExtractor=new s;this.batch=true;this.episodeList=(await this.batchExtractor.getItemList()).map((e,t)=>{return{aid:e.aid,cid:e.cid,title:e.title,index:t,checked:true}})},cancelDownload(){if(h){h.cancelDownload()}},async startDownload(){const e=this.getFormat();try{this.downloading=true;const t=await e.downloadInfo();t.videoSpeed.speedUpdate=(e=>this.speed=e);t.danmakuOption=this.danmakuModel.value;t.progress=(e=>{this.progressPercent=Math.trunc(e*100)});h=t;const s=await t.download();const a=document.getElementById("video-complete");a.setAttribute("href",s.url);a.setAttribute("download",s.filename);a.click();Toast.success(`下载完成: ${s.filename} 再次保存`,"下载视频")}catch(e){if(e!=="canceled"){logError(e)}this.progressPercent=0}finally{this.downloading=false;this.speed=""}},selectAllEpisodes(){this.episodeList.forEach(e=>e.checked=true)},unselectAllEpisodes(){this.episodeList.forEach(e=>e.checked=false)},inverseAllEpisodes(){this.episodeList.forEach(e=>e.checked=!e.checked)},toggleRpcSettings(){this.showRpcSettings=!this.showRpcSettings},saveRpcSettings(){if(this.rpcSettings.host===""){this.rpcSettings.host="127.0.0.1"}if(this.rpcSettings.port===""){this.rpcSettings.port="6800"}e.aria2RpcOption=this.rpcSettings}}});Observer.videoChange(async()=>{f.close();f.batch=false;f.downloadSingle=true;const e=dq("#download-video");const t=await w();e.style.display=t?"flex":"none";if(!t){return}f.aid=r.aid;f.cid=r.cid;const s=new a(r.aid);await s.fetchInfo();f.coverUrl=s.coverUrl.replace("http:","https:");l=await d.availableFormats;[c]=l;f.qualityModel={value:c.displayName,items:l.map(e=>e.displayName)};f.formatChange();await f.checkBatch()})}return{widget:{content:`\n `,condition:w,success:f}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-danmaku.min.js"] = (()=>{return(e,a)=>{if(typeof isEmbeddedPlayer!=="undefined"&&isEmbeddedPlayer()){return}Observer.videoChange(async()=>{const e=await SpinQuery.select(".bui-collapse-wrap");if(e&&e.classList.contains("bui-collapse-wrap-folded")){const e=await SpinQuery.select(".bui-collapse-header");e.click()}})}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-description.min.css"] = `.play-up-info .play-up-self,.video-desc .info{height:auto!important}.play-up-info .play-up-self-btn,.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")}})(); @@ -1066,7 +1066,8 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-player.min.css"] = `.touch-video-box-wrapper{display:flex;align-items:center;justify-content:center;width:100%;height:100%;position:absolute;top:0;left:0;z-index:14;pointer-events:none}.touch-video-box{display:flex;align-items:center;justify-content:center;width:100%;height:100%;background:rgba(0,0,0,.85);position:relative;max-width:520px;max-height:240px;border:4px solid transparent;transform-origin:center}.round-corner .touch-video-box{border-radius:var(--corner-radius)}.touch-video-box-wrapper.simple{align-items:flex-start}.touch-video-box.animation{transition:.2s cubic-bezier(.18,.89,.32,1.28)}.touch-video-info{color:#fff;font-size:2rem;text-align:center;display:flex;align-items:center;justify-content:center;flex-direction:column;height:100%;width:100%}.touch-row{flex-grow:1;display:flex;align-items:center;justify-content:center;width:100%}.touch-info{display:block;color:var(--theme-color)}.touch-result{display:block;font-size:1.5rem;line-height:150%}.touch-speed{display:block;background:rgba(0,0,0,.1);padding:.5em}.touch-progress{position:absolute;bottom:0;left:0;background:var(--theme-color);width:0;height:4px}.round-corner .touch-progress{border-radius:2px}.touch-row-item{flex:1 0 0;display:none;align-items:center;justify-content:center}.touch-row-item-wide{flex:1.5 0 0;display:flex;align-items:center;justify-content:center}.videoshot{background-color:transparent;background-image:none;transform-origin:center;transform:scale(.9)}.adjust-closed{opacity:0;transform:scale(.9)}.adjust-opened{opacity:1;transform:scale(1)}.touch-video-info.speed .touch-row-item{display:flex}.touch-video-info.cancel .touch-progress,.touch-video-info.cancel .touch-result{opacity:0}.disable-original-hover .bilibili-player-video-control-bottom,.disable-original-hover .bilibili-player-video-control-mask{opacity:0!important;visibility:hidden!important}.disable-original-hover .bilibili-player-video-control-wrap,.disable-original-hover.touch-video-control-show .bilibili-player-video-control-bottom,.disable-original-hover.touch-video-control-show .bilibili-player-video-control-mask{opacity:1!important;visibility:visible!important}.bilibili-player-video-control-top,.disable-original-hover .bilibili-player-video-control-top{left:0!important;right:0!important;bottom:0!important}.bilibili-player-video-control-top,.bilibili-player-video-progress-detail{bottom:0!important}.disable-original-hover.touch-video-control-show .bilibili-player-video-control-top{left:0!important;right:0!important;bottom:38px!important}div.bilibili-player-video-control{height:38px!important;align-items:center!important}.bilibili-player-video-btn{flex-grow:1!important;height:100%!important;display:flex!important;align-items:center!important;justify-content:center!important}.bilibili-player-video-inputbar,.bilibili-player-video-progress{flex-grow:30!important}.bilibili-player-video-quality-menu{display:flex!important;align-items:center!important;justify-content:center!important}.bilibili-player-iconfont-color,.bilibili-player-iconfont-danmaku,.bilibili-player-iconfont-danmaku-off,.bilibili-player-iconfont-fullscreen,.bilibili-player-iconfont-pause,.bilibili-player-iconfont-repeat,.bilibili-player-iconfont-setting,.bilibili-player-iconfont-start,.bilibili-player-iconfont-volume,.bilibili-player-iconfont-volume-max,.bilibili-player-iconfont-volume-min,.bilibili-player-iconfont-web-fullscreen,.bilibili-player-iconfont-widescreen{font-size:2.5rem!important}.bilibili-player-iconfont-next{font-size:2rem!important}.bilibili-player-video-btn-setting-panel,.bilibili-player-video-danmaku-setting-wrap,.bilibili-player.mode-fullscreen .bilibili-player-video-sendbar,.bpui-selectmenu-list{left:unset!important;bottom:38px!important}.bilibili-player-video-volumebar-wrp{left:unset!important}.bilibili-player-video-control-wrap{padding:0!important}.bilibili-player-video-control-bottom{padding:0!important;align-items:center!important}.bilibili-player-iconfont-next,.bilibili-player-iconfont-setting,.bilibili-player-video-btn-volume.video-state-volume-max .bilibili-player-iconfont-volume-max,.bilibili-player-video-btn-volume.video-state-volume-min .bilibili-player-iconfont-volume-min,.bilibili-player-video-btn-volume:not(.video-state-volume-max):not(.video-state-volume-min) .bilibili-player-iconfont-volume,.bilibili-player-video-control-bottom-left{display:flex!important;align-items:center!important}.bilibili-player-video-btn-danmaku{flex-grow:0!important;display:flex!important;align-items:center!important;height:100%!important;margin:0!important;padding:0!important}.bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-right{flex-grow:1!important}.bilibili-player.mode-fullscreen .bilibili-player-video-sendbar{bottom:0!important}.bilibili-player .bilibili-player-area .bilibili-player-video-control .bilibili-player-video-btn.bilibili-player-video-btn-fullscreen{margin-right:0!important;padding-right:8px!important}.bilibili-player .bilibili-player-area .bilibili-player-video-control .bilibili-player-video-btn.bilibili-player-video-btn-start{padding-left:8px!important;flex-grow:1.2!important;margin-right:0!important;margin-left:0!important}.bilibili-player .bilibili-player-area .bilibili-player-video-control .bilibili-player-video-btn{padding:0 3px!important}.bilibili-player .bilibili-player-area .bilibili-player-video-control-bottom,.bilibili-player .bilibili-player-area .bilibili-player-video-control-bottom-right,.bilibili-player-video-control-bottom-left{height:100%!important;margin:0!important}.bilibili-player-video-btn-setting-panel-hover-bridge{display:none!important}.disable-original-hover .bilibili-player-video-control-wrap:hover .bilibili-player-video-control-top .bilibili-player-video-progress-slider,.disable-original-hover.bilibili-player-area.video-control-show .bilibili-player-video-control-top .bilibili-player-video-progress-slider{height:2px!important}.disable-original-hover.bilibili-player-area .bilibili-player-video-control .bilibili-player-video-progress-detail.show{bottom:1px!important}.disable-original-hover.bilibili-player-area .subtitle-position.subtitle-position-bc,.disable-original-hover.bilibili-player-area .subtitle-position.subtitle-position-bl,.disable-original-hover.bilibili-player-area .subtitle-position.subtitle-position-br{bottom:20px!important}.disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-bc,.disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-bl,.disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-br{bottom:44px!important}.bilibili-player.mode-fullscreen .disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-bc,.bilibili-player.mode-fullscreen .disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-bl,.bilibili-player.mode-fullscreen .disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-br,.bilibili-player.mode-webfullscreen .disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-bc,.bilibili-player.mode-webfullscreen .disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-bl,.bilibili-player.mode-webfullscreen .disable-original-hover.touch-video-control-show .subtitle-position.subtitle-position-br{bottom:60px!important}.bilibili-player .bilibili-player-area:not(.disable-original-hover) .bilibili-player-video-control-wrap:hover .bilibili-player-video-control-top .bilibili-player-video-progress-slider,.bilibili-player .bilibili-player-area:not(.disable-original-hover).video-control-show .bilibili-player-video-control-top .bilibili-player-video-progress-slider{height:74px!important}.bilibili-player.mode-fullscreen .disable-original-hover .bilibili-player-video-control-top{opacity:1!important}#bofqi *{-webkit-tap-highlight-color:transparent!important}@media screen and (min-width:750px){.bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-center .bilibili-player-video-sendbar .bilibili-player-video-inputbar,.bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-center .bilibili-player-video-sendbar .bilibili-player-video-inputbar{background:#fff1!important}.bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control,.bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control{height:100%!important;margin:0!important}.bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom,.bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom{margin:0!important}.bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-left,.bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-left{height:100%!important}.bilibili-player-video-btn.bilibili-player-video-btn-start{flex-grow:.5!important}.player .bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-top,.player .bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-top{left:0!important;right:0!important}.player .bilibili-player.mode-fullscreen .disable-original-hover.bilibili-player-video-control-wrap .bilibili-player-video-control-top,.player .bilibili-player.mode-webfullscreen .disable-original-hover.bilibili-player-video-control-wrap .bilibili-player-video-control-top{left:0!important;right:0!important;bottom:0!important}.player .bilibili-player.mode-fullscreen .disable-original-hover.touch-video-control-show .bilibili-player-video-control-top,.player .bilibili-player.mode-webfullscreen .disable-original-hover.touch-video-control-show .bilibili-player-video-control-top{left:0!important;right:0!important;bottom:54px!important}.mode-fullscreen .bilibili-player-area.mouse-hover:not(.disable-original-hover) .bilibili-player-video-control-top,.mode-fullscreen .bilibili-player-area.video-control-show:not(.disable-original-hover) .bilibili-player-video-control-top,.mode-webfullscreen .bilibili-player-area.mouse-hover:not(.disable-original-hover) .bilibili-player-video-control-top,.mode-webfullscreen .bilibili-player-area.video-control-show:not(.disable-original-hover) .bilibili-player-video-control-top{left:0!important;right:0!important;bottom:48px!important}}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-player.min.js"] = (()=>{return(t,e)=>{const i=t=>{let e=0;let i=0;while(t&&!isNaN(t.offsetLeft)&&!isNaN(t.offsetTop)){e+=t.offsetLeft-t.scrollLeft;i+=t.offsetTop-t.scrollTop;t=t.offsetParent}return{x:e,y:i}};const s=t=>{t=Math.abs(t);const e=Math.floor(t/3600);const i=Math.floor((t-e*3600)/60);const s=t-e*3600-i*60;let o=fixed(s)+"秒";if(i>0){o=i+"分"+o}if(e>0){o=e+"时"+o}return o};const o=t=>{t=Math.abs(t);const e=Math.floor(t/3600);const i=Math.floor((t-e*3600)/60);const s=t-e*3600-i*60;let o=(s<10?"0":"")+fixed(s);o=(i<10?"0":"")+i+":"+o;o=(e<10?"0":"")+e+":"+o;return o};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",e=>{if(!this.xDown||!this.yDown){return}const s=e.touches[0].clientX;const o=e.touches[0].clientY;const n=i(t);const l={x:(e.touches[0].pageX-n.x)/t.clientWidth,y:(e.touches[0].pageY-n.y)/t.clientHeight,width:t.clientWidth,height:t.clientHeight};const a=this.xDown-s;const c=this.yDown-o;if(!this.direction){let t="";if(Math.abs(a)>Math.abs(c)){t="horizontal"}else{t="vertical"}this.direction=t}else{if(this.direction==="vertical"){this.action.startAction(this.direction,c,l)}else if(this.direction==="horizontal"){this.action.startAction(this.direction,-a,l)}}if(e.cancelable){e.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.volumeUp=null;this.volumeDown=null;this.brightnessUp=null;this.brightnessDown=null;this.speedCancel=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",()=>{this.touchStart=true});t.addEventListener("touchend",()=>{this.startPosition=null;this.onActionEnd&&this.onActionEnd(this.lastAction);this.lastAction=null})}startAction(t,e,i){if(this.touchStart){this.onActionStart&&this.onActionStart(t);this.startPosition=i;this.touchStart=false}if(t==="vertical"){let t;let s;if(this.startPosition.x<1/2){t=this.brightnessUp;s=this.brightnessDown;const o=Math.round(200*(e-this.minSwipeDistance)/(1.5*i.height));if(e>0){t&&t(o)}else{s&&s(o)}this.lastAction={type:"brightness",brightness:o}}else{t=this.volumeUp;s=this.volumeDown;const o=Math.round(200*(e-this.minSwipeDistance)/(1.5*i.height));if(e>0){t&&t(o)}else{s&&s(o)}this.lastAction={type:"volume",volume:o}}}else if(t==="horizontal"){if(i.y<1/3&&(i.x<.1||i.x>.9)){this.speedCancel&&this.speedCancel();this.lastAction=null}else{let t=0;let i;let s;if(this.startPosition.y<1/3){t=.05;i=this.lowSpeedForward;s=this.lowSpeedBackward}else if(this.startPosition.y>=1/3&&this.startPosition.y<=2/3){t=.2;i=this.mediumSpeedForward;s=this.mediumSpeedBackward}else{t=1;i=this.highSpeedForward;s=this.highSpeedBackward}if(e>0){const s=(e-this.minSwipeDistance)*t;i&&i(s);this.lastAction={type:"playback",seconds:s}}else{const i=(e+this.minSwipeDistance)*t;s&&s(i);this.lastAction={type:"playback",seconds:i}}}}}}class a{constructor(){this.aid=unsafeWindow.aid;this.cid=unsafeWindow.cid;this.cidData=null;this.supportWebp=a.supportWebp}getVideoshot(t,e){if(!(this.aid&&this.cid)){return}if(!this.cidData){Ajax.getText(`https://api.bilibili.com/x/player/videoshot?aid=${this.aid}&cid=${this.cid}&index=1`).then(i=>{this.cidData=JSON.parse(i).data;this.getVideoshot(t,e)})}else{const i=this.cidData;const s=i.index;let o=0;for(let e=0;e=s[e]&&tt.replace(".jpg",".jpg@.webp"))}const l=parseInt(i.pv_x_len)||10;const a=parseInt(i.pv_y_len)||10;const c=parseInt(i.pv_x_size)||160;const r=parseInt(i.pv_y_size)||90;const h=-(o%100%l)*c;const d=-Math.floor(o%100/a)*r;e({width:c,height:r,backgroundImage:`url(${n[Math.floor(o/100)]})`,backgroundPosition:`${h}px ${d}px`})}}static get supportWebp(){try{const t=document.createElement("canvas");if(t.getContext&&t.getContext("2d")){try{return t.toDataURL("image/webp").indexOf("data:image/webp")===0}catch(t){return false}}else{return false}}catch(t){return false}}}function c(t){t.unbind("click")}function r(t){if($(".touch-video-box").length!==0){return}$(".bilibili-player-video-subtitle").before(`\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
`);let e=$("video");const i=e.prop("duration");const l=new n(t.get(0));const c=document.querySelector(".touch-video-info");const r=document.querySelector(".touch-video-box");let h=100;let d=Math.round(e.prop("volume")*100);const u=t=>{t/=100;if(t<0){t=0}else if(t>1){t=1}e.prop("volume",t);$(".bilibili-player-video-volume-num").text(Math.round(t*100));$(".bui-thumb").css("transform",`translateY(-${48*t}px)`);$(".bui-track-vertical .bui-bar").css("transform",`scaleY(${t})`);if(t===0){$(".bilibili-player-video-btn-volume").addClass("video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-max");e.prop("muted",true)}else if(t===1){$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-min");$(".bilibili-player-video-btn-volume").addClass("video-state-volume-max");e.prop("muted",false)}else{$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-max");e.prop("muted",false)}};l.action.onActionStart=(t=>{r.classList.add("adjust-opened");c.classList[t==="vertical"?"remove":"add"]("speed");e=$("video");d=Math.round(e.prop("volume")*100);const i=e.css("filter").match(/brightness\((.+)\)/);h=Math.trunc((i?i[1]:1)*100)});const p=new a;const v=t=>{return n=>{const l=e.prop("currentTime");const a=fixed(100*l/i);let r=l+n;let h=fixed(100*r/i);let d=n;if(r>i){r=i;h=100;d=i-l}else if(r<0){r=0;h=0;d=l}const u=`${o(l)} (${a}%)
👇
${o(r)} (${h}%)`;c.classList.remove("cancel");c.querySelector(".touch-speed").innerHTML=`${t}速`;c.querySelector(".touch-info").innerHTML=`进度: ${n>0?"+":"-"}${s(d)}`;c.querySelector(".touch-result").innerHTML=u;p.getVideoshot(r,t=>$(".videoshot").css(t));$(".touch-progress").css("width",`${h}%`)}};l.action.lowSpeedBackward=v("低");l.action.lowSpeedForward=v("低");l.action.mediumSpeedBackward=v("中");l.action.mediumSpeedForward=v("中");l.action.highSpeedBackward=v("高");l.action.highSpeedForward=v("高");const f=t=>{let e=d+t;let i=Math.abs(t);if(e>100){e=100;i=100-d}else if(e<0){e=0;i=d}const s=`${d} 👉 ${e}`;u(e);c.classList.remove("cancel");c.querySelector(".touch-info").innerHTML=`音量: ${t>0?"+":"-"}${i}`;c.querySelector(".touch-result").innerHTML=s;$(".touch-progress").css("width",`${e}%`)};l.action.volumeUp=f;l.action.volumeDown=f;const b=t=>{let i=h+t;let s=Math.abs(t);if(i>100){i=100;s=100-h}else if(i<0){i=0;s=h}const o=`${h} 👉 ${i}`;e.css("filter",`brightness(${i/100})`);c.classList.remove("cancel");c.querySelector(".touch-info").innerHTML=`亮度: ${t>0?"+":"-"}${s}`;c.querySelector(".touch-result").innerHTML=o;$(".touch-progress").css("width",`${i}%`)};l.action.brightnessUp=b;l.action.brightnessDown=b;l.action.speedCancel=(()=>{c.querySelector(".touch-info").innerHTML=`取消时间调整`;c.classList.add("cancel")});l.action.onActionEnd=(t=>{if(!unsafeWindow.touchPlayerDebug){if(t){if(t.type==="playback"){let s=e.prop("currentTime");s+=t.seconds;if(s<0){s=0}else if(s>i){s=i}e.prop("currentTime",s)}else if(t.type==="volume"){const t=JSON.parse(localStorage.bilibili_player_settings);t.video_status.volume=e.prop("volume");localStorage.bilibili_player_settings=JSON.stringify(t)}}r.classList.remove("adjust-opened")}})}function h(t){if(!t.hasClass("disable-original-hover")){t.addClass("disable-original-hover");const e=unsafeWindow.$(".bilibili-player-video");const i="touch-video-control-show";const s=e.data("events").click[0].handler;const o=new DoubleClickEvent(t=>s(t),()=>t.toggleClass(i));e.unbind("click");o.bind(e[0])}}const d=()=>{SpinQuery.any(()=>$(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),c);SpinQuery.condition(()=>$(".bilibili-player-video"),t=>t.length>0&&$("video").length>0&&$("video").prop("duration"),r);if(t.touchVideoPlayerDoubleTapControl){new SpinQuery(()=>$(".bilibili-player-area"),t=>t.length>0&&unsafeWindow.$&&unsafeWindow.$(".bilibili-player-video").data("events"),h).start()}};Observer.videoChange(d);e.applyStyle("touchPlayerStyle")}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/tweets.min.css"] = `.nav-search-submit{display:block!important;color:var(--foreground-color-d)!important;transform:translateX(-125px);-webkit-tap-highlight-color:transparent}.nav-search-submit:hover{color:var(--foreground-color)!important}#nav_searchform{transition:.3s ease-out;box-shadow:none;width:0!important;padding:0!important}.preserve-rank>a{opacity:0!important;pointer-events:none}.showSearch .preserve-rank>a{opacity:.382!important;pointer-events:initial}.showSearch #nav_searchform{box-shadow:0 2px 10px 1px #0002;width:250px!important}.showSearch .nav-search-submit,.showSearch .nav-search-submit:hover{color:#888!important;transform:none}@media only screen and (max-width:1291px){.showSearch #nav_searchform{width:140px!important}}`; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/v-dropdown.vue.min.js"] = (()=>{return(o,e)=>{const n=`
{{ value }}
`;e.applyStyleFromText(`.v-dropdown{position:relative;background-color:#8884;cursor:pointer;display:flex;align-items:center;justify-content:space-between;min-width:100px}.v-dropdown .dropdown-menu{transform-origin:top;transform:scaleY(0) translateX(-50%);position:absolute;top:calc(100% + 2px);left:50%;background-color:var(--download-video-background);z-index:1;transition:.2s cubic-bezier(.6,-.28,.74,.05);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0}.v-dropdown .dropdown-menu.opened{transform:scaleY(1) translateX(-50%);transition-timing-function:cubic-bezier(.18,.89,.32,1.28)}.v-dropdown .dropdown-menu li{padding:4px 8px;white-space:nowrap;min-width:80px;text-align:center;cursor:pointer;color:var(--download-video-foreground);background-color:transparent}.v-dropdown .dropdown-menu li:hover{background-color:rgba(0,0,0,.16)}.v-dropdown .mdi-chevron-down{font-size:16pt;line-height:1;transform:rotate(0)}.v-dropdown .dropdown-menu.opened~.mdi-chevron-down{transform:rotate(180deg)}.v-dropdown .selected{user-select:none;padding:4px 8px}`,"v-dropdown-style");return{export:Object.assign({template:n},{props:["items","value"],data(){return{dropdownOpen:false}},methods:{toggleDropdown(){this.dropdownOpen=!this.dropdownOpen},select(o){this.$emit("update:value",o);this.$emit("change",o)}}})}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/v-checkbox.vue.min.js"] = (()=>{return(e,c)=>{const i=`
{{title}}
`;c.applyStyleFromText(`.v-checkbox{font-size:10pt;cursor:pointer;display:flex;align-items:center}.v-checkbox .mdi{font-size:15pt;line-height:1}.v-checkbox .content{flex-grow:1;text-align:left;padding:0 8px}.v-checkbox .mdi-checkbox-marked-circle{color:var(--theme-color);position:absolute;top:0;left:0;transform:scale(0);transition-timing-function:cubic-bezier(.6,-.28,.74,.05)}.v-checkbox .mdi-checkbox-blank-circle-outline{color:#8884;position:relative}.v-checkbox.checked .mdi-checkbox-blank-circle-outline{color:var(--theme-color)}.v-checkbox.checked .mdi-checkbox-marked-circle{transform:scale(1);transition-timing-function:cubic-bezier(.18,.89,.32,1.28)}`,"v-checkbox-style");return{export:Object.assign({template:i},{props:["checked","title"],methods:{toggleCheck(){this.$emit("update:checked",!this.checked)}}})}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/v-dropdown.vue.min.js"] = (()=>{return(o,e)=>{const n=`
{{ value }}
`;e.applyStyleFromText(`.v-dropdown{position:relative;background-color:#8884;cursor:pointer;display:flex;align-items:center;justify-content:space-between;min-width:100px}.v-dropdown .dropdown-menu{transform-origin:top;transform:scaleY(0) translateX(-50%);position:absolute;top:calc(100% + 2px);left:50%;background-color:var(--download-video-background);z-index:1;transition:.2s cubic-bezier(.6,-.28,.74,.05);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0}.v-dropdown .dropdown-menu.opened{transform:scaleY(1) translateX(-50%);transition-timing-function:cubic-bezier(.18,.89,.32,1.28)}.v-dropdown .dropdown-menu li{padding:4px 8px;white-space:nowrap;min-width:80px;text-align:center;cursor:pointer;color:var(--download-video-foreground);background-color:transparent}.v-dropdown .dropdown-menu li:hover{background-color:rgba(0,0,0,.16)}.v-dropdown .mdi-chevron-down{font-size:16pt;line-height:1;transform:rotate(0)}.v-dropdown .dropdown-menu.opened~.mdi-chevron-down{transform:rotate(180deg)}.v-dropdown .selected{user-select:none;padding:4px 8px}.round-corner .v-dropdown,.round-corner .v-dropdown .dropdown-menu,.round-corner .v-dropdown .dropdown-menu li{border-radius:var(--corner-radius)}`,"v-dropdown-style");return{export:Object.assign({template:n},{props:["items","value"],data(){return{dropdownOpen:false}},methods:{toggleDropdown(){this.dropdownOpen=!this.dropdownOpen},select(o){this.$emit("update:value",o);this.$emit("change",o)}}})}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/video-info.min.js"] = (()=>{return(t,i)=>{class e{constructor(t){this.aid=t}async fetchInfo(){const t=JSON.parse(await Ajax.getText(`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 s(this.cid.toString());return this.danmaku.fetchInfo()}}class a{constructor(t,i){this.text=t;this.p=i}}class s{constructor(t){this.cid=t}async fetchInfo(){const t=await Ajax.getText(`https://api.bilibili.com/x/v1/dm/list.so?oid=${this.cid}`);this.rawXML=t;const i=(new DOMParser).parseFromString(t,"application/xml").documentElement;this.xml=i;this.danmakus=[...i.querySelectorAll("d[p]")].map(t=>{return new a(t.innerHTML,t.getAttribute("p"))})}}class n{constructor(t){this.ep=t;this.videos=[]}async fetchInfo(){const t=await Ajax.getText(`https://www.bilibili.com/bangumi/play/ep${this.ep}/`);const i=JSON.parse(t.match(/window\.__INITIAL_STATE__=(.*);\(function\(\){/)[1]);this.title=i.mediaInfo.title;this.cover=i.mediaInfo.cover;this.squareCover=i.mediaInfo.square_cover;this.aid=i.epInfo.aid;this.cid=i.epInfo.cid;this.videos=i.epList.map(async t=>{return{title:t.index_title,aid:t.aid,cid:t.cid,info:await new e(t.aid).fetchInfo()}});return this}}return{export:{VideoInfo:e,BangumiInfo:n,Danmaku:a,DanmakuInfo:s}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/video-story.min.js"] = (()=>{return(t,i)=>{class e{constructor(t){this.title=t.option;this.nodeID=t.node_id;this.cid=t.cid;this.default=t.is_default===1}}class s{constructor(t,i,e){this.title=t.title;this.nodeID=t.node_id;this.aid=i;this.cid=t.cid;this.graphVersion=e;this.choices=[];this.choiceTime=-1}async getChoices(){if(this.choices.length>0){return}const t=`https://api.bilibili.com/x/stein/nodeinfo?aid=${this.aid}&node_id=${this.nodeID}&graph_version=504`;const i=await Ajax.getJsonWithCredentials(t);if(i.code!==0){console.error(`获取选项失败: ${i.message}`);return}this.choices=i.data.edges.choices.map(t=>new e(t))}}class o{constructor(t,i){this.nodeList=t;if(i){this.startingNode=i}else{[this.startingNode]=t}}async getAllChoices(){return await Promise.all(this.nodeList.map(t=>t.getChoices()))}}const n=async(t,i)=>{const n=`https://api.bilibili.com/x/stein/nodeinfo?aid=${t}&graph_version=${i}`;const c=await Ajax.getJsonWithCredentials(n);if(c.code!==0){return c.message}const a=c.data.story_list.map(e=>new s(e,t,i));const d=a.find(t=>t.nodeID===c.data.node_id);if(!d){return"获取起始结点失败"}d.choiceTime=c.data.edges.show_time;const r=c.data.edges.choices.map(t=>new e(t));d.choices=r;return new o(a,d)};return{export:{StoryChoice:e,StoryNode:s,Story:o,getStoryNodes:n}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{const{VideoInfo:i}=t.import("video-info");const{getFriendlyTitle:n}=t.import("title");class o{constructor(e){this.url=e;if(document.querySelector(".image-viewer")===null){this.createContainer()}this.viewer=document.querySelector(".image-viewer-container");this.downloadImage();addSettingsListener("filenameFormat",()=>{this.viewer.querySelector(".download").setAttribute("download",this.filename)})}createContainer(){document.body.insertAdjacentHTML("beforeend",t.import("imageViewerHtml"));document.querySelector(".image-viewer-container .close").addEventListener("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){document.querySelector("#view-cover").style.display=this.url?"flex":"none";if(this.url===""){return}const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=URL.createObjectURL(e.response);if(this.imageData){URL.revokeObjectURL(this.imageData)}this.imageData=t;const i=this.viewer.querySelector(".download");i.setAttribute("href",t);i.setAttribute("download",this.filename);this.viewer.querySelector(".copy-link").addEventListener("click",()=>GM_setClipboard(this.url));this.viewer.querySelector(".new-tab").setAttribute("href",this.url);this.viewer.querySelector(".image").src=t});e.send()}show(){this.viewer.classList.add("opened")}hide(){this.viewer.classList.remove("opened")}get filename(){return n(document.URL.includes("/www.bilibili.com/bangumi/"))+this.url.substring(this.url.lastIndexOf("."))}}return(()=>{if(!document.URL.includes("live.bilibili.com")){return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);return Boolean(e)},success:async()=>{async function e(){const e=(unsafeWindow||window).aid;const t=new i(e);try{await t.fetchInfo()}catch(e){return""}return t.coverUrl}let t=new o(await e());document.querySelector("#view-cover").addEventListener("click",()=>{t.show()});const n=async()=>{t=new o(await e())};Observer.videoChange(n)}}}}else{return{widget:{content:`\n \n \n 查看封面\n `,condition:async()=>{const e=await SpinQuery.select(()=>document.querySelector(".header-info-ctnr .room-cover"));return Boolean(e)},success:async()=>{const e=document.querySelector(".header-info-ctnr .room-cover");const t=e.getAttribute("href").match(/space\.bilibili\.com\/([\d]+)/);if(t&&t[1]){const e=t[1];const i=`https://api.live.bilibili.com/room/v1/Room/getRoomInfoOld?mid=${e}`;const n=await Ajax.getJson(i);const r=n.data.cover;const s=new o(r);document.querySelector("#view-cover").addEventListener("click",()=>{s.show()})}}}}}})()}})(); @@ -1901,6 +1902,12 @@ Resource.manifest = { vDropdown: '下拉框组件', }, }, + vCheckbox: { + path: 'v-checkbox.vue.min.js', + displayNames: { + vCheckbox: '复选框组件', + }, + }, doubleClickFullscreen: { path: 'double-click-fullscreen.min.js', displayNames: { diff --git a/bilibili-evolved.preview.user.js b/bilibili-evolved.preview.user.js index 8d993b6e1..de9b2e53f 100644 --- a/bilibili-evolved.preview.user.js +++ b/bilibili-evolved.preview.user.js @@ -1795,6 +1795,12 @@ Resource.manifest = { vDropdown: '下拉框组件', }, }, + vCheckbox: { + path: 'v-checkbox.vue.min.js', + displayNames: { + vCheckbox: '复选框组件', + }, + }, doubleClickFullscreen: { path: 'double-click-fullscreen.min.js', displayNames: { diff --git a/bilibili-evolved.user.js b/bilibili-evolved.user.js index 17d13d178..fd1bcdb24 100644 --- a/bilibili-evolved.user.js +++ b/bilibili-evolved.user.js @@ -1795,6 +1795,12 @@ Resource.manifest = { vDropdown: '下拉框组件', }, }, + vCheckbox: { + path: 'v-checkbox.vue.min.js', + displayNames: { + vCheckbox: '复选框组件', + }, + }, doubleClickFullscreen: { path: 'double-click-fullscreen.min.js', displayNames: { diff --git a/min/download-video.min.css b/min/download-video.min.css index 1d926d75e..0d5f010d6 100644 --- a/min/download-video.min.css +++ b/min/download-video.min.css @@ -1 +1 @@ -.download-video.opened{pointer-events:initial;opacity:1;transform:translate(-50%,-50%) scale(1)}.download-video{--download-video-background:white;--download-video-foreground:black;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .title,.round-corner .download-video button,.round-corner .v-dropdown,.round-corner .v-dropdown .dropdown-menu,.round-corner .v-dropdown .dropdown-menu li{border-radius:var(--corner-radius)}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video .cover{width:240px;min-height:135px;background-color:#8882}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video h1{font-size:16pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding-top:12px;font-size:10pt}.download-video .tabs .tab{padding:6px 12px;border-bottom:2px solid transparent;cursor:pointer}.download-video .tab.active{color:var(--theme-color);border-bottom-color:var(--theme-color)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0}.download-video h2{font-size:12pt;font-weight:700;color:var(--download-video-foreground)}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}.download-video .direct-download .progress .percent{width:50px;text-align:right}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(50% - 16px);display:flex;justify-content:center;align-items:center}.download-video i.mdi-alert-circle{font-size:14pt;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:300px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.v-checkbox{font-size:10pt;cursor:pointer;display:flex;align-items:center}.v-checkbox .mdi{font-size:15pt;line-height:1}.v-checkbox .content{flex-grow:1;text-align:left;padding:0 8px}.v-checkbox .mdi-checkbox-marked-circle{color:var(--theme-color);position:absolute;top:0;left:0;transform:scale(0);transition-timing-function:cubic-bezier(.6,-.28,.74,.05)}.v-checkbox .mdi-checkbox-blank-circle-outline{color:#8884;position:relative}.v-checkbox.checked .mdi-checkbox-blank-circle-outline{color:var(--theme-color)}.v-checkbox.checked .mdi-checkbox-marked-circle{transform:scale(1);transition-timing-function:cubic-bezier(.18,.89,.32,1.28)}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:var(--download-video-background);bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%);opacity:0;pointer-events:none;padding:8px;z-index:3}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;pointer-events:initial}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center} \ No newline at end of file +.download-video{--download-video-background:white;--download-video-foreground:black;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;max-height:90%;overflow:auto}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translate(-50%,-50%) scale(1)}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{width:240px;min-height:135px;background-color:#8882}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video h1{font-size:16pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding-top:12px;font-size:10pt}.download-video .tabs .tab{padding:6px 12px;border-bottom:2px solid transparent;cursor:pointer}.download-video .tabs .tab.active{color:var(--theme-color);border-bottom-color:var(--theme-color)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video h2{font-size:12pt;font-weight:700;color:var(--download-video-foreground)}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(50% - 16px);display:flex;justify-content:center;align-items:center}.download-video i.mdi-alert-circle{font-size:14pt;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:300px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:var(--download-video-background);bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%);opacity:0;pointer-events:none;padding:8px;z-index:3}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;pointer-events:initial}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))} \ No newline at end of file diff --git a/min/download-video.min.js b/min/download-video.min.js index 03cc63171..1c81cb38f 100644 --- a/min/download-video.min.js +++ b/min/download-video.min.js @@ -1 +1 @@ -(()=>{return(e,t)=>{const{getFriendlyTitle:s}=t.import("title");const{VideoInfo:i,DanmakuInfo:a}=t.import("video-info");class n{constructor(){this.menuClasses=["quality","action","progress"];[this.currentMenuClass]=this.menuClasses}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}closeMenu(){this.menuPanel.classList.remove("opened");setTimeout(()=>this.resetMenuClass(),200)}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=${r.aid}&cid=${r.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${r.aid}&cid=${r.cid}&otype=json`}}}class o extends n{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${r.aid}&cid=${r.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${r.aid}&cid=${r.cid}&qn=&otype=json`}}}const r={entity:new n,aid:"",cid:""};let l=[];let c=null;class d{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new u(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{r.entity.getUrl().then(s=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{const s=JSON.parse(i.responseText);if(s.code!==0){t("获取清晰度信息失败.");return}const a=s.data||s.result||s;const n=a.accept_quality;const o=a.accept_format.split(",");const r=a.accept_description;const l=[];while(n.length>0){const e=new d(n.pop(),o.pop(),r.pop());l.push(e)}e(l.reverse())});i.addEventListener("error",()=>t(`获取清晰度信息失败.`));i.withCredentials=true;i.open("GET",s);i.send()})})}}class h{constructor(e,t,s,i){this.length=e;this.size=t;this.url=s;this.backupUrls=i}}class u{constructor(e,t){this.fragmentSplitFactor=6*5;this.workingXhr=null;this.progressMap=new Map;this.format=e;this.fragments=t||[];this.videoSpeed=new p(this)}get totalSize(){return this.fragments.map(e=>e.size).reduce((e,t)=>e+t)}fetchVideoInfo(){return new Promise((e,t)=>{r.entity.getUrl(this.format.quality).then(s=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{const s=JSON.parse(i.responseText.replace(/http:/g,"https:"));const a=s.data||s.result||s;if(a.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const n=a.durl;this.fragments=n.map(e=>new h(e.length,e.size,e.url,e.backup_url));e(this.fragments)});i.withCredentials=true;i.open("GET",s);i.send()})})}updateProgress(){const e=this.progressMap?[...this.progressMap.values()].reduce((e,t)=>e+t,0)/this.totalSize:0;if(e>1||e<0){console.error(`[下载视频] 进度异常: ${e}`,this.progressMap.values())}this.progress&&this.progress(e)}cancelDownload(){this.videoSpeed.stopMeasure();if(this.workingXhr!==null){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const s=16*1024*1024;let i=0;const a=e=>[...this.progressMap.keys()].indexOf(e)+1;while(i{const i=new XMLHttpRequest;i.open("GET",e.url);i.responseType="arraybuffer";i.withCredentials=false;i.addEventListener("progress",e=>{console.log(`[下载视频] 视频片段${a(i)}下载进度: ${e.loaded}/${r} bytes loaded, ${o}`);this.progressMap.set(i,e.loaded);this.updateProgress()});i.addEventListener("load",()=>{if((""+i.status)[0]==="2"){console.log(`[下载视频] 视频片段${a(i)}下载完成`);t(i.response)}else{s(`视频片段${a(i)}请求失败, response = ${i.status}`)}});i.addEventListener("abort",()=>s("canceled"));i.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${a(i)}下载失败: ${o}`);this.progressMap.set(i,0);this.updateProgress();i.open("GET",e.url);i.setRequestHeader("Range",o);i.send()});i.setRequestHeader("Range",o);this.progressMap.set(i,0);i.send();this.workingXhr.push(i)}));i=Math.round(i+s)+1}return Promise.all(t)}async copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}static downloadBlob(e,t){const s=document.createElement("a");let i;if(typeof e==="string"){i=e}else{i=URL.createObjectURL(e)}s.setAttribute("href",i);s.setAttribute("download",t);document.body.appendChild(s);s.click();s.remove();URL.revokeObjectURL(i)}async exportData(e=false){const t=JSON.stringify([{fragments:this.fragments,title:s(),totalSize:this.fragments.map(e=>e.size).reduce((e,t)=>e+t),referer:document.URL.replace(window.location.search,"")}]);if(e){GM_setClipboard(t,"text")}else{const e=new Blob([t],{type:"text/json"});const i=await this.downloadDanmaku();if(i!==null){const t=new JSZip;t.file(`${s()}.json`,e);t.file(s()+"."+this.danmakuOption.toLowerCase(),i);u.downloadBlob(await t.generateAsync({type:"blob"}),`${s()}.zip`)}else{u.downloadBlob(e,`${s()}.json`)}}}async exportAria2(i=false){if(i){const i=await this.downloadDanmaku();if(i!==null){u.downloadBlob(new Blob([i]),`${s()}.${this.danmakuOption==="ASS"?"ass":"xml"}`)}const a=e.aria2RpcOption;const n=this.fragments.map((e,t)=>{let i="";if(this.fragments.length>1){i=" - "+(t+1)}const n=[];if(a.secretKey!==""){n.push(`token:${a.secretKey}`)}n.push([e.url]);n.push({referer:document.URL.replace(window.location.search,""),"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0",out:`${s()}${i}${this.extension(e)}`,split:this.fragmentSplitFactor,dir:a.dir||undefined,"max-download-limit":a.maxDownloadLimit||undefined});const o=encodeURIComponent(`${s()}${i}`);return{params:n,id:o}});const{sendRpc:o}=await t.importAsync("aria2-rpc");await o(n)}else{const e=`\n# Generated by Bilibili Evolved Video Export\n# https://github.com/the1812/Bilibili-Evolved/\n${this.fragments.map((e,t)=>{let i="";if(this.fragments.length>1){i=" - "+(t+1)}return`\n${e.url}\n referer=${document.URL.replace(window.location.search,"")}\n user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0\n out=${s()}${i}${this.extension(e)}\n split=${this.fragmentSplitFactor}\n `.trim()}).join("\n")}\n `.trim();const t=new Blob([e],{type:"text/plain"});const i=await this.downloadDanmaku();if(i!==null){const e=new JSZip;e.file(`${s()}.txt`,t);e.file(s()+"."+this.danmakuOption.toLowerCase(),i);u.downloadBlob(await e.generateAsync({type:"blob"}),`${s()}.zip`)}else{u.downloadBlob(t,`${s()}.txt`)}}}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=dq("a#video-complete").getAttribute("href");if(e&&!dq(`.link[href="${e}"]`)){URL.revokeObjectURL(e)}dqa(".toast-card-header").filter(e=>e.innerText.includes("下载视频")).forEach(e=>e.querySelector(".toast-card-dismiss").click())}async downloadDanmaku(){if(this.danmakuOption!=="无"){const e=new a(r.cid);await e.fetchInfo();if(this.danmakuOption==="XML"){return e.rawXML}else{const{convertToAss:s}=await t.importAsync("download-danmaku");return s(e.rawXML)}}else{return null}}async downloadSingle(e){const t=await this.downloadDanmaku();const[i]=e;if(t===null){const e=this.makeBlob(i);const t=s()+this.extension();return{blob:e,filename:t}}else{const e=new JSZip;e.file(s()+this.extension(),this.makeBlob(i));e.file(s()+"."+this.danmakuOption.toLowerCase(),t);const a=await e.generateAsync({type:"blob"});const n=s()+".zip";return{blob:a,filename:n}}}async downloadMultiple(e){const t=new JSZip;const i=s();if(e.length>1){e.forEach((e,s)=>{const a=this.fragments[s];t.file(`${i} - ${s+1}${this.extension(a)}`,this.makeBlob(e,a))})}else{const[s]=e;t.file(`${i}${this.extension()}`,this.makeBlob(s))}const a=await this.downloadDanmaku();if(a!==null){t.file(s()+"."+this.danmakuOption.toLowerCase(),a)}const n=await t.generateAsync({type:"blob"});const o=i+".zip";return{blob:n,filename:o}}async download(){const e=[];this.videoSpeed.startMeasure();for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let{blob:t,filename:s}=await(async()=>{if(e.length===1){return await this.downloadSingle(e)}else{return await this.downloadMultiple(e)}})();this.cleanUpOldBlobUrl();const i=URL.createObjectURL(t);this.progress&&this.progress(0);this.videoSpeed.stopMeasure();return{url:i,filename:s}}}class p{constructor(e){this.lastProgress=0;this.measureInterval=1e3;this.workingDownloader=e}startMeasure(){this.intervalTimer=setInterval(()=>{const e=this.workingDownloader.progressMap?[...this.workingDownloader.progressMap.values()].reduce((e,t)=>e+t,0):0;const t=e-this.lastProgress;if(this.speedUpdate!==undefined){this.speedUpdate(formatFileSize(t)+"/s")}this.lastProgress=e},this.measureInterval)}stopMeasure(){clearInterval(this.intervalTimer)}}async function w(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);if(!(e&&t)){return false}r.aid=e;r.cid=t;if(document.URL.indexOf("bangumi")!==-1){r.entity=new o}else{r.entity=new n}try{l=await d.availableFormats}catch(e){return false}return true}async function f(){c=l[0];t.applyStyle("downloadVideoStyle");dq("#download-video").addEventListener("click",()=>{dq(".download-video").classList.toggle("opened");dq(".gui-settings-mask").click()});dq("#download-video").addEventListener("mouseover",()=>{document.body.insertAdjacentHTML("beforeend",t.import("downloadVideoHtml"));m()},{once:true})}async function m(){const n=await t.importAsync("v-dropdown.vue");Vue.component("v-checkbox",{template:`\n
\n \n \n \n {{title}}\n
\n `,props:["checked","title"],methods:{toggleCheck(){this.$emit("update:checked",!this.checked)}}});let o;const h=new Map;const p=new Vue({el:".download-video",components:{"v-dropdown":n},data:{downloadSingle:true,coverUrl:'data:image/svg+xml;utf-8,',aid:r.aid,cid:r.cid,qualityModel:{value:c.displayName,items:l.map(e=>e.displayName)},danmakuModel:{value:e.downloadVideoDefaultDanmaku,items:["无","XML","ASS"]},progressPercent:0,size:"获取大小中",blobUrl:"",episodeList:[],downloading:false,speed:"",batch:false,rpcSettings:e.aria2RpcOption,showRpcSettings:false,busy:false},computed:{displaySize(){if(typeof this.size==="string"){return this.size}return formatFileSize(this.size)},sizeWarning(){if(typeof this.size==="string"){return false}return this.size>1073741824},selectedEpisodeCount(){return this.episodeList.filter(e=>e.checked).length}},methods:{close(){this.$el.classList.remove("opened")},danmakuOptionChange(){e.downloadVideoDefaultDanmaku=this.danmakuModel.value},async formatChange(){const e=this.getFormat();const t=h.get(e);if(t){this.size=t;return}try{this.size="获取大小中";const t=await e.downloadInfo();this.size=t.totalSize;h.set(e,this.size)}catch(e){this.size="获取大小失败"}},getFormat(){const e=l.find(e=>e.displayName===this.qualityModel.value);if(!e){console.error(`No format found. model value = ${this.qualityModel.value}`);return null}return e},async exportData(e){if(this.busy===true){return}try{this.busy=true;if(!this.downloadSingle){await this.exportBatchData(e);return}const t=this.getFormat();const s=await t.downloadInfo();s.danmakuOption=this.danmakuModel.value;switch(e){case"copyLink":await s.copyUrl();Toast.success("已复制链接到剪贴板.","下载视频",3e3);break;case"aria2":await s.exportAria2(false);break;case"aria2RPC":await s.exportAria2(true);break;case"copyVLD":await s.exportData(true);Toast.success("已复制VLD数据到剪贴板.","下载视频",3e3);break;case"exportVLD":await s.exportData(false);break;default:break}}catch(e){logError(e)}finally{this.busy=false}},async exportBatchData(e){const i=this.episodeList;if(i.every(e=>e.checked===false)){Toast.info("请至少选择1集或以上的数量!","批量导出",3e3);return}const n=e=>{const t=i.find(t=>t.cid===e.cid);if(t===undefined){return false}return t.checked};const o=this.getFormat();if(this.danmakuModel.value!=="无"){const e=Toast.info("下载弹幕中...","批量导出");const s=new JSZip;try{if(this.danmakuModel.value==="XML"){for(const e of i.filter(n)){const t=new a(e.cid);await t.fetchInfo();s.file(e.title+".xml",t.rawXML)}}else{const{convertToAss:e}=await t.importAsync("download-danmaku");for(const t of i.filter(n)){const i=new a(t.cid);await i.fetchInfo();s.file(t.title+".ass",await e(i.rawXML))}}u.downloadBlob(await s.generateAsync({type:"blob"}),this.cid+".danmakus.zip")}catch(e){logError(`弹幕下载失败`)}finally{e.dismiss()}}const r=Toast.info("获取链接中...","批量导出");this.batchExtractor.itemFilter=n;let l;try{switch(e){case"aria2":l=await this.batchExtractor.collectAria2(o,r);u.downloadBlob(new Blob([l],{type:"text/plain"}),s(false)+".txt");return;case"aria2RPC":await this.batchExtractor.collectAria2(o,r,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);return;case"copyVLD":GM_setClipboard(await this.batchExtractor.collectData(o,r),{mimetype:"text/plain"});Toast.success("已复制批量vld数据到剪贴板.","批量导出",3e3);return;case"exportVLD":l=await this.batchExtractor.collectData(o,r);u.downloadBlob(new Blob([l],{type:"text/json"}),s(false)+".json");return;default:return}}catch(e){logError(e)}finally{r.dismiss()}},async checkBatch(){const e=["/www.bilibili.com/bangumi","/www.bilibili.com/video/av"];if(!e.some(e=>document.URL.includes(e))){this.batch=false;this.episodeList=[];return}const{BatchExtractor:s}=await t.importAsync("batch-download");if(await s.test()!==true){this.batch=false;this.episodeList=[];return}this.batchExtractor=new s;this.batch=true;this.episodeList=(await this.batchExtractor.getItemList()).map((e,t)=>{return{aid:e.aid,cid:e.cid,title:e.title,index:t,checked:true}})},cancelDownload(){if(o){o.cancelDownload()}},async startDownload(){const e=this.getFormat();try{this.downloading=true;const t=await e.downloadInfo();t.videoSpeed.speedUpdate=(e=>this.speed=e);t.danmakuOption=this.danmakuModel.value;t.progress=(e=>{this.progressPercent=Math.trunc(e*100)});o=t;const s=await t.download();const i=document.getElementById("video-complete");i.setAttribute("href",s.url);i.setAttribute("download",s.filename);i.click();Toast.success(`下载完成: ${s.filename} 再次保存`,"下载视频")}catch(e){if(e!=="canceled"){logError(e)}this.progressPercent=0}finally{this.downloading=false;this.speed=""}},selectAllEpisodes(){this.episodeList.forEach(e=>e.checked=true)},unselectAllEpisodes(){this.episodeList.forEach(e=>e.checked=false)},inverseAllEpisodes(){this.episodeList.forEach(e=>e.checked=!e.checked)},toggleRpcSettings(){this.showRpcSettings=!this.showRpcSettings},saveRpcSettings(){if(this.rpcSettings.host===""){this.rpcSettings.host="127.0.0.1"}if(this.rpcSettings.port===""){this.rpcSettings.port="6800"}e.aria2RpcOption=this.rpcSettings}}});Observer.videoChange(async()=>{p.close();p.batch=false;p.downloadSingle=true;const e=dq("#download-video");const t=await w();e.style.display=t?"flex":"none";if(!t){return}p.aid=r.aid;p.cid=r.cid;const s=new i(r.aid);await s.fetchInfo();p.coverUrl=s.coverUrl.replace("http:","https:");l=await d.availableFormats;[c]=l;p.qualityModel={value:c.displayName,items:l.map(e=>e.displayName)};p.formatChange();await p.checkBatch()})}return{widget:{content:`\n `,condition:w,success:f}}}})(); \ No newline at end of file +(()=>{return(e,t)=>{const{getFriendlyTitle:s}=t.import("title");const{VideoInfo:a,DanmakuInfo:i}=t.import("video-info");class n{constructor(){this.menuClasses=["quality","action","progress"];[this.currentMenuClass]=this.menuClasses}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}closeMenu(){this.menuPanel.classList.remove("opened");setTimeout(()=>this.resetMenuClass(),200)}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=${r.aid}&cid=${r.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${r.aid}&cid=${r.cid}&otype=json`}}}class o extends n{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${r.aid}&cid=${r.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${r.aid}&cid=${r.cid}&qn=&otype=json`}}}const r={entity:new n,aid:"",cid:""};let l=[];let c=null;class d{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new u(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{r.entity.getUrl().then(s=>{const a=new XMLHttpRequest;a.addEventListener("load",()=>{const s=JSON.parse(a.responseText);if(s.code!==0){t("获取清晰度信息失败.");return}const i=s.data||s.result||s;const n=i.accept_quality;const o=i.accept_format.split(",");const r=i.accept_description;const l=[];while(n.length>0){const e=new d(n.pop(),o.pop(),r.pop());l.push(e)}e(l.reverse())});a.addEventListener("error",()=>t(`获取清晰度信息失败.`));a.withCredentials=true;a.open("GET",s);a.send()})})}}class h{constructor(e,t,s,a){this.length=e;this.size=t;this.url=s;this.backupUrls=a}}class u{constructor(e,t){this.fragmentSplitFactor=6*5;this.workingXhr=null;this.progressMap=new Map;this.format=e;this.fragments=t||[];this.videoSpeed=new p(this)}get totalSize(){return this.fragments.map(e=>e.size).reduce((e,t)=>e+t)}fetchVideoInfo(){return new Promise((e,t)=>{r.entity.getUrl(this.format.quality).then(s=>{const a=new XMLHttpRequest;a.addEventListener("load",()=>{const s=JSON.parse(a.responseText.replace(/http:/g,"https:"));const i=s.data||s.result||s;if(i.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const n=i.durl;this.fragments=n.map(e=>new h(e.length,e.size,e.url,e.backup_url));e(this.fragments)});a.withCredentials=true;a.open("GET",s);a.send()})})}updateProgress(){const e=this.progressMap?[...this.progressMap.values()].reduce((e,t)=>e+t,0)/this.totalSize:0;if(e>1||e<0){console.error(`[下载视频] 进度异常: ${e}`,this.progressMap.values())}this.progress&&this.progress(e)}cancelDownload(){this.videoSpeed.stopMeasure();if(this.workingXhr!==null){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const s=16*1024*1024;let a=0;const i=e=>[...this.progressMap.keys()].indexOf(e)+1;while(a{const a=new XMLHttpRequest;a.open("GET",e.url);a.responseType="arraybuffer";a.withCredentials=false;a.addEventListener("progress",e=>{console.log(`[下载视频] 视频片段${i(a)}下载进度: ${e.loaded}/${r} bytes loaded, ${o}`);this.progressMap.set(a,e.loaded);this.updateProgress()});a.addEventListener("load",()=>{if((""+a.status)[0]==="2"){console.log(`[下载视频] 视频片段${i(a)}下载完成`);t(a.response)}else{s(`视频片段${i(a)}请求失败, response = ${a.status}`)}});a.addEventListener("abort",()=>s("canceled"));a.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${i(a)}下载失败: ${o}`);this.progressMap.set(a,0);this.updateProgress();a.open("GET",e.url);a.setRequestHeader("Range",o);a.send()});a.setRequestHeader("Range",o);this.progressMap.set(a,0);a.send();this.workingXhr.push(a)}));a=Math.round(a+s)+1}return Promise.all(t)}async copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}static downloadBlob(e,t){const s=document.createElement("a");let a;if(typeof e==="string"){a=e}else{a=URL.createObjectURL(e)}s.setAttribute("href",a);s.setAttribute("download",t);document.body.appendChild(s);s.click();s.remove();URL.revokeObjectURL(a)}async exportData(e=false){const t=JSON.stringify([{fragments:this.fragments,title:s(),totalSize:this.fragments.map(e=>e.size).reduce((e,t)=>e+t),referer:document.URL.replace(window.location.search,"")}]);if(e){GM_setClipboard(t,"text")}else{const e=new Blob([t],{type:"text/json"});const a=await this.downloadDanmaku();if(a!==null){const t=new JSZip;t.file(`${s()}.json`,e);t.file(s()+"."+this.danmakuOption.toLowerCase(),a);u.downloadBlob(await t.generateAsync({type:"blob"}),`${s()}.zip`)}else{u.downloadBlob(e,`${s()}.json`)}}}async exportAria2(a=false){if(a){const a=await this.downloadDanmaku();if(a!==null){u.downloadBlob(new Blob([a]),`${s()}.${this.danmakuOption==="ASS"?"ass":"xml"}`)}const i=e.aria2RpcOption;const n=this.fragments.map((e,t)=>{let a="";if(this.fragments.length>1){a=" - "+(t+1)}const n=[];if(i.secretKey!==""){n.push(`token:${i.secretKey}`)}n.push([e.url]);n.push({referer:document.URL.replace(window.location.search,""),"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0",out:`${s()}${a}${this.extension(e)}`,split:this.fragmentSplitFactor,dir:i.dir||undefined,"max-download-limit":i.maxDownloadLimit||undefined});const o=encodeURIComponent(`${s()}${a}`);return{params:n,id:o}});const{sendRpc:o}=await t.importAsync("aria2-rpc");await o(n)}else{const e=`\n# Generated by Bilibili Evolved Video Export\n# https://github.com/the1812/Bilibili-Evolved/\n${this.fragments.map((e,t)=>{let a="";if(this.fragments.length>1){a=" - "+(t+1)}return`\n${e.url}\n referer=${document.URL.replace(window.location.search,"")}\n user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0\n out=${s()}${a}${this.extension(e)}\n split=${this.fragmentSplitFactor}\n `.trim()}).join("\n")}\n `.trim();const t=new Blob([e],{type:"text/plain"});const a=await this.downloadDanmaku();if(a!==null){const e=new JSZip;e.file(`${s()}.txt`,t);e.file(s()+"."+this.danmakuOption.toLowerCase(),a);u.downloadBlob(await e.generateAsync({type:"blob"}),`${s()}.zip`)}else{u.downloadBlob(t,`${s()}.txt`)}}}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=dq("a#video-complete").getAttribute("href");if(e&&!dq(`.link[href="${e}"]`)){URL.revokeObjectURL(e)}dqa(".toast-card-header").filter(e=>e.innerText.includes("下载视频")).forEach(e=>e.querySelector(".toast-card-dismiss").click())}async downloadDanmaku(){if(this.danmakuOption!=="无"){const e=new i(r.cid);await e.fetchInfo();if(this.danmakuOption==="XML"){return e.rawXML}else{const{convertToAss:s}=await t.importAsync("download-danmaku");return s(e.rawXML)}}else{return null}}async downloadSingle(e){const t=await this.downloadDanmaku();const[a]=e;if(t===null){const e=this.makeBlob(a);const t=s()+this.extension();return{blob:e,filename:t}}else{const e=new JSZip;e.file(s()+this.extension(),this.makeBlob(a));e.file(s()+"."+this.danmakuOption.toLowerCase(),t);const i=await e.generateAsync({type:"blob"});const n=s()+".zip";return{blob:i,filename:n}}}async downloadMultiple(e){const t=new JSZip;const a=s();if(e.length>1){e.forEach((e,s)=>{const i=this.fragments[s];t.file(`${a} - ${s+1}${this.extension(i)}`,this.makeBlob(e,i))})}else{const[s]=e;t.file(`${a}${this.extension()}`,this.makeBlob(s))}const i=await this.downloadDanmaku();if(i!==null){t.file(s()+"."+this.danmakuOption.toLowerCase(),i)}const n=await t.generateAsync({type:"blob"});const o=a+".zip";return{blob:n,filename:o}}async download(){const e=[];this.videoSpeed.startMeasure();for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let{blob:t,filename:s}=await(async()=>{if(e.length===1){return await this.downloadSingle(e)}else{return await this.downloadMultiple(e)}})();this.cleanUpOldBlobUrl();const a=URL.createObjectURL(t);this.progress&&this.progress(0);this.videoSpeed.stopMeasure();return{url:a,filename:s}}}class p{constructor(e){this.lastProgress=0;this.measureInterval=1e3;this.workingDownloader=e}startMeasure(){this.intervalTimer=setInterval(()=>{const e=this.workingDownloader.progressMap?[...this.workingDownloader.progressMap.values()].reduce((e,t)=>e+t,0):0;const t=e-this.lastProgress;if(this.speedUpdate!==undefined){this.speedUpdate(formatFileSize(t)+"/s")}this.lastProgress=e},this.measureInterval)}stopMeasure(){clearInterval(this.intervalTimer)}}async function w(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);if(!(e&&t)){return false}r.aid=e;r.cid=t;if(document.URL.indexOf("bangumi")!==-1){r.entity=new o}else{r.entity=new n}try{l=await d.availableFormats}catch(e){return false}return true}async function f(){c=l[0];t.applyStyle("downloadVideoStyle");dq("#download-video").addEventListener("click",()=>{dq(".download-video").classList.toggle("opened");dq(".gui-settings-mask").click()});dq("#download-video").addEventListener("mouseover",()=>{document.body.insertAdjacentHTML("beforeend",t.import("downloadVideoHtml"));m()},{once:true})}async function m(){const n=await t.importAsync("v-dropdown.vue");const o=await t.importAsync("v-checkbox.vue");let h;const p=new Map;const f=new Vue({el:".download-video",components:{"v-dropdown":n,"v-checkbox":o},data:{downloadSingle:true,coverUrl:'data:image/svg+xml;utf-8,',aid:r.aid,cid:r.cid,qualityModel:{value:c.displayName,items:l.map(e=>e.displayName)},danmakuModel:{value:e.downloadVideoDefaultDanmaku,items:["无","XML","ASS"]},progressPercent:0,size:"获取大小中",blobUrl:"",episodeList:[],downloading:false,speed:"",batch:false,rpcSettings:e.aria2RpcOption,showRpcSettings:false,busy:false},computed:{displaySize(){if(typeof this.size==="string"){return this.size}return formatFileSize(this.size)},sizeWarning(){if(typeof this.size==="string"){return false}return this.size>1073741824},selectedEpisodeCount(){return this.episodeList.filter(e=>e.checked).length}},methods:{close(){this.$el.classList.remove("opened")},danmakuOptionChange(){e.downloadVideoDefaultDanmaku=this.danmakuModel.value},async formatChange(){const e=this.getFormat();const t=p.get(e);if(t){this.size=t;return}try{this.size="获取大小中";const t=await e.downloadInfo();this.size=t.totalSize;p.set(e,this.size)}catch(e){this.size="获取大小失败"}},getFormat(){const e=l.find(e=>e.displayName===this.qualityModel.value);if(!e){console.error(`No format found. model value = ${this.qualityModel.value}`);return null}return e},async exportData(e){if(this.busy===true){return}try{this.busy=true;if(!this.downloadSingle){await this.exportBatchData(e);return}const t=this.getFormat();const s=await t.downloadInfo();s.danmakuOption=this.danmakuModel.value;switch(e){case"copyLink":await s.copyUrl();Toast.success("已复制链接到剪贴板.","下载视频",3e3);break;case"aria2":await s.exportAria2(false);break;case"aria2RPC":await s.exportAria2(true);break;case"copyVLD":await s.exportData(true);Toast.success("已复制VLD数据到剪贴板.","下载视频",3e3);break;case"exportVLD":await s.exportData(false);break;default:break}}catch(e){logError(e)}finally{this.busy=false}},async exportBatchData(e){const a=this.episodeList;if(a.every(e=>e.checked===false)){Toast.info("请至少选择1集或以上的数量!","批量导出",3e3);return}const n=e=>{const t=a.find(t=>t.cid===e.cid);if(t===undefined){return false}return t.checked};const o=this.getFormat();if(this.danmakuModel.value!=="无"){const e=Toast.info("下载弹幕中...","批量导出");const s=new JSZip;try{if(this.danmakuModel.value==="XML"){for(const e of a.filter(n)){const t=new i(e.cid);await t.fetchInfo();s.file(e.title+".xml",t.rawXML)}}else{const{convertToAss:e}=await t.importAsync("download-danmaku");for(const t of a.filter(n)){const a=new i(t.cid);await a.fetchInfo();s.file(t.title+".ass",await e(a.rawXML))}}u.downloadBlob(await s.generateAsync({type:"blob"}),this.cid+".danmakus.zip")}catch(e){logError(`弹幕下载失败`)}finally{e.dismiss()}}const r=Toast.info("获取链接中...","批量导出");this.batchExtractor.itemFilter=n;let l;try{switch(e){case"aria2":l=await this.batchExtractor.collectAria2(o,r);u.downloadBlob(new Blob([l],{type:"text/plain"}),s(false)+".txt");return;case"aria2RPC":await this.batchExtractor.collectAria2(o,r,true);Toast.success(`成功发送了批量请求.`,"aria2 RPC",3e3);return;case"copyVLD":GM_setClipboard(await this.batchExtractor.collectData(o,r),{mimetype:"text/plain"});Toast.success("已复制批量vld数据到剪贴板.","批量导出",3e3);return;case"exportVLD":l=await this.batchExtractor.collectData(o,r);u.downloadBlob(new Blob([l],{type:"text/json"}),s(false)+".json");return;default:return}}catch(e){logError(e)}finally{r.dismiss()}},async checkBatch(){const e=["/www.bilibili.com/bangumi","/www.bilibili.com/video/av"];if(!e.some(e=>document.URL.includes(e))){this.batch=false;this.episodeList=[];return}const{BatchExtractor:s}=await t.importAsync("batch-download");if(await s.test()!==true){this.batch=false;this.episodeList=[];return}this.batchExtractor=new s;this.batch=true;this.episodeList=(await this.batchExtractor.getItemList()).map((e,t)=>{return{aid:e.aid,cid:e.cid,title:e.title,index:t,checked:true}})},cancelDownload(){if(h){h.cancelDownload()}},async startDownload(){const e=this.getFormat();try{this.downloading=true;const t=await e.downloadInfo();t.videoSpeed.speedUpdate=(e=>this.speed=e);t.danmakuOption=this.danmakuModel.value;t.progress=(e=>{this.progressPercent=Math.trunc(e*100)});h=t;const s=await t.download();const a=document.getElementById("video-complete");a.setAttribute("href",s.url);a.setAttribute("download",s.filename);a.click();Toast.success(`下载完成: ${s.filename} 再次保存`,"下载视频")}catch(e){if(e!=="canceled"){logError(e)}this.progressPercent=0}finally{this.downloading=false;this.speed=""}},selectAllEpisodes(){this.episodeList.forEach(e=>e.checked=true)},unselectAllEpisodes(){this.episodeList.forEach(e=>e.checked=false)},inverseAllEpisodes(){this.episodeList.forEach(e=>e.checked=!e.checked)},toggleRpcSettings(){this.showRpcSettings=!this.showRpcSettings},saveRpcSettings(){if(this.rpcSettings.host===""){this.rpcSettings.host="127.0.0.1"}if(this.rpcSettings.port===""){this.rpcSettings.port="6800"}e.aria2RpcOption=this.rpcSettings}}});Observer.videoChange(async()=>{f.close();f.batch=false;f.downloadSingle=true;const e=dq("#download-video");const t=await w();e.style.display=t?"flex":"none";if(!t){return}f.aid=r.aid;f.cid=r.cid;const s=new a(r.aid);await s.fetchInfo();f.coverUrl=s.coverUrl.replace("http:","https:");l=await d.availableFormats;[c]=l;f.qualityModel={value:c.displayName,items:l.map(e=>e.displayName)};f.formatChange();await f.checkBatch()})}return{widget:{content:`\n `,condition:w,success:f}}}})(); \ No newline at end of file diff --git a/min/v-checkbox.vue.min.js b/min/v-checkbox.vue.min.js new file mode 100644 index 000000000..a131d60fa --- /dev/null +++ b/min/v-checkbox.vue.min.js @@ -0,0 +1 @@ +(()=>{return(e,c)=>{const i=`
{{title}}
`;c.applyStyleFromText(`.v-checkbox{font-size:10pt;cursor:pointer;display:flex;align-items:center}.v-checkbox .mdi{font-size:15pt;line-height:1}.v-checkbox .content{flex-grow:1;text-align:left;padding:0 8px}.v-checkbox .mdi-checkbox-marked-circle{color:var(--theme-color);position:absolute;top:0;left:0;transform:scale(0);transition-timing-function:cubic-bezier(.6,-.28,.74,.05)}.v-checkbox .mdi-checkbox-blank-circle-outline{color:#8884;position:relative}.v-checkbox.checked .mdi-checkbox-blank-circle-outline{color:var(--theme-color)}.v-checkbox.checked .mdi-checkbox-marked-circle{transform:scale(1);transition-timing-function:cubic-bezier(.18,.89,.32,1.28)}`,"v-checkbox-style");return{export:Object.assign({template:i},{props:["checked","title"],methods:{toggleCheck(){this.$emit("update:checked",!this.checked)}}})}}})(); \ No newline at end of file diff --git a/min/v-dropdown.vue.min.js b/min/v-dropdown.vue.min.js index 0418e33ea..40cc6ddef 100644 --- a/min/v-dropdown.vue.min.js +++ b/min/v-dropdown.vue.min.js @@ -1 +1 @@ -(()=>{return(o,e)=>{const n=`
{{ value }}
`;e.applyStyleFromText(`.v-dropdown{position:relative;background-color:#8884;cursor:pointer;display:flex;align-items:center;justify-content:space-between;min-width:100px}.v-dropdown .dropdown-menu{transform-origin:top;transform:scaleY(0) translateX(-50%);position:absolute;top:calc(100% + 2px);left:50%;background-color:var(--download-video-background);z-index:1;transition:.2s cubic-bezier(.6,-.28,.74,.05);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0}.v-dropdown .dropdown-menu.opened{transform:scaleY(1) translateX(-50%);transition-timing-function:cubic-bezier(.18,.89,.32,1.28)}.v-dropdown .dropdown-menu li{padding:4px 8px;white-space:nowrap;min-width:80px;text-align:center;cursor:pointer;color:var(--download-video-foreground);background-color:transparent}.v-dropdown .dropdown-menu li:hover{background-color:rgba(0,0,0,.16)}.v-dropdown .mdi-chevron-down{font-size:16pt;line-height:1;transform:rotate(0)}.v-dropdown .dropdown-menu.opened~.mdi-chevron-down{transform:rotate(180deg)}.v-dropdown .selected{user-select:none;padding:4px 8px}`,"v-dropdown-style");return{export:Object.assign({template:n},{props:["items","value"],data(){return{dropdownOpen:false}},methods:{toggleDropdown(){this.dropdownOpen=!this.dropdownOpen},select(o){this.$emit("update:value",o);this.$emit("change",o)}}})}}})(); \ No newline at end of file +(()=>{return(o,e)=>{const n=`
{{ value }}
`;e.applyStyleFromText(`.v-dropdown{position:relative;background-color:#8884;cursor:pointer;display:flex;align-items:center;justify-content:space-between;min-width:100px}.v-dropdown .dropdown-menu{transform-origin:top;transform:scaleY(0) translateX(-50%);position:absolute;top:calc(100% + 2px);left:50%;background-color:var(--download-video-background);z-index:1;transition:.2s cubic-bezier(.6,-.28,.74,.05);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0}.v-dropdown .dropdown-menu.opened{transform:scaleY(1) translateX(-50%);transition-timing-function:cubic-bezier(.18,.89,.32,1.28)}.v-dropdown .dropdown-menu li{padding:4px 8px;white-space:nowrap;min-width:80px;text-align:center;cursor:pointer;color:var(--download-video-foreground);background-color:transparent}.v-dropdown .dropdown-menu li:hover{background-color:rgba(0,0,0,.16)}.v-dropdown .mdi-chevron-down{font-size:16pt;line-height:1;transform:rotate(0)}.v-dropdown .dropdown-menu.opened~.mdi-chevron-down{transform:rotate(180deg)}.v-dropdown .selected{user-select:none;padding:4px 8px}.round-corner .v-dropdown,.round-corner .v-dropdown .dropdown-menu,.round-corner .v-dropdown .dropdown-menu li{border-radius:var(--corner-radius)}`,"v-dropdown-style");return{export:Object.assign({template:n},{props:["items","value"],data(){return{dropdownOpen:false}},methods:{toggleDropdown(){this.dropdownOpen=!this.dropdownOpen},select(o){this.$emit("update:value",o);this.$emit("change",o)}}})}}})(); \ No newline at end of file diff --git a/src/client/resource-manifest.js b/src/client/resource-manifest.js index 698cf5d45..2758e4c44 100644 --- a/src/client/resource-manifest.js +++ b/src/client/resource-manifest.js @@ -694,6 +694,12 @@ Resource.manifest = { vDropdown: '下拉框组件', }, }, + vCheckbox: { + path: 'v-checkbox.vue.min.js', + displayNames: { + vCheckbox: '复选框组件', + }, + }, doubleClickFullscreen: { path: 'double-click-fullscreen.min.js', displayNames: { diff --git a/src/video/download-video/download-video.css b/src/video/download-video/download-video.css deleted file mode 100644 index 54d3a4ff3..000000000 --- a/src/video/download-video/download-video.css +++ /dev/null @@ -1,374 +0,0 @@ -.download-video.opened -{ - pointer-events: initial; - opacity: 1; - transform: translate(-50%, -50%) scale(1); -} -.download-video -{ - --download-video-background: white; - --download-video-foreground: black; - position: fixed; - top: 50%; - left: 50%; - transform: translate(-50%, -50%) scale(0.95); - background: var(--download-video-background); - color: var(--download-video-foreground); - box-shadow: rgba(0,0,0,0.2) 0 4px 8px 0px; - z-index: 10001; - pointer-events: none; - opacity: 0; - padding: 16px; - width: 300px; - display: flex; - flex-direction: column; - align-items: stretch; - justify-content: space-between; -} -body.dark .download-video { - --download-video-background: #222; - --download-video-foreground: #eee; -} -.round-corner .download-video, -.round-corner .download-video .episode-list .v-checkbox, -.round-corner .download-video .rpc-settings { - border-radius: var(--large-corner-radius); -} -.round-corner .download-video .title, -.round-corner .download-video .cover, -.round-corner .v-dropdown, -.round-corner .v-dropdown .dropdown-menu, -.round-corner .v-dropdown .dropdown-menu li, -.round-corner .download-video button, -.round-corner .download-video .button, -.round-corner .download-video .direct-download .progress .background, -.round-corner .download-video .direct-download .progress .foreground, -.round-corner .download-video .rpc-settings input[type="text"] { - border-radius: var(--corner-radius); -} -.download-video, -.download-video * { - transition: all .2s ease-out; - -webkit-tap-highlight-color: transparent !important; -} -.download-video .cover { - width: 240px; - min-height: 135px; - background-color: #8882; -} -.download-video .header { - display: flex; - justify-content: space-between; - align-items: center; -} -.download-video h1 { - font-size: 16pt; - font-weight: bold; - color: var(--download-video-foreground); -} -.download-video .header .mdi-close { - font-size: 16pt; - color: var(--download-video-foreground); - cursor: pointer; -} -.download-video .header .mdi-close:hover { - color: var(--theme-color); -} -.download-video .info { - display: flex; - flex-direction: column; - align-items: center; - margin-top: 12px; -} -.download-video .title { - display: flex; - flex-direction: column; - justify-content: space-between; - align-items: stretch; - margin-top: 12px; -} -.download-video .bold { - color: var(--download-video-foreground); - font-weight: bold; - font-size: 12pt; -} -.download-video .title .bold { - width: 300px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - text-align: center; -} -.download-video .title .size { - font-size: 10pt; - color: var(--download-video-foreground); - align-self: center; - display: flex; - align-items: center; - height: 24px; -} -.download-video .option-item { - display: flex; - justify-content: space-between; - align-items: center; - padding-top: 12px; - font-size: 10pt; -} -.download-video .tabs { - display: flex; - padding-top: 12px; - font-size: 10pt; -} -.download-video .tabs .tab { - padding: 6px 12px; - border-bottom: 2px solid transparent; - cursor: pointer; -} -.download-video .tab.active { - color: var(--theme-color); - border-bottom-color: var(--theme-color); -} -.download-video .separator { - height: 1px; - background: #8884; - width: 100%; - margin: 12px 0; -} -.download-video h2 { - font-size: 12pt; - font-weight: bold; - color: var(--download-video-foreground); -} -.download-video .direct-download { - display: flex; - flex-direction: column; - align-items: start; - justify-content: space-between; -} -.download-video button, -.download-video .button { - border: none; - outline: none !important; - padding: 6px 16px; - font-size: 10pt; - cursor: pointer; - background: #8884; - color: var(--download-video-foreground); -} -.download-video button:hover, -.download-video .button:hover { - background: #8886; -} -.download-video .primary { - background: var(--theme-color); - color: var(--foreground-color); - align-self: center; -} -.download-video .primary:hover { - background: var(--theme-color-90); -} -.download-video button:disabled, -.download-video .busy button, -.download-video .busy .button, -.download-video .busy .primary { - background-color: #0001; - color: #8884; - cursor: not-allowed; -} -.download-video .busy button, -.download-video .busy .button { - cursor: wait !important; -} -.download-video .direct-download .progress { - align-self: stretch; - display: flex; - align-items: center; - margin-top: 8px; -} -.download-video .direct-download .progress .background { - flex-grow: 1; - height: 4px; - background: #8884; - margin-right: 4px; - position: relative; -} -.download-video .direct-download .progress .foreground { - position: absolute; - top: 0; - left: 0; - height: 4px; - background: linear-gradient(to right, var(--theme-color), var(--theme-color-60)); -} -body.dark .download-video .direct-download .progress .foreground { - background: linear-gradient(to right, var(--theme-color-70), var(--theme-color)); -} -.download-video .direct-download .progress .percent { - width: 50px; - text-align: right; -} -.download-video .actions { - display: flex; - flex-wrap: wrap; - justify-content: space-between; - margin: 8px -4px 0 -4px; -} -.download-video .actions>* { - margin: 4px; - flex-grow: 1; - flex-basis: calc(50% - 16px); - display: flex; - justify-content: center; - align-items: center; -} -.download-video i.mdi-alert-circle { - font-size: 14pt; - color: #FF9800; -} -.download-video .size-warning { - position: relative; - padding: 0 8px; -} -.download-video .size-warning-tip { - position: absolute; - bottom: 100%; - left: 50%; - transform: translateX(-50%); - background: var(--download-video-background); - color: var(--download-video-foreground); - border: 1px dashed var(--theme-color); - z-index: 2; - font-size: 10pt; - width: 300px; - padding: 8px; - box-shadow: rgba(0,0,0,0.2) 0 4px 8px 0px; - pointer-events: none; - opacity: 0; -} -.download-video .size-warning:hover .size-warning-tip { - opacity: 1; -} -.download-video .episode-list .v-checkbox { - padding: 4px 8px; - margin: 4px 0; - position: relative; - background-color: transparent; -} -.download-video .episode-list .v-checkbox.checked { - background-color: #8882; -} -.v-checkbox { - font-size: 10pt; - cursor: pointer; - display: flex; - align-items: center; -} -.v-checkbox .mdi { - font-size: 15pt; - line-height: 1; -} -.v-checkbox .content { - flex-grow: 1; - text-align: left; - padding: 0 8px; -} -.v-checkbox .mdi-checkbox-marked-circle { - color: var(--theme-color); - position: absolute; - top: 0; - left: 0; - transform: scale(0); - transition-timing-function: cubic-bezier(0.6, -0.28, 0.74, 0.05); -} -.v-checkbox .mdi-checkbox-blank-circle-outline { - color: #8884; - position: relative; -} -.v-checkbox.checked .mdi-checkbox-blank-circle-outline { - color: var(--theme-color); -} -.v-checkbox.checked .mdi-checkbox-marked-circle { - transform: scale(1); - transition-timing-function: cubic-bezier(0.18, 0.89, 0.32, 1.28); -} -.download-video .episode-header { - display: flex; - align-items: center; - justify-content: space-between; - margin-bottom: 12px; -} -.download-video .episode-list { - overflow: auto; - max-height: 320px; -} -.download-video button.list-tool { - padding: 4px; - line-height: 1; - font-size: 12pt; - margin: 0 4px; -} -.download-video .episode-header h2 { - flex-grow: 1; -} -.download-video .selected-count { - width: 64px; - text-align: right; -} -.download-video .aria2-rpc .mdi { - margin-left: 8px; - font-size: 14pt; - line-height: 1; -} -.download-video .aria2-rpc { - position: relative; -} -.download-video .rpc-settings { - position: absolute; - display: flex; - flex-direction: column; - align-items: stretch; - color: var(--download-video-foreground); - background: var(--download-video-background); - bottom: 120%; - left: 50%; - cursor: initial; - box-shadow: rgba(0,0,0,0.2) 0 4px 8px 0px; - transform-origin: bottom; - transform: translateX(-50%); - opacity: 0; - pointer-events: none; - padding: 8px; - z-index: 3; -} -.download-video .rpc-settings>* { - margin: 8px; -} -.download-video .rpc-settings.show { - opacity: 1; - pointer-events: initial; -} -.download-video .rpc-settings-item { - display: flex; - align-items: center; - justify-content: space-between; - white-space: nowrap; -} -.download-video .rpc-settings input[type="text"] { - background: transparent; - color: var(--download-video-foreground); - border: 1px solid #8884; - padding: 4px; - margin-left: 8px; -} -.download-video .rpc-settings input[type="text"]:focus { - border-color: var(--theme-color); -} -.download-video button.start-download, -.download-video button.cancel-download { - margin-top: 8px; -} -.download-video .direct-download-header { - align-self: stretch; - display: flex; - justify-content: space-between; - align-items: center; -} \ No newline at end of file diff --git a/src/video/download-video/download-video.scss b/src/video/download-video/download-video.scss new file mode 100644 index 000000000..072fa2cfa --- /dev/null +++ b/src/video/download-video/download-video.scss @@ -0,0 +1,342 @@ +.download-video { + --download-video-background: white; + --download-video-foreground: black; + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%) scale(0.95); + background: var(--download-video-background); + color: var(--download-video-foreground); + box-shadow: rgba(0, 0, 0, 0.2) 0 4px 8px 0px; + z-index: 10001; + pointer-events: none; + opacity: 0; + padding: 16px; + width: 300px; + display: flex; + flex-direction: column; + align-items: stretch; + justify-content: space-between; + max-height: 90%; + overflow: auto; + + &, + * { + transition: all 0.2s ease-out; + -webkit-tap-highlight-color: transparent !important; + } + &.opened { + pointer-events: initial; + opacity: 1; + transform: translate(-50%, -50%) scale(1); + } + body.dark & { + --download-video-background: #222; + --download-video-foreground: #eee; + } + .round-corner & { + border-radius: var(--large-corner-radius); + .episode-list .v-checkbox, + .rpc-settings { + border-radius: var(--large-corner-radius); + } + .title, + .cover, + button, + .button, + .direct-download .progress .background, + .direct-download .progress .foreground, + .rpc-settings input[type="text"] { + border-radius: var(--corner-radius); + } + } + .cover { + width: 240px; + min-height: 135px; + background-color: #8882; + } + .header { + display: flex; + justify-content: space-between; + align-items: center; + } + h1 { + font-size: 16pt; + font-weight: bold; + color: var(--download-video-foreground); + } + .header .mdi-close { + font-size: 16pt; + color: var(--download-video-foreground); + cursor: pointer; + } + .header .mdi-close:hover { + color: var(--theme-color); + } + .info { + display: flex; + flex-direction: column; + align-items: center; + margin-top: 12px; + } + .title { + display: flex; + flex-direction: column; + justify-content: space-between; + align-items: stretch; + margin-top: 12px; + + .bold { + width: 300px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + text-align: center; + } + .size { + font-size: 10pt; + color: var(--download-video-foreground); + align-self: center; + display: flex; + align-items: center; + height: 24px; + } + } + .bold { + color: var(--download-video-foreground); + font-weight: bold; + font-size: 12pt; + } + .option-item { + display: flex; + justify-content: space-between; + align-items: center; + padding-top: 12px; + font-size: 10pt; + } + .tabs { + display: flex; + padding-top: 12px; + font-size: 10pt; + .tab { + padding: 6px 12px; + border-bottom: 2px solid transparent; + cursor: pointer; + &.active { + color: var(--theme-color); + border-bottom-color: var(--theme-color); + } + } + } + .separator { + height: 1px; + background: #8884; + width: 100%; + margin: 12px 0; + flex-shrink: 0; + } + h2 { + font-size: 12pt; + font-weight: bold; + color: var(--download-video-foreground); + } + .direct-download { + display: flex; + flex-direction: column; + align-items: start; + justify-content: space-between; + } + button, + .button { + border: none; + outline: none !important; + padding: 6px 16px; + font-size: 10pt; + cursor: pointer; + background: #8884; + color: var(--download-video-foreground); + } + button:hover, + .button:hover { + background: #8886; + } + .primary { + background: var(--theme-color); + color: var(--foreground-color); + align-self: center; + } + .primary:hover { + background: var(--theme-color-90); + } + button:disabled, + .busy button, + .busy .button, + .busy .primary { + background-color: #0001; + color: #8884; + cursor: not-allowed; + } + .busy button, + .busy .button { + cursor: wait !important; + } + .direct-download .progress { + align-self: stretch; + display: flex; + align-items: center; + margin-top: 8px; + .background { + flex-grow: 1; + height: 4px; + background: #8884; + margin-right: 4px; + position: relative; + .foreground { + position: absolute; + top: 0; + left: 0; + height: 4px; + background: linear-gradient(to right, var(--theme-color), var(--theme-color-60)); + } + } + } + .direct-download .progress .percent { + width: 50px; + text-align: right; + } + .actions { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + margin: 8px -4px 0 -4px; + } + .actions > * { + margin: 4px; + flex-grow: 1; + flex-basis: calc(50% - 16px); + display: flex; + justify-content: center; + align-items: center; + } + i.mdi-alert-circle { + font-size: 14pt; + color: #ff9800; + } + .size-warning { + position: relative; + padding: 0 8px; + } + .size-warning-tip { + position: absolute; + bottom: 100%; + left: 50%; + transform: translateX(-50%); + background: var(--download-video-background); + color: var(--download-video-foreground); + border: 1px dashed var(--theme-color); + z-index: 2; + font-size: 10pt; + width: 300px; + padding: 8px; + box-shadow: rgba(0, 0, 0, 0.2) 0 4px 8px 0px; + pointer-events: none; + opacity: 0; + } + .size-warning:hover .size-warning-tip { + opacity: 1; + } + .episode-list .v-checkbox { + padding: 4px 8px; + margin: 4px 0; + position: relative; + background-color: transparent; + } + .episode-list .v-checkbox.checked { + background-color: #8882; + } + .episode-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 12px; + } + .episode-list { + overflow: auto; + max-height: 320px; + } + button.list-tool { + padding: 4px; + line-height: 1; + font-size: 12pt; + margin: 0 4px; + } + .episode-header h2 { + flex-grow: 1; + } + .selected-count { + width: 64px; + text-align: right; + } + .aria2-rpc .mdi { + margin-left: 8px; + font-size: 14pt; + line-height: 1; + } + .aria2-rpc { + position: relative; + } + .rpc-settings { + position: absolute; + display: flex; + flex-direction: column; + align-items: stretch; + color: var(--download-video-foreground); + background: var(--download-video-background); + bottom: 120%; + left: 50%; + cursor: initial; + box-shadow: rgba(0, 0, 0, 0.2) 0 4px 8px 0px; + transform-origin: bottom; + transform: translateX(-50%); + opacity: 0; + pointer-events: none; + padding: 8px; + z-index: 3; + } + .rpc-settings > * { + margin: 8px; + } + .rpc-settings.show { + opacity: 1; + pointer-events: initial; + } + .rpc-settings-item { + display: flex; + align-items: center; + justify-content: space-between; + white-space: nowrap; + } + .rpc-settings input[type="text"] { + background: transparent; + color: var(--download-video-foreground); + border: 1px solid #8884; + padding: 4px; + margin-left: 8px; + } + .rpc-settings input[type="text"]:focus { + border-color: var(--theme-color); + } + button.start-download, + button.cancel-download { + margin-top: 8px; + } + .direct-download-header { + align-self: stretch; + display: flex; + justify-content: space-between; + align-items: center; + } +} +body.dark .download-video .direct-download .progress .foreground { + background: linear-gradient(to right, var(--theme-color-70), var(--theme-color)); +} diff --git a/src/video/download-video/download-video.ts b/src/video/download-video/download-video.ts index cf5ad26b0..e3fb964df 100644 --- a/src/video/download-video/download-video.ts +++ b/src/video/download-video/download-video.ts @@ -497,22 +497,7 @@ async function loadWidget() { } async function loadPanel() { const VueDropDown = await import((() => './v-dropdown.vue')()) - Vue.component('v-checkbox', { - template: /*html*/` -
- - - - {{title}} -
- `, - props: ['checked', 'title'], - methods: { - toggleCheck() { - this.$emit('update:checked', !this.checked) - }, - }, - }) + const VueCheckBox = await import((() => './v-checkbox.vue')()) let workingDownloader: VideoDownloader const sizeCache = new Map() type ExportType = 'copyLink' | 'aria2' | 'aria2RPC' | 'copyVLD' | 'exportVLD' @@ -527,6 +512,7 @@ async function loadPanel() { el: '.download-video', components: { 'v-dropdown': VueDropDown, + 'v-checkbox': VueCheckBox, }, data: { downloadSingle: true, diff --git a/src/video/download-video/v-checkbox.vue b/src/video/download-video/v-checkbox.vue new file mode 100644 index 000000000..a5ab221eb --- /dev/null +++ b/src/video/download-video/v-checkbox.vue @@ -0,0 +1,55 @@ + + + \ No newline at end of file diff --git a/src/video/download-video/v-dropdown.vue b/src/video/download-video/v-dropdown.vue index cee16a9ab..707a2c28e 100644 --- a/src/video/download-video/v-dropdown.vue +++ b/src/video/download-video/v-dropdown.vue @@ -75,5 +75,14 @@ export default { user-select: none; padding: 4px 8px; } + + .round-corner & { + border-radius: var(--corner-radius); + + .dropdown-menu, + .dropdown-menu li { + border-radius: var(--corner-radius); + } + } } \ No newline at end of file