diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index 06f849cbe..748a0886a 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Offline) -// @version 298.28 +// @version 298.29 // @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -1033,14 +1033,14 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/debounce.min.js"] = (()=>{return(n,l)=>{function u(n,l,u){var e,t,i,r,f;if(null==l)l=100;function o(){var a=Date.now()-r;if(a=0){e=setTimeout(o,l-a)}else{e=null;if(!u){f=n.apply(i,t);i=t=null}}}var a=function(){i=this;t=arguments;r=Date.now();var a=u&&!e;if(!e)e=setTimeout(o,l);if(a){f=n.apply(i,t);i=t=null}return f};a.clear=function(){if(e){clearTimeout(e);e=null}};a.flush=function(){if(e){f=n.apply(i,t);i=t=null;clearTimeout(e);e=null}};return a}return{export:{debounce:u}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-danmaku-settings.min.css"] = `.bilibili-player-video-danmaku-setting-wrap{display:none!important}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-danmaku-settings.min.js"] = (()=>{return(e,t)=>{async function i(e,t){const i=await SpinQuery.select(()=>document.querySelector(e));if(!i){return}i.checked=t;raiseEvent(i,"change")}if(!e.enableDanmaku){i(".bilibili-player-video-danmaku-switch>input",false)}if(e.rememberDanmakuSettings){const i={subtitlesPreserve:".bilibili-player-video-danmaku-setting-left-preventshade input",smartMask:".bilibili-player-video-danmaku-setting-left-danmaku-mask input"};async function n(){const n=await SpinQuery.select(()=>document.querySelector(".bilibili-player-video-danmaku-setting"));if(!n){return}await loadLazyPanel(".bilibili-player-video-danmaku-setting");setTimeout(()=>t.removeStyle("defaultDanmakuSettingsStyle"),300);for(const[t,n]of Object.entries(e.danmakuSettings)){const e=await SpinQuery.select(()=>document.querySelector(i[t]));if(e!==null&&e.checked!==undefined&&e.checked!==n){e.click()}}}async function a(){for(const t in e.danmakuSettings){const n=await SpinQuery.select(()=>document.querySelector(i[t]));if(!n){return}n.addEventListener("click",()=>{e.danmakuSettings=Object.assign(e.danmakuSettings,{[t]:n.checked});saveSettings(e)})}}n();a()}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-player-layout.min.js"] = (()=>{return(e,t)=>{class s{setCookie(e,t){document.cookie=`${e}=${t};path=/;domain=.bilibili.com;max-age=31536000`}clearCookie(e){document.cookie=`${e}=;path=/;domain=.bilibili.com;max-age=0`}getValue(e){return document.cookie.replace(new RegExp(`(?:(?:^|.*;\\s*)${e}\\s*\\=\\s*([^;]*).*$)|^.*$`),"$1")}checkSettings(){return e.useDefaultPlayerLayout}checkCookies(){if(!this.checkSettings()){return}}useNewLayout(){if(!this.checkSettings()){return}}useOldLayout(){if(!this.checkSettings()){return}}setLayout(e){if(e){this.useNewLayout()}else{this.useOldLayout()}}}class o extends s{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<0&&e.defaultPlayerLayout!=="旧版"){this.useNewLayout()}else if(e.defaultPlayerLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustvideo";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,1)}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,-1)}}class i extends s{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<=0&&e.defaultBangumiLayout!=="旧版"){this.useNewLayout()}else if(e.defaultBangumiLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustpgcv";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,"0606")}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,0)}}const u=new o;addSettingsListener("defaultPlayerLayout",e=>{console.log("layout change detected");u.setLayout(e==="新版")});const a=new i;addSettingsListener("defaultBangumiLayout",e=>{a.setLayout(e==="新版")})}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-player-layout.min.js"] = (()=>{return(e,t)=>{class s{setCookie(e,t){document.cookie=`${e}=${t};path=/;domain=.bilibili.com;max-age=31536000`}clearCookie(e){document.cookie=`${e}=;path=/;domain=.bilibili.com;max-age=0`}getValue(e){return document.cookie.replace(new RegExp(`(?:(?:^|.*;\\s*)${e}\\s*\\=\\s*([^;]*).*$)|^.*$`),"$1")}checkSettings(){return e.useDefaultPlayerLayout}checkCookies(){if(!this.checkSettings()){return}}useNewLayout(){if(!this.checkSettings()){return}}useOldLayout(){if(!this.checkSettings()){return}}setLayout(e){if(e){this.useNewLayout()}else{this.useOldLayout()}}}class o extends s{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<0&&e.defaultPlayerLayout!=="旧版"){this.useNewLayout()}else if(e.defaultPlayerLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustvideo";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,1)}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,-1)}}class i extends s{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<=0&&e.defaultBangumiLayout!=="旧版"){this.useNewLayout()}else if(e.defaultBangumiLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustpgcv";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,"0606")}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,0)}}const u=new o;addSettingsListener("defaultPlayerLayout",e=>{u.setLayout(e==="新版")});const a=new i;addSettingsListener("defaultBangumiLayout",e=>{a.setLayout(e==="新版")})}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-player-mode.min.js"] = (()=>{return(e,i)=>{if(typeof isEmbeddedPlayer!=="undefined"&&isEmbeddedPlayer()){return}const n=[{name:"常规",action:()=>{}},{name:"宽屏",action:()=>{document.querySelector(".bilibili-player-video-btn-widescreen").click();document.querySelector("#bofqi").scrollIntoView({behavior:"smooth"})}},{name:"网页全屏",action:()=>{document.querySelector(".bilibili-player-video-web-fullscreen").click()}},{name:"全屏",action:()=>{document.querySelector(".bilibili-player-video-btn-fullscreen").click()}}];let t=()=>{};let o=()=>{};async function l(){if(e.autoLightOff){await SpinQuery.unsafeJquery();const e=await SpinQuery.any(()=>unsafeWindow.$(".bilibili-player-video-btn-setting"));if(!e){return}e.mouseover().mouseout();const i=async e=>{const i=await SpinQuery.select(()=>document.querySelector(".bilibili-player-video-btn-setting-panel-others-content-lightoff .bui-checkbox-input"));i.checked=e;raiseEvent(i,"change")};t=(()=>i(true));o=(()=>i(false))}}async function a(){await l();await SpinQuery.condition(()=>$(".bilibili-player-video,.bilibili-player-video-btn-start,.bilibili-player-area"),e=>e.length===3&&$("video").length>0&&$("video").prop("duration"));const i=document.querySelector("video");if(!i){return}const a=n.find(i=>i.name===e.defaultPlayerMode);{const n=()=>{if(a&&$("#bilibiliPlayer[class*=mode-]").length===0){a.action()}};if(e.applyPlayerModeOnPlay&&!e.autoPlay){i.addEventListener("play",n,{once:true})}else{n()}if(!e.autoPlay){i.addEventListener("play",t,{once:true})}else{t()}i.addEventListener("ended",o,{once:true})}}Observer.videoChange(a)}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-video-quality.min.js"] = (()=>{return(e,a)=>{const t=[{name:"1080P60",value:116},{name:"1080P+",value:112},{name:"1080P",value:80},{name:"720P60",value:74},{name:"720P",value:64},{name:"480P",value:32},{name:"360P",value:15},{name:"自动",value:0}];async function i(){const a=await SpinQuery.any(()=>$(".bilibili-player-video-quality-menu .bui-select-list>li.bui-select-item"));if(!a){return}const i=(e,a)=>a-e;const[n]=a.toArray().map(e=>parseInt(e.getAttribute("data-value"))).sort(i);const[l]=t.filter(a=>a.name===e.defaultVideoQuality).map(e=>e.value).sort(i);const[r]=t.map(e=>e.value).filter(e=>e<=Math.min(l,n)).sort(i);const u=await SpinQuery.select(()=>document.querySelector("video"));function s(){a.each((e,a)=>{if(parseInt(a.getAttribute("data-value"))===r){a.click()}});this.removeEventListener("play",s)}u.addEventListener("play",s)}if(Observer.videoChange){Observer.videoChange(i)}else{Observer.childList("#bofqi",()=>i())}}})(); 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:o}=e.import("danmaku-converter");async function a(t,e){const a=n();const r=new i((unsafeWindow||window).cid);await r.fetchInfo();const l=await(async()=>{if(e===true){let t={title:a};try{await loadLazyPanel(".bilibili-player-video-danmaku-setting");const e=t=>{const e=parseFloat(document.querySelector(t).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const n={0:0,44:1,94:2,144:3,188:4}[e];return n};t.font=document.querySelector(".bilibili-player-video-danmaku-setting-right-font .bui-select-result").innerText;t.alpha=parseFloat(document.querySelector(".bilibili-player-setting-opacity .bui-bar").style.transform.replace(/scaleX\(([\d\.]+)\)/,"$1"));t.duration=(()=>{const t=[10,8,6,4,2][e(".bilibili-player-setting-speedplus .bui-thumb")];return e=>{switch(e.type){case 4:case 5:return 4;default:return t}}})();t.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(document.querySelector(n).classList.contains("disabled")){t=t.concat(i)}}return t.concat(7,8)})();const n=[1.4,1.2,1,.8,.6][e(".bilibili-player-setting-fontsize .bui-thumb")];t.resolution={x:1920*n,y:1080*n};t.bottomMarginPercent=[.75,.5,.25,0,0][e(".bilibili-player-setting-area .bui-thumb")];if(t.bottomMarginPercent===0&&document.querySelector(".bilibili-player-video-danmaku-setting-left-preventshade input").checked){t.bottomMarginPercent=.15}t.bold=document.querySelector(".bilibili-player-video-danmaku-setting-right-font-bold input").checked}catch(e){t={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 e=new o(t);const n=e.convertToAssDocument(r.rawXML);return new Blob([n.generateAss()],{type:"text/plain"})}else{return new Blob([r.rawXML],{type:"text/plain"})}})();const c=URL.createObjectURL(l);const s=$("#danmaku-link");const u=s.attr("href");if(u){URL.revokeObjectURL(u)}clearTimeout(t);document.querySelector("#download-danmaku>span").innerHTML="下载弹幕";s.attr("download",`${a}.${e?"ass":"xml"}`).attr("href",c).get(0).click()}return{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");$("#download-danmaku").on("click",e=>{if(e.target!==t){const t=setTimeout(()=>document.querySelector("#download-danmaku>span").innerHTML="请稍侯...",200);a(t,e.shiftKey)}})}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.css"] = `.download-video-panel.opened{transform:scaleY(1) translateX(-50%)}.download-video-panel{position:absolute;top:calc(100% + 2px);transition:.16s ease-out;transform-origin:top;transform:scaleY(0) translateX(-50%);background:#fff;box-shadow:0 3px 20px 2px #0004;z-index:100;left:50%}.video-action>div,ol.video-quality li{cursor:pointer;align-items:center;margin:0;padding:8px 16px;transition:.2s ease-out;text-align:center;white-space:nowrap}.video-action>div{padding:12px 24px}.video-action>div:hover,ol.video-quality li:hover{background:rgba(0,0,0,.16)}.video-action,.video-error,.video-progress,.video-quality{display:none}.download-video-panel.action:not(.error) .video-action,.download-video-panel.error .video-error,.download-video-panel.progress:not(.error) .video-progress,.download-video-panel.quality:not(.error) .video-quality{display:block}.download-progress-text{display:flex}.download-progress-background{background-color:#8884;height:4px;width:100%;margin-top:4px}.download-progress-foreground{background-color:var(--theme-color);transform-origin:left;transition:.2s ease-out;transform:scaleX(0);height:100%;width:100%}.download-progress-cancel{margin-top:8px;display:flex;justify-content:center}.download-progress-cancel>span{background-color:#8884;padding:4px 8px;cursor:pointer}.download-progress-cancel>span:hover{opacity:.9}.download-progress-cancel>span:active{opacity:.8}.video-error,.video-progress{padding:12px}.video-progress{min-width:120px}#video-action-batch-data,#video-action-batch-download-data,#video-complete{display:none}.batch #video-action-batch-data,.batch #video-action-batch-download-data{display:block}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.html"] = `
下载视频
`; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.js"] = (()=>{return(e,t)=>{const{getFriendlyTitle:s}=t.import("title");const n={entity:null,aid:undefined,cid:undefined};let o=null;class r{constructor(){this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}get menuPanel(){return document.querySelector(".download-video-panel")}addMenuClass(){this.menuPanel.classList.remove(...this.menuClasses);this.menuPanel.classList.add(this.currentMenuClass);return this.currentMenuClass}resetMenuClass(){[this.currentMenuClass]=this.menuClasses;this.addMenuClass()}nextMenuClass(){const e=this.menuClasses.indexOf(this.currentMenuClass)+1;const t=this.menuClasses[e>=this.menuClasses.length?0:e];this.currentMenuClass=t;this.addMenuClass();return t}addError(){this.menuPanel.classList.add("error")}removeError(){this.menuPanel.classList.remove("error");this.resetMenuClass()}async getUrl(e){if(e){return`https://api.bilibili.com/x/player/playurl?avid=${n.aid}&cid=${n.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${n.aid}&cid=${n.cid}&otype=json`}}}class a extends r{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${n.aid}&cid=${n.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${n.aid}&cid=${n.cid}&qn=&otype=json`}}}class i{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new c(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{n.entity.getUrl().then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText);if(s.code!==0){t("获取清晰度信息失败.")}const o=s.data||s.result||s;const r=o.accept_quality;const a=o.accept_format.split(",");const l=o.accept_description;const c=[];while(r.length>0){const e=new i(r.pop(),a.pop(),l.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class l{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class c{constructor(e,t){this.format=e;this.fragments=t||[];this.progress=null;this.totalSize=null;this.workingXhr=null;this.fragmentSplitFactor=6*5}fetchVideoInfo(){return new Promise((e,t)=>{n.entity.getUrl(this.format.quality).then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText.replace(/http:/g,"https:"));const o=s.data||s.result||s;if(o.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const r=o.durl;this.fragments=r.map(e=>new l(e.length,e.size,e.url,e.backup_url));e(this.fragments)});n.withCredentials=true;n.open("GET",s);n.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(){if("forEach"in this.workingXhr){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const s=Math.round(e.size/this.fragmentSplitFactor);let n=0;const o=e=>[...this.progressMap.keys()].indexOf(e)+1;while(n{const n=new XMLHttpRequest;n.open("GET",e.url);n.responseType="arraybuffer";n.withCredentials=false;n.addEventListener("progress",e=>{console.log(`[下载视频] 视频片段${o(n)}下载进度: ${e.loaded}/${i} bytes loaded, ${a}`);this.progressMap.set(n,e.loaded);this.updateProgress()});n.addEventListener("load",()=>{if((""+n.status)[0]==="2"){t(n.response)}else{s(`请求失败.`)}});n.addEventListener("abort",()=>s("下载已取消."));n.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${o(n)}下载失败: ${a}`);this.progressMap.set(n,0);this.updateProgress();n.open("GET",e.url);n.setRequestHeader("Range",a);n.send()});n.setRequestHeader("Range",a);this.progressMap.set(n,0);n.send();this.workingXhr.push(n)}));n=Math.round(n+s)+1}return Promise.all(t)}copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}exportData(e=false){const t=JSON.stringify({fragments:this.fragments,title:s(true),totalSize:this.fragments.map(e=>e.size).reduce((e,t)=>e+t)});if(e){GM_setClipboard(t,"text")}else{const e=document.createElement("a");const s=new Blob([t],{type:"text/json"});const n=URL.createObjectURL(s);e.setAttribute("href",n);e.setAttribute("download",`cid${unsafeWindow.cid}.json`);document.body.appendChild(e);e.click();e.remove();URL.revokeObjectURL(n)}}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t=null){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=document.querySelector("a#video-complete").getAttribute("href");if(e&&!document.querySelector(`.link[href="${e}"]`)){URL.revokeObjectURL(e)}[...document.querySelectorAll(".toast-card-header")].filter(e=>e.innerText.includes("下载视频")).forEach(e=>e.querySelector(".toast-card-dismiss").click())}downloadSingle(e){const[t]=e;const n=this.makeBlob(t);const o=s()+this.extension();return[n,o]}async downloadMultiple(e){const t=new JSZip;const n=s();if(e.length>1){e.forEach((e,s)=>{const o=this.fragments[s];t.file(`${n} - ${s+1}${this.extension(o)}`,this.makeBlob(e,o))})}else{const[s]=e;t.file(`${n}${this.extension()}`,this.makeBlob(s))}const o=await t.generateAsync({type:"blob"});const r=n+".zip";return[o,r]}async download(){const e=[];this.totalSize=this.fragments.map(e=>e.size).reduce((e,t)=>e+t);for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let t=null;let s=null;if(e.length===1){[t,s]=this.downloadSingle(e)}else{[t,s]=await this.downloadMultiple(e)}this.cleanUpOldBlobUrl();const n=URL.createObjectURL(t);this.progress&&this.progress(0);return{url:n,filename:s}}}async function d(){const e=["/www.bilibili.com/bangumi"];if(e.some(e=>document.URL.includes(e))){const{BatchExtractor:e}=await t.importAsync("batchDownload");const s=new e;document.getElementById("download-video").classList.add("batch");document.getElementById("video-action-batch-data").addEventListener("click",async()=>{if(!o){return}n.entity.resetMenuClass();const e=Toast.info("获取链接中...","批量下载");const t=await s.collectData(o,e);if(!t){return}GM_setClipboard(t,{type:"text/json"});Toast.success("已复制批量数据到剪贴板.","复制批量数据",3e3)});document.getElementById("video-action-batch-download-data").addEventListener("click",async()=>{if(!o){return}n.entity.resetMenuClass();const e=Toast.info("获取链接中...","批量下载");const t=await s.collectData(o,e);if(!t){return}const r=document.createElement("a");const a=new Blob([t],{type:"text/json"});const i=URL.createObjectURL(a);r.setAttribute("href",i);r.setAttribute("download",`export.json`);document.body.appendChild(r);r.click();r.remove();URL.revokeObjectURL(i)})}}async function u(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);n.aid=e;n.cid=t;if(document.URL.indexOf("bangumi")!==-1){n.entity=new a}else{n.entity=new r}return Boolean(e&&t)}async function p(){let e=await i.availableFormats;o=e[0];const s=async()=>{await u();e=await i.availableFormats;const t=$("ol.video-quality");t.html("");e.forEach(e=>{$(`
  • ${e.displayName}
  • `).on("click",()=>{o=e;n.entity.nextMenuClass()}).prependTo(t)})};if(Observer.videoChange){Observer.videoChange(s)}else{Observer.childList("#bofqi",s)}const r=()=>o.downloadInfo().catch(e=>{n.entity.addError();$(".video-error").text(e)});async function a(){if(!o){return}n.entity.nextMenuClass();const e=await r();e.progress=(e=>{$(".download-progress-value").text(`${fixed(e*100)}`);$(".download-progress-foreground").css("transform",`scaleX(${e})`)});document.querySelector(".download-progress-cancel>span").onclick=(()=>e.cancelDownload());const t=await e.download().catch(e=>{n.entity.addError();$(".video-error").text(e)});if(!t){return}const s=document.getElementById("video-complete");s.setAttribute("href",t.url);s.setAttribute("download",t.filename);s.click();const a=`下载完成. 再次保存`;Toast.success(a,"下载视频");n.entity.resetMenuClass()}async function l(){if(!o){return}const e=await r();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);n.entity.resetMenuClass()}document.querySelector("#video-action-download").addEventListener("click",a);document.querySelector("#video-action-copy").addEventListener("click",l);document.querySelector("#video-action-copy-data").addEventListener("click",async()=>{if(!o){return}const e=await r();e.exportData(true);Toast.success("已复制数据到剪贴板.","复制数据",3e3);n.entity.resetMenuClass()});document.querySelector("#video-action-download-data").addEventListener("click",async()=>{if(!o){return}const e=await r();e.exportData(false);n.entity.resetMenuClass()});t.applyStyle("downloadVideoStyle");const c=document.querySelector(".download-video-panel");const p=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!c.contains(e.target)){p()}});$(".video-error").on("click",()=>{$(".video-error").text("");n.entity.removeError()});await SpinQuery.select(()=>document.querySelector(".download-video-panel"));n.entity.addMenuClass();d()}return{widget:{content:(t.data.downloadVideoDom||t.data.downloadVideoHtml).text,condition:u,success:p}}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.js"] = (()=>{return(e,t)=>{const{getFriendlyTitle:s}=t.import("title");const n={entity:null,aid:undefined,cid:undefined};let o=null;class r{constructor(){this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}get menuPanel(){return document.querySelector(".download-video-panel")}addMenuClass(){this.menuPanel.classList.remove(...this.menuClasses);this.menuPanel.classList.add(this.currentMenuClass);return this.currentMenuClass}resetMenuClass(){[this.currentMenuClass]=this.menuClasses;this.addMenuClass()}nextMenuClass(){const e=this.menuClasses.indexOf(this.currentMenuClass)+1;const t=this.menuClasses[e>=this.menuClasses.length?0:e];this.currentMenuClass=t;this.addMenuClass();return t}addError(){this.menuPanel.classList.add("error")}removeError(){this.menuPanel.classList.remove("error");this.resetMenuClass()}async getUrl(e){if(e){return`https://api.bilibili.com/x/player/playurl?avid=${n.aid}&cid=${n.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${n.aid}&cid=${n.cid}&otype=json`}}}class a extends r{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${n.aid}&cid=${n.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${n.aid}&cid=${n.cid}&qn=&otype=json`}}}class i{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new c(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{n.entity.getUrl().then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText);if(s.code!==0){t("获取清晰度信息失败.")}const o=s.data||s.result||s;const r=o.accept_quality;const a=o.accept_format.split(",");const l=o.accept_description;const c=[];while(r.length>0){const e=new i(r.pop(),a.pop(),l.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class l{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class c{constructor(e,t){this.format=e;this.fragments=t||[];this.progress=null;this.totalSize=null;this.workingXhr=null;this.fragmentSplitFactor=6*5}fetchVideoInfo(){return new Promise((e,t)=>{n.entity.getUrl(this.format.quality).then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText.replace(/http:/g,"https:"));const o=s.data||s.result||s;if(o.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const r=o.durl;this.fragments=r.map(e=>new l(e.length,e.size,e.url,e.backup_url));e(this.fragments)});n.withCredentials=true;n.open("GET",s);n.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(){if("forEach"in this.workingXhr){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const s=Math.round(e.size/this.fragmentSplitFactor);let n=0;const o=e=>[...this.progressMap.keys()].indexOf(e)+1;while(n{const n=new XMLHttpRequest;n.open("GET",e.url);n.responseType="arraybuffer";n.withCredentials=false;n.addEventListener("progress",e=>{console.log(`[下载视频] 视频片段${o(n)}下载进度: ${e.loaded}/${i} bytes loaded, ${a}`);this.progressMap.set(n,e.loaded);this.updateProgress()});n.addEventListener("load",()=>{if((""+n.status)[0]==="2"){t(n.response)}else{s(`请求失败.`)}});n.addEventListener("abort",()=>s("下载已取消."));n.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${o(n)}下载失败: ${a}`);this.progressMap.set(n,0);this.updateProgress();n.open("GET",e.url);n.setRequestHeader("Range",a);n.send()});n.setRequestHeader("Range",a);this.progressMap.set(n,0);n.send();this.workingXhr.push(n)}));n=Math.round(n+s)+1}return Promise.all(t)}copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}exportData(e=false){const t=JSON.stringify({fragments:this.fragments,title:s(true),totalSize:this.fragments.map(e=>e.size).reduce((e,t)=>e+t)});if(e){GM_setClipboard(t,"text")}else{const e=document.createElement("a");const s=new Blob([t],{type:"text/json"});const n=URL.createObjectURL(s);e.setAttribute("href",n);e.setAttribute("download",`cid${unsafeWindow.cid}.json`);document.body.appendChild(e);e.click();e.remove();URL.revokeObjectURL(n)}}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t=null){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=document.querySelector("a#video-complete").getAttribute("href");if(e&&!document.querySelector(`.link[href="${e}"]`)){URL.revokeObjectURL(e)}[...document.querySelectorAll(".toast-card-header")].filter(e=>e.innerText.includes("下载视频")).forEach(e=>e.querySelector(".toast-card-dismiss").click())}downloadSingle(e){const[t]=e;const n=this.makeBlob(t);const o=s()+this.extension();return[n,o]}async downloadMultiple(e){const t=new JSZip;const n=s();if(e.length>1){e.forEach((e,s)=>{const o=this.fragments[s];t.file(`${n} - ${s+1}${this.extension(o)}`,this.makeBlob(e,o))})}else{const[s]=e;t.file(`${n}${this.extension()}`,this.makeBlob(s))}const o=await t.generateAsync({type:"blob"});const r=n+".zip";return[o,r]}async download(){const e=[];this.totalSize=this.fragments.map(e=>e.size).reduce((e,t)=>e+t);for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let t=null;let s=null;if(e.length===1){[t,s]=this.downloadSingle(e)}else{[t,s]=await this.downloadMultiple(e)}this.cleanUpOldBlobUrl();const n=URL.createObjectURL(t);this.progress&&this.progress(0);return{url:n,filename:s}}}async function d(){const e=["/www.bilibili.com/bangumi"];if(e.some(e=>document.URL.includes(e))){const{BatchExtractor:e}=await t.importAsync("batchDownload");const s=new e;document.getElementById("download-video").classList.add("batch");document.getElementById("video-action-batch-data").addEventListener("click",async()=>{if(!o){return}n.entity.resetMenuClass();const e=Toast.info("获取链接中...","批量下载");const t=await s.collectData(o,e);if(!t){return}GM_setClipboard(t,{type:"text/json"});Toast.success("已复制批量数据到剪贴板.","复制批量数据",3e3)});document.getElementById("video-action-batch-download-data").addEventListener("click",async()=>{if(!o){return}n.entity.resetMenuClass();const e=Toast.info("获取链接中...","批量下载");const t=await s.collectData(o,e);if(!t){return}const r=document.createElement("a");const a=new Blob([t],{type:"text/json"});const i=URL.createObjectURL(a);r.setAttribute("href",i);r.setAttribute("download",`export.json`);document.body.appendChild(r);r.click();r.remove();URL.revokeObjectURL(i)})}}async function u(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);n.aid=e;n.cid=t;if(document.URL.indexOf("bangumi")!==-1){n.entity=new a}else{n.entity=new r}return Boolean(e&&t)}async function p(){let e=await i.availableFormats;o=e[0];const s=async()=>{await u();e=await i.availableFormats;const t=$("ol.video-quality");t.html("");e.forEach(e=>{$(`
  • ${e.displayName}
  • `).on("click",()=>{o=e;n.entity.nextMenuClass()}).prependTo(t)})};if(Observer.videoChange){Observer.videoChange(s)}else{Observer.childList("#bofqi",s)}const r=()=>o.downloadInfo().catch(e=>{n.entity.addError();$(".video-error").text(e)});async function a(){if(!o){return}n.entity.nextMenuClass();const e=await r();e.progress=(e=>{$(".download-progress-value").text(`${fixed(e*100)}`);$(".download-progress-foreground").css("transform",`scaleX(${e})`)});document.querySelector(".download-progress-cancel>span").onclick=(()=>e.cancelDownload());const t=await e.download().catch(e=>{n.entity.addError();$(".video-error").text(e)});if(!t){return}const s=document.getElementById("video-complete");s.setAttribute("href",t.url);s.setAttribute("download",t.filename);s.click();const a=`下载完成. 再次保存`;Toast.success(a,"下载视频");n.entity.resetMenuClass()}async function l(){if(!o){return}const e=await r();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);n.entity.resetMenuClass()}document.querySelector("#video-action-download").addEventListener("click",a);document.querySelector("#video-action-copy").addEventListener("click",l);document.querySelector("#video-action-copy-data").addEventListener("click",async()=>{if(!o){return}const e=await r();e.exportData(true);Toast.success("已复制数据到剪贴板.","复制数据",3e3);n.entity.resetMenuClass()});document.querySelector("#video-action-download-data").addEventListener("click",async()=>{if(!o){return}const e=await r();e.exportData(false);n.entity.resetMenuClass()});t.applyStyle("downloadVideoStyle");const c=document.querySelector(".download-video-panel");const p=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!c.contains(e.target)){p()}});$(".video-error").on("click",()=>{$(".video-error").text("");n.entity.removeError()});await SpinQuery.select(()=>document.querySelector(".download-video-panel"));n.entity.addMenuClass();d()}return{widget:{content:t.data.downloadVideoHtml.text,condition:u,success:p}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-danmaku.min.js"] = (()=>{return(e,i)=>{if(typeof isEmbeddedPlayer!=="undefined"&&isEmbeddedPlayer()){return}const r=()=>{SpinQuery.any(()=>$(".bui-collapse-header"),e=>{if(parseInt($(".bui-collapse-body").css("height"))===0&&$(".bui-collapse-arrow-text").text()==="展开"){e.click()}})};if(Observer.videoChange){Observer.videoChange(r)}else{Observer.childList("#bofqi",r)}}})(); 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")}})(); @@ -1055,7 +1055,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/full-tweets-title.min.js"] = (()=>{return(e,l)=>{l.applyStyle("fullTweetsTitleStyle")}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/gui-settings.min.css"] = `.gui-settings-icon-panel{height:auto;display:flex;flex-direction:column;justify-content:center;align-items:center;position:fixed;top:50%;left:0;width:32px;z-index:99999;transform:translateY(-50%)}.gui-settings-icon-panel i{transition:.2s;opacity:.6;transform:rotate(180deg)}.gui-settings-widgets:hover i,.gui-settings:hover i{opacity:.75;transform:rotate(0)}.gui-settings,.gui-settings-widgets{display:flex;justify-content:center;align-items:center;cursor:pointer;-webkit-tap-highlight-color:transparent;margin:16px 0;width:24px;height:24px;transition:.2s;opacity:1;transform-origin:center!important;transform:translateX(-16px);background-color:rgba(255,255,255,.75);border-radius:0 50% 50% 0;padding:6px}body.dark .gui-settings,body.dark .gui-settings-widgets{background-color:rgba(0,0,0,.75)}.gui-settings-widgets:hover,.gui-settings:hover{opacity:1;transform:translateX(0)}.gui-settings-footer,.gui-settings-header{flex-grow:0;display:flex;align-items:center;justify-content:space-between;flex-shrink:0;z-index:10;padding:32px}.gui-settings-footer{height:80px;justify-content:center;position:relative}.gui-settings-content{flex-grow:1;overflow:auto;position:relative;overscroll-behavior:contain}.gui-settings-content ul{padding:0;margin:0}.gui-settings-content ul li{font-size:16px;margin-bottom:18px;display:flex;height:24px;transition:.2s}.gui-settings-content ul li.disabled,.gui-settings-content ul li:not(.category).folded{height:0;margin:0;overflow:hidden}.gui-settings-content ul li.indent-0{margin-left:16px}.gui-settings-content ul li.indent-1{margin-left:80px}.gui-settings-content ul li.indent-2{margin-left:144px}.gui-settings-content ul li.indent-center{align-items:center;justify-content:center}.gui-settings-content ul li.category{padding:16px 0;margin-bottom:18px;border-top:1px dashed #8884;border-bottom:1px dashed #8884;background:#fff;position:sticky;top:0;z-index:10;cursor:pointer;transition:.2s ease-out;-webkit-tap-highlight-color:transparent}.gui-settings-content ul li.category.folded{margin-bottom:-1px}.gui-settings-content ul li.category *{opacity:.8}.gui-settings-title{font-size:16pt;flex:0 0 auto}.gui-settings-box .gui-settings-title{margin-right:64px}.gui-settings-search[type=text]{flex:1 0 auto;height:auto;border:none;padding:6px;font-size:12pt;width:40%;border-bottom:1px solid #8884;transition:.2s;color:inherit;background:0 0;box-sizing:border-box;outline:0!important}.gui-settings-close{width:24px;height:24px;padding:16px}.gui-settings-header .gui-settings-close{cursor:pointer;-webkit-tap-highlight-color:transparent}.gui-settings-textbox-container{display:flex;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent}.gui-settings-dropdown-span,.gui-settings-textbox-container span{margin:0 16px;transition:.2s}.gui-settings-textbox-container input{border:none;height:100%;max-width:90px;padding:4px 8px;background:#8884;transition:.2s;font-size:16px}.gui-settings-textbox-container input:disabled,.gui-settings-textbox-container.disabled div,.gui-settings-textbox-container.disabled span{opacity:.5}.gui-settings-checkbox-container{cursor:pointer;display:flex;width:100%;justify-content:start;align-items:center;padding:0 16px;-webkit-tap-highlight-color:transparent}.gui-settings-checkbox-container input{visibility:collapse;transition:.2s;width:0}.gui-settings-checkbox-container .gui-settings-ok{width:24px;height:24px;margin-right:16px;transition:.2s}.gui-settings-checkbox-container input~.gui-settings-ok{background-color:#8884}.gui-settings-checkbox-container input:checked~.gui-settings-ok{background-color:var(--theme-color)}.gui-settings-checkbox-container input~.gui-settings-ok>i{opacity:0;transform-origin:center;transform:scale(.9)}.gui-settings-checkbox-container input:checked~.gui-settings-ok>i{opacity:1}.gui-settings-checkbox-container input:disabled~.gui-settings-ok,.gui-settings-checkbox-container input:disabled~span{opacity:.5}button.gui-settings-button{padding:6px 20px;margin:0 4px;max-height:34px;border:none;background:#8884;font-size:16px;cursor:pointer;transition:.2s ease-out;font-family:inherit;-webkit-tap-highlight-color:transparent}button.gui-settings-button:hover{opacity:.9}button.gui-settings-button:active{opacity:.8}button.gui-settings-button:focus{outline:0}.custom-color-preview{width:28px;height:28px;border-radius:50%;background:var(--theme-color);margin-right:16px;position:relative;cursor:pointer;box-sizing:border-box;box-shadow:0 2px 8px 1px var(--theme-color-70)}.predefined-colors{transition:.2s;display:flex;opacity:0;background:#fff;width:168px;height:168px;position:absolute;box-shadow:0 3px 20px 2px #0004;top:32px;left:calc(-84px + 50%);transform:scale(0);transform-origin:top;z-index:9}.predefined-colors.opened{opacity:1;transform:scale(1)}.predefined-colors-grid{display:grid;grid-template-columns:auto auto auto auto;margin:0;flex-grow:1}.predefined-colors-grid-block{width:100%;height:100%;justify-self:center;align-self:center;cursor:pointer;transform-origin:center;transition:.1s ease-out}.predefined-colors-grid-block:hover{transform:scale(1.1);box-shadow:0 0 8px 1px #0004}input[key]:focus{outline:0}input[type=text][key]{height:auto;border:none}.gui-settings-label{margin:0 16px;font-size:16px}.hidden{display:none!important}@supports (backdrop-filter:blur(24px)) or (-webkit-backdrop-filter:blur(24px)){.gui-settings-box.blur li.category{-webkit-backdrop-filter:blur(24px);backdrop-filter:blur(24px);background:0 0}.gui-settings-box.blur,.gui-settings-box.blur .gui-settings-content,.gui-settings-box.blur .gui-settings-footer,.gui-settings-box.blur .gui-settings-header{background:#fff8}.gui-settings-box.blur .gui-settings-content,.gui-settings-box.blur .gui-settings-footer,.gui-settings-box.blur .gui-settings-header{-webkit-backdrop-filter:blur(64px);backdrop-filter:blur(64px)}}li.category i.icon-arrow{transition:.2s ease-out}li.category.folded i.icon-arrow{transform:rotate(180deg)}.gui-settings-dropdown-container{display:flex;align-items:center}.gui-settings-dropdown{position:relative;cursor:pointer;-webkit-tap-highlight-color:transparent;background-color:#8884;display:inline-flex;align-items:center;height:32px}.gui-settings-dropdown>i{transition:.2s ease-out;transform-origin:center;transform:rotate(180deg)}.gui-settings-dropdown>ul{position:absolute;top:calc(100%);width:100%;cursor:pointer;background:#fff;transform-origin:top;transform:scaleY(0);transition:.2s ease-out;display:flex;flex-direction:column;align-items:center;box-shadow:0 3px 20px 2px #0004;z-index:100}.gui-settings-dropdown ul li{margin:0;padding:12px 0;height:auto;width:100%;justify-content:center}.gui-settings-dropdown ul li:hover{background:rgba(0,0,0,.16)}.gui-settings-dropdown.opened>ul{transform:scaleY(1)}.gui-settings-dropdown.opened>i{transform:rotate(0)}.gui-settings-dropdown input{cursor:pointer;border:none;height:100%;max-width:80px;padding:4px 8px;transition:.2s;font-size:16px;background-color:transparent}.gui-settings-mask{height:calc(100% + 5px);width:calc(100% + 5px);opacity:0;background:#000a;position:fixed;top:0;left:0;z-index:99999;pointer-events:none;transition:.3s cubic-bezier(0,.86,.58,1);overscroll-behavior:contain}.gui-settings-mask.opened{opacity:1;pointer-events:initial}.gui-settings-mask.opened.transparent{opacity:0;transition:.3s cubic-bezier(0,.86,.58,1) .3s}.gui-settings-box,.gui-settings-widgets-box{height:100%;width:400px;background:#fff;color:#000;position:fixed;top:0;left:0;z-index:100000;transform:translateX(-100%);transition:.3s cubic-bezier(0,.86,.58,1);display:none;flex-direction:column;box-shadow:4px 0 16px 0 #0000}.gui-settings-box.loaded,.gui-settings-widgets-box.loaded{display:flex}.gui-settings-widgets-box{min-width:200px;width:auto}.gui-settings-box.opened,.gui-settings-widgets-box.opened{transform:translateX(0);box-shadow:4px 0 16px 0 #0005}.gui-settings-widgets-box>.title{margin:32px;font-size:16pt}.gui-settings-widgets-box>.widgets-container{padding:32px;display:flex;flex-direction:column;align-items:stretch;justify-content:start;position:relative;overscroll-behavior:contain;overflow:auto;height:100%}.gui-settings-widgets-box>.widgets-container .empty-tip{font-size:10pt;display:none}.gui-settings-widgets-box>.widgets-container .empty-tip.show{display:block}.gui-settings-widgets-box>.gui-settings-header{justify-content:start}.gui-settings-flat-button,.gui-settings-flat-button a,.gui-settings-flat-button a:hover{display:flex;align-items:center;justify-content:center;color:inherit}.gui-settings-flat-button{width:auto;padding:8px 16px;background:#8884;border:none;color:#000;cursor:pointer;transition:.2s ease-out;font-size:10pt;border-bottom:2px solid var(--theme-color-50);flex:0 0 auto;margin:4px}.gui-settings-flat-button:disabled{opacity:.5;cursor:not-allowed}.gui-settings-flat-button:hover:not(:disabled){border-bottom-color:var(--theme-color-90)}.gui-settings-flat-button:active:not(:disabled){border-bottom-color:var(--theme-color)}.gui-settings-flat-button:focus{outline:0}.gui-settings-flat-button i{margin-right:8px;line-height:24px;height:24px}.gui-settings-checkbox{width:28px;margin-right:24px;height:12px;background:#8884;border-radius:16px;position:relative}.gui-settings-checkbox::after{content:"";width:20px;height:20px;background:#c6c6c6;position:absolute;border-radius:50%;top:-4px;left:-4px;box-shadow:0 2px 8px 1px #0003;transition:.2s ease-out}.gui-settings-checkbox-container input:checked~.gui-settings-checkbox{background:var(--theme-color-80)}.gui-settings-checkbox-container input:checked~.gui-settings-checkbox::after{background:var(--theme-color)!important;box-shadow:0 2px 8px 1px var(--theme-color-70);left:calc(100% - 16px)}.gui-settings-checkbox-container input:disabled~.gui-settings-checkbox{opacity:.5}.gui-settings-header>i{margin-right:8px}.player-full-win .app-content,.player-full-win .live-room-app .app-content,.player-mode-webfullscreen .player-module{z-index:100000!important}.gui-settings-flat-button .popup{position:absolute;top:calc(100% + 2px);transition:.16s ease-out;transform-origin:top;transform:scaleY(0) translateX(-50%);left:50%;background:#fff;box-shadow:0 3px 20px 2px #0004;z-index:200;display:flex;flex-direction:column;align-items:center;width:max-content}.gui-settings-flat-button .popup *{transition:.2s}.gui-settings-flat-button .popup.opened{transform:scaleY(1) translateX(-50%)}.gui-settings-flat-button .popup ul{list-style:none;margin:0;padding:0}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/gui-settings.min.html"] = `
    附加功能
    空空如也哦 = ̄ω ̄=
    设置
    • 视频
    • 样式
    • 工具
    • 触摸
    • 其他
    `; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/gui-settings.min.js"] = (()=>{return(e,t)=>{const{ThemeColors:n}=t.import("theme-colors");const{SettingsSearch:i}=t.import("settings-search");const{Validator:s}=t.import("text-validate");let o=[];let r=[];let c=[];function a(e){let t=e.nextElementSibling;const n=[];while(t!==null&&!t.classList.contains("category")){n.push(t);t=t.nextElementSibling}return n}function l(){c.forEach(t=>t.value=e[t.getAttribute("key")]);r.forEach(t=>t.checked=e[t.getAttribute("key")])}function u(){document.querySelector(".gui-settings-mask").addEventListener("click",()=>{document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask,.bilibili-evolved-about").forEach(e=>e.classList.remove("opened"))});c.forEach(t=>{t.setAttribute("placeholder",e[t.getAttribute("key")])});document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.addEventListener("click",e=>{const t=document.querySelector(".gui-settings-search");if(t.value!==""){t.value="";raiseEvent(t,"input")}e.currentTarget.classList.toggle("folded");a(e.currentTarget).forEach(e=>e.classList.toggle("folded"))})});document.querySelectorAll(".gui-settings-dropdown>input").forEach(e=>{e.addEventListener("click",e=>{e.currentTarget.parentElement.classList.toggle("opened")})})}function d(){const t=e=>{};r.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const s=n.checked;e[i]=s;t(i);saveSettings(e)})});c.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const o=s.getValidator(i).validate(n.value);e[i]=o;n.value=o;t(i);saveSettings(e)})})}function g(){const e=o.map(e=>[e.getAttribute("dependencies").split(" ").map(e=>o.find(t=>t.getAttribute("key")===e)),e]);const t=e=>e.nodeName.toUpperCase()==="LI"?e:t(e.parentElement);e.forEach(([e,n])=>{if(e[0]===undefined){return}const i=()=>{if(e.every(e=>e.checked)){t(n).classList.remove("disabled")}else{t(n).classList.add("disabled")}};e.forEach(e=>e.addEventListener("change",i));i()})}function f(){if(typeof offlineData!=="undefined"){document.querySelector(".gui-settings-checkbox-container>input[key=useCache]").parentElement.parentElement.classList.add("disabled");document.querySelector("input[key=useCache]").disabled=true}}function b(){document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.click()})}function m(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){o.find(e=>e.getAttribute("key")==="blurVideoControl").disabled=true;e.blurVideoControl=false;saveSettings(e)}if(window.devicePixelRatio===1){o.find(e=>e.getAttribute("key")==="harunaScale").disabled=true;o.find(e=>e.getAttribute("key")==="imageResolution").disabled=true;e.harunaScale=false;e.imageResolution=false;saveSettings(e)}if(e.defaultPlayerLayout==="旧版"){const t=o.find(e=>e.getAttribute("key")==="overrideNavBar");t.disabled=true;raiseEvent(t,"change");if(e.overrideNavBar){t.checked=false;raiseEvent(t,"change");e.overrideNavBar=false;saveSettings(e)}}}function y(){for(const[e,t]of Object.entries(Resource.displayNames)){const n=o.find(t=>t.getAttribute("key")===e);if(!n){continue}switch(n.type){case"checkbox":n.nextElementSibling.nextElementSibling.innerHTML=t;break;case"text":const e=n.parentElement;if(e.classList.contains("gui-settings-textbox-container")){n.previousElementSibling.innerHTML=t}else if(e.classList.contains("gui-settings-dropdown")){e.previousElementSibling.innerHTML=t}break;default:break}}}(async()=>{t.applyStyle("guiSettingsStyle");document.body.insertAdjacentHTML("afterbegin",``);const e=document.body&&unsafeWindow.parent.window!==unsafeWindow;if(e){document.querySelector(".gui-settings-icon-panel").style.display="none"}const s=(t.data.guiSettingsDom||t.data.guiSettingsHtml).text;document.body.insertAdjacentHTML("beforeend",s);const a=document.querySelector(".widgets-container");const p=a.querySelector(".empty-tip");Observer.childList(a,()=>{if(a.childElementCount<=1){p.classList.add("show")}else{p.classList.remove("show")}});o=[...document.querySelectorAll("input[key]")];r=o.filter(e=>e.type==="checkbox");c=o.filter(e=>e.type==="text");u();f();l();g();d();b();m();y();(new n).setupDom();new i;const h=document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box");document.querySelector(".gui-settings-icon-panel").addEventListener("mouseover",()=>{h.forEach(e=>e.classList.add("loaded"))},{once:true})})()}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/gui-settings.min.js"] = (()=>{return(e,t)=>{const{ThemeColors:n}=t.import("theme-colors");const{SettingsSearch:i}=t.import("settings-search");const{Validator:s}=t.import("text-validate");let o=[];let r=[];let c=[];function a(e){let t=e.nextElementSibling;const n=[];while(t!==null&&!t.classList.contains("category")){n.push(t);t=t.nextElementSibling}return n}function l(){c.forEach(t=>t.value=e[t.getAttribute("key")]);r.forEach(t=>t.checked=e[t.getAttribute("key")])}function u(){document.querySelector(".gui-settings-mask").addEventListener("click",()=>{document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask,.bilibili-evolved-about").forEach(e=>e.classList.remove("opened"))});c.forEach(t=>{t.setAttribute("placeholder",e[t.getAttribute("key")])});document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.addEventListener("click",e=>{const t=document.querySelector(".gui-settings-search");if(t.value!==""){t.value="";raiseEvent(t,"input")}e.currentTarget.classList.toggle("folded");a(e.currentTarget).forEach(e=>e.classList.toggle("folded"))})});document.querySelectorAll(".gui-settings-dropdown>input").forEach(e=>{e.addEventListener("click",e=>{e.currentTarget.parentElement.classList.toggle("opened")})})}function d(){const t=e=>{};r.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const s=n.checked;e[i]=s;t(i);saveSettings(e)})});c.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const o=s.getValidator(i).validate(n.value);e[i]=o;n.value=o;t(i);saveSettings(e)})})}function g(){const e=o.map(e=>[e.getAttribute("dependencies").split(" ").map(e=>o.find(t=>t.getAttribute("key")===e)),e]);const t=e=>e.nodeName.toUpperCase()==="LI"?e:t(e.parentElement);e.forEach(([e,n])=>{if(e[0]===undefined){return}const i=()=>{if(e.every(e=>e.checked)){t(n).classList.remove("disabled")}else{t(n).classList.add("disabled")}};e.forEach(e=>e.addEventListener("change",i));i()})}function f(){if(typeof offlineData!=="undefined"){document.querySelector(".gui-settings-checkbox-container>input[key=useCache]").parentElement.parentElement.classList.add("disabled");document.querySelector("input[key=useCache]").disabled=true}}function b(){document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.click()})}function m(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){o.find(e=>e.getAttribute("key")==="blurVideoControl").disabled=true;e.blurVideoControl=false;saveSettings(e)}if(window.devicePixelRatio===1){o.find(e=>e.getAttribute("key")==="harunaScale").disabled=true;o.find(e=>e.getAttribute("key")==="imageResolution").disabled=true;e.harunaScale=false;e.imageResolution=false;saveSettings(e)}if(e.defaultPlayerLayout==="旧版"){const t=o.find(e=>e.getAttribute("key")==="overrideNavBar");t.disabled=true;raiseEvent(t,"change");if(e.overrideNavBar){t.checked=false;raiseEvent(t,"change");e.overrideNavBar=false;saveSettings(e)}}}function y(){for(const[e,t]of Object.entries(Resource.displayNames)){const n=o.find(t=>t.getAttribute("key")===e);if(!n){continue}switch(n.type){case"checkbox":n.nextElementSibling.nextElementSibling.innerHTML=t;break;case"text":const e=n.parentElement;if(e.classList.contains("gui-settings-textbox-container")){n.previousElementSibling.innerHTML=t}else if(e.classList.contains("gui-settings-dropdown")){e.previousElementSibling.innerHTML=t}break;default:break}}}(async()=>{t.applyStyle("guiSettingsStyle");document.body.insertAdjacentHTML("afterbegin",``);const e=document.body&&unsafeWindow.parent.window!==unsafeWindow;if(e){document.querySelector(".gui-settings-icon-panel").style.display="none"}const s=t.data.guiSettingsHtml.text;document.body.insertAdjacentHTML("beforeend",s);const a=document.querySelector(".widgets-container");const p=a.querySelector(".empty-tip");Observer.childList(a,()=>{if(a.childElementCount<=1){p.classList.add("show")}else{p.classList.remove("show")}});(new n).setupDom();const h=document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box");document.querySelector(".gui-settings-icon-panel").addEventListener("mouseover",()=>{h.forEach(e=>e.classList.add("loaded"));o=[...document.querySelectorAll("input[key]")];r=o.filter(e=>e.type==="checkbox");c=o.filter(e=>e.type==="text");u();f();l();g();d();b();m();y();new i},{once:true})})()}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/haruna-scale.min.js"] = (()=>{return(n,t)=>{const a="bilibili-haruna-scale";if($(a).length===0){t.applyStyleFromText(`\n \n `)}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/hide-banner.min.css"] = `#banner_link,.custom-navbar .blur-layer,.z-top-container.has-banner>.header{display:none!important}.b-header-mask-wrp .b-header-mask-bg,div.blur-bg{opacity:0!important}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/hide-banner.min.js"] = (()=>{return(e,l)=>{const r="hideBannerStyle";l.applyStyle(r);return{reload:()=>l.applyStyle(r),unload:()=>l.removeStyle(r)}}})(); @@ -1073,7 +1073,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/image-viewer.min.html"] = `
    `; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/medal-helper.min.css"] = `.medal-popup{position:absolute;top:calc(100% + 2px);transition:.16s ease-out;transform-origin:top;transform:scaleY(0) translateX(-50%);left:50%;background:#fff;box-shadow:0 3px 20px 2px #0004;z-index:100}.medal-popup.opened{transform:scaleY(1) translateX(-50%)}.medal-popup *{transition:.2s}.medal-popup ul{list-style:none;margin:0;padding:0}.medal-popup ul>li.active{box-shadow:0 0 4px 0 var(--theme-color)}.medal-popup ul>li:hover{background-color:rgba(0,0,0,.16)}.medal-popup label{display:flex;align-items:center;justify-content:center;cursor:pointer;padding:8px}.medal-popup label>*{flex-shrink:0}.medal-popup input[type=radio]{visibility:collapse;width:0;margin:0;padding:0}.medal-popup input[type=radio]~i{opacity:0;transform:scale(.8);margin:0}.medal-popup input[type=radio]~.fans-medal-item{margin:0 8px}.medal-popup input[type=radio]:checked~i{opacity:1}.title-image{display:inline-block;vertical-align:middle;height:20px}.fans-medal-item .label{width:40px;text-align:center;padding:0 2px;color:#fff}.fans-medal-item .level{width:16px;background-color:#fff;text-align:center;color:#61decb}.fans-medal-item .label,.fans-medal-item .level{position:relative;display:block;float:left}.fans-medal-item{display:inline-block;height:14px;line-height:14px;color:#fff;border:1px solid #61decb;border-left:0;white-space:nowrap;border-radius:2px;flex-shrink:0;font-size:12px}.level-1,.level-2,.level-3,.level-4{border-color:#61decb}.level-1 .label,.level-2 .label,.level-3 .label,.level-4 .label{background-color:#61decb}.level-1 .level,.level-2 .level,.level-3 .level,.level-4 .level{color:#61decb}.level-5,.level-6,.level-7,.level-8{border-color:#5896de}.level-5 .label,.level-6 .label,.level-7 .label,.level-8 .label{background-color:#5896de}.level-5 .level,.level-6 .level,.level-7 .level,.level-8 .level{color:#5896de}.level-10,.level-11,.level-12,.level-9{border-color:#a068f1}.level-10 .label,.level-11 .label,.level-12 .label,.level-9 .label{background-color:#a068f1}.level-10 .level,.level-11 .level,.level-12 .level,.level-9 .level{color:#a068f1}.level-13,.level-14,.level-15,.level-16{border-color:#ff86b2}.level-13 .label,.level-14 .label,.level-15 .label,.level-16 .label{background-color:#ff86b2}.level-13 .level,.level-14 .level,.level-15 .level,.level-16 .level{color:#ff86b2}.level-17,.level-18,.level-19,.level-20{border-color:#f6be18}.level-17 .label,.level-18 .label,.level-19 .label,.level-20 .label{background-color:#f6be18}.level-17 .level,.level-18 .level,.level-19 .level,.level-20 .level{color:#f6be18}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/medal-helper.min.html"] = `
    更换勋章
      更换头衔
        `; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/medal-helper.min.js"] = (()=>{return(e,t)=>{class i{constructor(e,t){this.isActive=e;this.id=t}static parseJson(e,{successAction:t,errorMessage:i,errorAction:a}){const s=JSON.parse(e);if(s.code!==0){logError(`${i} 错误码:${s.code} ${s.message||""}`);return a(s)}return t(s)}}class a extends i{constructor({medal_id:e,status:t,level:i,medalName:a,uname:s}){super(t===1,e);this.level=i;this.name=a;this.upName=s}static async getList(){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/i/api/medal?page=1&pageSize=256"),{successAction:e=>e.data.fansMedalList.map(e=>new a(e)),errorAction:()=>[],errorMessage:"无法获取勋章列表."})}static getContainer(){return document.querySelector("#medal-helper .medal-popup ul")}static getItemTemplate(e){return`
      • \n \n
      • `}async activate(){return i.parseJson(await Ajax.getTextWithCredentials(`https://api.live.bilibili.com/i/ajaxWearFansMedal?medal_id=${this.id}`),{successAction:()=>{this.isActive=true;return true},errorAction:()=>false,errorMessage:"佩戴勋章失败."})}async deactivate(){return i.parseJson(await Ajax.getTextWithCredentials(`https://api.live.bilibili.com/i/ajaxCancelWear`),{successAction:()=>{this.isActive=false;return true},errorAction:()=>false,errorMessage:"卸下勋章失败."})}}class s extends i{constructor({id:e,cid:t,wear:i,css:a,name:r,source:c}){super(i,a);this.tid=e;this.cid=t;this.name=r;this.source=c;s.getImageMap().then(e=>{this.imageUrl=e[this.id]})}static async getImageMap(){if(s.imageMap===undefined){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/rc/v1/Title/webTitles"),{successAction(e){s.imageMap={};e.data.forEach(e=>{s.imageMap[e.identification]=e.web_pic_url});return s.imageMap},errorAction:()=>{return{}},errorMessage:"获取头衔图片失败."})}else{return s.imageMap}}static async getList(){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/i/api/ajaxTitleInfo?page=1&pageSize=256&had=1"),{successAction:e=>e.data.list.map(e=>new s(e)),errorAction:()=>[],errorMessage:"无法获取头衔列表."})}static getContainer(){return document.querySelector("#title-helper .medal-popup ul")}static getItemTemplate(e){return`
      • \n \n
      • `}async activate(){return i.parseJson(await Ajax.postTextWithCredentials(`https://api.live.bilibili.com/i/ajaxWearTitle`,`id=${this.tid}&cid=${this.cid}`),{successAction:()=>{this.isActive=true;return true},errorAction:()=>false,errorMessage:"佩戴头衔失败."})}async deactivate(){return i.parseJson(await Ajax.postTextWithCredentials(`https://api.live.bilibili.com/i/ajaxCancelWearTitle`,""),{successAction:()=>{this.isActive=false;return true},errorAction:()=>false,errorMessage:"卸下头衔失败."})}}async function r(e){const t=e.getContainer();const i=await e.getList();const a=async()=>{const i=await e.getList();i.forEach(e=>{const i=t.querySelector(`li[data-id='${e.id}']`);if(e.isActive){i.classList.add("active")}else{i.classList.remove("active")}i.querySelector(`input`).checked=e.isActive})};i.forEach(s=>{const r=e.getItemTemplate(s);t.insertAdjacentHTML("beforeend",r);const c=t.querySelector(`li[data-id='${s.id}']`);const n=c.querySelector(`input`);c.addEventListener("click",e=>{if(e.target===n){return}if(s.isActive){s.deactivate().then(a)}else{const e=i.find(e=>e.isActive);if(e){e.isActive=false}s.activate().then(a)}})})}return{export:{Badge:i,Medal:a,Title:s},widget:{condition:()=>document.domain==="live.bilibili.com",content:(t.data.medalHelperDom||t.data.medalHelperHtml).text,success:()=>{document.querySelectorAll(".medal-helper").forEach(e=>{const t=e.querySelector(".medal-popup");e.addEventListener("click",e=>{if(!t.contains(e.target)){t.classList.toggle("opened")}})});r(a);s.getImageMap().then(()=>r(s))}}}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/medal-helper.min.js"] = (()=>{return(e,t)=>{class i{constructor(e,t){this.isActive=e;this.id=t}static parseJson(e,{successAction:t,errorMessage:i,errorAction:a}){const s=JSON.parse(e);if(s.code!==0){logError(`${i} 错误码:${s.code} ${s.message||""}`);return a(s)}return t(s)}}class a extends i{constructor({medal_id:e,status:t,level:i,medalName:a,uname:s}){super(t===1,e);this.level=i;this.name=a;this.upName=s}static async getList(){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/i/api/medal?page=1&pageSize=256"),{successAction:e=>e.data.fansMedalList.map(e=>new a(e)),errorAction:()=>[],errorMessage:"无法获取勋章列表."})}static getContainer(){return document.querySelector("#medal-helper .medal-popup ul")}static getItemTemplate(e){return`
      • \n \n
      • `}async activate(){return i.parseJson(await Ajax.getTextWithCredentials(`https://api.live.bilibili.com/i/ajaxWearFansMedal?medal_id=${this.id}`),{successAction:()=>{this.isActive=true;return true},errorAction:()=>false,errorMessage:"佩戴勋章失败."})}async deactivate(){return i.parseJson(await Ajax.getTextWithCredentials(`https://api.live.bilibili.com/i/ajaxCancelWear`),{successAction:()=>{this.isActive=false;return true},errorAction:()=>false,errorMessage:"卸下勋章失败."})}}class s extends i{constructor({id:e,cid:t,wear:i,css:a,name:r,source:c}){super(i,a);this.tid=e;this.cid=t;this.name=r;this.source=c;s.getImageMap().then(e=>{this.imageUrl=e[this.id]})}static async getImageMap(){if(s.imageMap===undefined){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/rc/v1/Title/webTitles"),{successAction(e){s.imageMap={};e.data.forEach(e=>{s.imageMap[e.identification]=e.web_pic_url});return s.imageMap},errorAction:()=>{return{}},errorMessage:"获取头衔图片失败."})}else{return s.imageMap}}static async getList(){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/i/api/ajaxTitleInfo?page=1&pageSize=256&had=1"),{successAction:e=>e.data.list.map(e=>new s(e)),errorAction:()=>[],errorMessage:"无法获取头衔列表."})}static getContainer(){return document.querySelector("#title-helper .medal-popup ul")}static getItemTemplate(e){return`
      • \n \n
      • `}async activate(){return i.parseJson(await Ajax.postTextWithCredentials(`https://api.live.bilibili.com/i/ajaxWearTitle`,`id=${this.tid}&cid=${this.cid}`),{successAction:()=>{this.isActive=true;return true},errorAction:()=>false,errorMessage:"佩戴头衔失败."})}async deactivate(){return i.parseJson(await Ajax.postTextWithCredentials(`https://api.live.bilibili.com/i/ajaxCancelWearTitle`,""),{successAction:()=>{this.isActive=false;return true},errorAction:()=>false,errorMessage:"卸下头衔失败."})}}async function r(e){const t=e.getContainer();const i=await e.getList();const a=async()=>{const i=await e.getList();i.forEach(e=>{const i=t.querySelector(`li[data-id='${e.id}']`);if(e.isActive){i.classList.add("active")}else{i.classList.remove("active")}i.querySelector(`input`).checked=e.isActive})};i.forEach(s=>{const r=e.getItemTemplate(s);t.insertAdjacentHTML("beforeend",r);const c=t.querySelector(`li[data-id='${s.id}']`);const n=c.querySelector(`input`);c.addEventListener("click",e=>{if(e.target===n){return}if(s.isActive){s.deactivate().then(a)}else{const e=i.find(e=>e.isActive);if(e){e.isActive=false}s.activate().then(a)}})})}return{export:{Badge:i,Medal:a,Title:s},widget:{condition:()=>document.domain==="live.bilibili.com",content:t.data.medalHelperHtml.text,success:()=>{document.querySelectorAll(".medal-helper").forEach(e=>{const t=e.querySelector(".medal-popup");e.addEventListener("click",e=>{if(!t.contains(e.target)){t.classList.toggle("opened")}})});r(a);s.getImageMap().then(()=>r(s))}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/narrow-danmaku.min.js"] = (()=>{return(e,l)=>{const i=``;l.applyStyleFromText(i);return{reload:()=>l.applyStyleFromText(i),unload:()=>document.getElementById("narrow-danmaku-style").remove()}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/new-styles.min.js"] = (()=>{return(e,l)=>{if(document.URL===`https://h.bilibili.com/`){return}if(document.querySelector(`.z_header`)!==null){l.removeStyle("tweetsStyle");return}SpinQuery.any(()=>$(".custom-scrollbar"),e=>e.removeClass("custom-scrollbar"));SpinQuery.any(()=>$("#banner_link"),()=>l.removeStyle("tweetsStyle"));if(["/h.bilibili.com","/live.bilibili.com","/link.bilibili.com"].some(e=>document.URL.includes(e))){l.applyStyle("style","bilibili-style-optimization")}else{Promise.race([SpinQuery.select(()=>document.querySelector(".bili-header-m")).then(e=>e!==null&&e.classList.contains("stardust-video")),SpinQuery.select(()=>document.querySelector("body>#Header")).then(e=>e!==null)]).then(e=>l.applyStyle(e?"style":"oldStyle","bilibili-style-optimization"))}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/no-banner.min.css"] = `#banner_link,.z-top-container.has-banner>.header{display:none!important}.b-header-mask-wrp .b-header-mask-bg,div.blur-bg{opacity:0!important}`; @@ -1115,7 +1115,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-player.min.js"] = (()=>{return(t,i)=>{const e=t=>{let i=0;let e=0;while(t&&!isNaN(t.offsetLeft)&&!isNaN(t.offsetTop)){i+=t.offsetLeft-t.scrollLeft;e+=t.offsetTop-t.scrollTop;t=t.offsetParent}return{x:i,y:e}};const s=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const s=t-i*3600-e*60;let o=fixed(s)+"秒";if(e>0){o=e+"分"+o}if(i>0){o=i+"时"+o}return o};const o=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const s=t-i*3600-e*60;let o=(s<10?"0":"")+fixed(s);o=(e<10?"0":"")+e+":"+o;o=(i<10?"0":"")+i+":"+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",i=>{if(!this.xDown||!this.yDown){return}const s=i.touches[0].clientX;const o=i.touches[0].clientY;const n=e(t);const l={x:(i.touches[0].pageX-n.x)/t.clientWidth,y:(i.touches[0].pageY-n.y)/t.clientHeight,width:t.clientWidth,height:t.clientHeight};const a=this.xDown-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;i.preventDefault()}else{if(this.direction==="vertical"){this.action.startAction(this.direction,c,l)}else if(this.direction==="horizontal"){this.action.startAction(this.direction,-a,l)}i.preventDefault()}});t.addEventListener("touchend",t=>{this.xDown=null;this.yDown=null;this.direction=null;if(this.onTouchEnd){this.onTouchEnd(t)}})}}class l{constructor(t){this.lowSpeedForward=null;this.lowSpeedBackward=null;this.mediumSpeedForward=null;this.mediumSpeedBackward=null;this.highSpeedForward=null;this.highSpeedBackward=null;this.lowVolumeUp=null;this.lowVolumeDown=null;this.mediumVolumeUp=null;this.mediumVolumeDown=null;this.highVolumeUp=null;this.highVolumeDown=null;this.speedCancel=null;this.volumeCancel=null;this.minSwipeDistance=20;this.onActionStart=null;this.onActionEnd=null;this.element=t;this.touchStart=false;this.startPosition=null;this.lastAction=null;t.addEventListener("touchstart",t=>{this.touchStart=true});t.addEventListener("touchend",t=>{this.startPosition=null;this.onActionEnd&&this.onActionEnd(this.lastAction);this.lastAction=null})}startAction(t,i,e){if(this.touchStart){this.onActionStart&&this.onActionStart(t);this.startPosition=e;this.touchStart=false}if(t==="vertical"){if(Math.abs(i)=1/3&&this.startPosition.x<=2/3){t=1;s=this.mediumVolumeUp;o=this.mediumVolumeDown}else{t=2;s=this.highVolumeUp;o=this.highVolumeDown}if(i>0){const o=Math.round(t*100*(i-this.minSwipeDistance)/(1.5*e.height));s&&s(o);this.lastAction={type:"volume",volume:o}}else{const s=Math.round(t*100*(i+this.minSwipeDistance)/(1.5*e.height));o&&o(s);this.lastAction={type:"volume",volume:s}}}}else if(t==="horizontal"){if(e.y<1/3&&(e.x<.1||e.x>.9)||Math.abs(i)=1/3&&this.startPosition.y<=2/3){t=.2;e=this.mediumSpeedForward;s=this.mediumSpeedBackward}else{t=1;e=this.highSpeedForward;s=this.highSpeedBackward}if(i>0){const s=(i-this.minSwipeDistance)*t;e&&e(s);this.lastAction={type:"playback",seconds:s}}else{const e=(i+this.minSwipeDistance)*t;s&&s(e);this.lastAction={type:"playback",seconds:e}}}}}}class a{constructor(){this.aid=unsafeWindow.aid;this.cid=unsafeWindow.cid;this.cidData=null;this.supportWebp=a.supportWebp}getVideoshot(t,i){if(!(this.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(e=>{this.cidData=JSON.parse(e).data;this.getVideoshot(t,i)})}else{const e=this.cidData;const s=e.index;let o=0;for(let i=0;i=s[i]&&tt.replace(".jpg",".jpg@.webp"))}const l=parseInt(e.pv_x_len)||10;const a=parseInt(e.pv_y_len)||10;const c=parseInt(e.pv_x_size)||160;const r=parseInt(e.pv_y_size)||90;const d=-(o%100%l)*c;const h=-Math.floor(o%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(o/100)]})`,backgroundPosition:`${d}px ${h}px`})}}static get supportWebp(){try{const t=document.createElement("canvas");if(t.getContext&&t.getContext("2d"))try{return t.toDataURL("image/webp").indexOf("data:image/webp")===0}catch(t){return false}else return false}catch(t){return false}}}function c(t){t.unbind("click")}function r(i){if($(".touch-video-box").length!==0){return}$(".bilibili-player-video-subtitle").before(`\n
        \n
        \n
        \n
        \n
        \n
        `);const e=$("video");const l=e.prop("duration");const c=new n(i.get(0));const r=document.getElementsByClassName("touch-video-info")[0];const d=document.getElementsByClassName("touch-video-box")[0];let h=Math.round(e.prop("volume")*100);const u=t=>{t/=100;if(t<0){t=0}else if(t>1){t=1}e.prop("volume",t);const i=JSON.parse(localStorage.bilibili_player_settings);i.video_status.volume=t;localStorage.bilibili_player_settings=JSON.stringify(i);$(".bilibili-player-video-volume-num").text(Math.round(t*100));$(".bui-thumb").css("transform",`translateY(-${48*t}px)`);$(".bui-track-vertical .bui-bar").css("transform",`scaleY(${t})`);if(t===0){$(".bilibili-player-video-btn-volume").addClass("video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-max");e.prop("muted",true)}else if(t===1){$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-min");$(".bilibili-player-video-btn-volume").addClass("video-state-volume-max");e.prop("muted",false)}else{$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-max");e.prop("muted",false)}};if(t.touchVideoPlayerAnimation){d.classList.add("animation")}c.action.onActionStart=(t=>{d.classList.add("adjust-opened");r.innerHTML="";h=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");const a=fixed(100*n/l);let c=n+i;let d=fixed(100*c/l);let h=i;if(c>l){c=l;d=100;h=l-n}else if(c<0){c=0;d=0;h=n}const u=`${o(n)} (${a}%)
        👇
        ${o(c)} (${d}%)`;const m=`\n
        \n
        \n ${t}速\n
        \n
        \n 进度: ${i>0?"+":"-"}${s(h)}\n
        \n
        \n
        \n
        \n
        \n
        \n
        \n ${u}\n
        \n
        \n `;r.innerHTML=m;p.getVideoshot(c,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${d/100})`)}};c.action.lowSpeedBackward=m("低");c.action.lowSpeedForward=m("低");c.action.mediumSpeedBackward=m("中");c.action.mediumSpeedForward=m("中");c.action.highSpeedBackward=m("高");c.action.highSpeedForward=m("高");const v=t=>{return i=>{let e=h+i;let s=Math.abs(i);if(e>100){e=100;s=100-h}else if(e<0){e=0;s=h}const o=`${h} 👉 ${e}`;u(e);const n=`\n
        \n
        \n ${t}速\n
        \n
        \n 音量: ${i>0?"+":"-"}${s}\n
        \n
        \n
        \n
        \n ${o}\n
        \n
        \n `;r.innerHTML=n;$(".touch-progress").css("transform",`scaleX(${e/100})`)}};c.action.lowVolumeUp=v("低");c.action.lowVolumeDown=v("低");c.action.mediumVolumeUp=v("中");c.action.mediumVolumeDown=v("中");c.action.highVolumeUp=v("高");c.action.highVolumeDown=v("高");c.action.speedCancel=(()=>{r.innerHTML=`松开手指,取消进退`;$(".touch-progress").css("transform","scaleX(0)")});c.action.volumeCancel=(()=>{r.innerHTML=`松开手指,取消调整`;$(".touch-progress").css("transform","scaleX(0)");u(h)});if(!unsafeWindow.TOUCH_PLAYER_DEBUG){c.action.onActionEnd=(t=>{r.innerHTML="";if(t){if(t.type==="playback"){let i=e.prop("currentTime");i+=t.seconds;if(i<0){i=0}else if(i>l){i=l}e.prop("currentTime",i)}}d.classList.remove("adjust-opened")})}}function d(t){if(!t.hasClass("disable-original-hover")){t.addClass("disable-original-hover");const i=unsafeWindow.$(".bilibili-player-video");const e="touch-video-control-show";const s=i.data("events").click[0].handler;const o=new DoubleClickEvent(t=>s(t),()=>t.toggleClass(e));i.unbind("click");o.bind(i[0])}}const h=()=>{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"),d).start()}};if(Observer.videoChange){Observer.videoChange(h)}else{Observer.childList("#bofqi",()=>h())}i.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/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);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=[].map.call(i.querySelectorAll("d[p]"),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/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($(".image-viewer").length===0){this.createContainer()}this.viewer=$(".image-viewer-container");this.downloadImage()}createContainer(){$("body").append((t.data.imageViewerDom||t.data.imageViewerHtml).text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=n();const i=URL.createObjectURL(e.response);if(this.imageData){URL.revokeObjectURL(this.imageData)}this.imageData=i;this.viewer.find(".download").attr("href",i).attr("download",t+this.url.substring(this.url.lastIndexOf(".")));this.viewer.find(".copy-link").on("click",()=>GM_setClipboard(this.url));this.viewer.find(".new-tab").attr("href",this.url);this.viewer.find(".image").prop("src",i)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}return(()=>{if($("meta[itemprop='image'],meta[property='og:image']").length>0){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);await t.fetchInfo();return t.coverUrl}let t=new o(await e());$("#view-cover").on("click",()=>{t.show()});const n=async()=>{t=new o(await e())};if(Observer.videoChange){Observer.videoChange(n)}else{Observer.childList("#bofqi",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=$(".header-info-ctnr .room-cover");const t=e.attr("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.getText(i);const s=JSON.parse(n).data.cover;const a=new o(s);$("#view-cover").on("click",()=>{a.show()})}}}}}})()}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{const{VideoInfo:i}=t.import("video-info");const{getFriendlyTitle:n}=t.import("title");class o{constructor(e){this.url=e;if($(".image-viewer").length===0){this.createContainer()}this.viewer=$(".image-viewer-container");this.downloadImage()}createContainer(){$("body").append(t.data.imageViewerHtml.text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=n();const i=URL.createObjectURL(e.response);if(this.imageData){URL.revokeObjectURL(this.imageData)}this.imageData=i;this.viewer.find(".download").attr("href",i).attr("download",t+this.url.substring(this.url.lastIndexOf(".")));this.viewer.find(".copy-link").on("click",()=>GM_setClipboard(this.url));this.viewer.find(".new-tab").attr("href",this.url);this.viewer.find(".image").prop("src",i)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}return(()=>{if($("meta[itemprop='image'],meta[property='og:image']").length>0){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);await t.fetchInfo();return t.coverUrl}let t=new o(await e());$("#view-cover").on("click",()=>{t.show()});const n=async()=>{t=new o(await e())};if(Observer.videoChange){Observer.videoChange(n)}else{Observer.childList("#bofqi",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=$(".header-info-ctnr .room-cover");const t=e.attr("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.getText(i);const s=JSON.parse(n).data.cover;const a=new o(s);$("#view-cover").on("click",()=>{a.show()})}}}}}})()}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater.min.js"] = (()=>{return(e,t)=>{const r=e=>{const t=e.match(/(av[\d]+)\/p([\d]+)/);if(t){return`https://www.bilibili.com/video/${t[1]}/?p=${t[2]}`}else{return"javascript:;"}};const a=e=>{const t=e.map(e=>{const t=e.getAttribute("href");if(!t){return"javascript:;"}if(t.match(/.*watchlater.*|javascript:;/g)){return r(t)}if(t.indexOf("video/av")!==-1){return t}});e.forEach((e,r)=>$(e).attr("href",t[r]).attr("target","_blank"))};const i=(...e)=>{for(const t of e){SpinQuery.select(()=>document.querySelectorAll(t),e=>a([...e]))}};SpinQuery.any(()=>$(".watch-later-list"),()=>{(Observer.childListSubtree||Observer.subtree)("#viewlater-app",()=>{SpinQuery.condition(()=>document.URL.match(/(av[\d]+)\/p([\d]+)/),e=>e&&document.URL.indexOf("watchlater")!==-1,()=>{const e=r(document.URL);if(e!==null){window.location.replace(e)}});SpinQuery.any(()=>$("#viewlater-app .s-btn[href='#/']"),e=>e.remove());i(".av-pic",".av-about>a")})});SpinQuery.any(()=>$("li.nav-item[report-id*=watchlater]"),()=>{(Observer.childListSubtree||Observer.subtree)("li.nav-item[report-id*=watchlater]",()=>{i(".av-item>a",".av-about>a","div.watch-later-m>ul>div>li>a");SpinQuery.any(()=>$(".read-more.mr"),e=>e.remove());SpinQuery.any(()=>$(".read-more-grp>.read-more"),e=>e.css({float:"none",width:"auto"}))})})}})(); class ResourceType diff --git a/bilibili-evolved.preview-offline.user.js b/bilibili-evolved.preview-offline.user.js index 973a320c7..49d30e924 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 298.28 +// @version 298.29 // @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -1033,14 +1033,14 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/debounce.min.js"] = (()=>{return(n,l)=>{function u(n,l,u){var e,t,i,r,f;if(null==l)l=100;function o(){var a=Date.now()-r;if(a=0){e=setTimeout(o,l-a)}else{e=null;if(!u){f=n.apply(i,t);i=t=null}}}var a=function(){i=this;t=arguments;r=Date.now();var a=u&&!e;if(!e)e=setTimeout(o,l);if(a){f=n.apply(i,t);i=t=null}return f};a.clear=function(){if(e){clearTimeout(e);e=null}};a.flush=function(){if(e){f=n.apply(i,t);i=t=null;clearTimeout(e);e=null}};return a}return{export:{debounce:u}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-danmaku-settings.min.css"] = `.bilibili-player-video-danmaku-setting-wrap{display:none!important}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-danmaku-settings.min.js"] = (()=>{return(e,t)=>{async function i(e,t){const i=await SpinQuery.select(()=>document.querySelector(e));if(!i){return}i.checked=t;raiseEvent(i,"change")}if(!e.enableDanmaku){i(".bilibili-player-video-danmaku-switch>input",false)}if(e.rememberDanmakuSettings){const i={subtitlesPreserve:".bilibili-player-video-danmaku-setting-left-preventshade input",smartMask:".bilibili-player-video-danmaku-setting-left-danmaku-mask input"};async function n(){const n=await SpinQuery.select(()=>document.querySelector(".bilibili-player-video-danmaku-setting"));if(!n){return}await loadLazyPanel(".bilibili-player-video-danmaku-setting");setTimeout(()=>t.removeStyle("defaultDanmakuSettingsStyle"),300);for(const[t,n]of Object.entries(e.danmakuSettings)){const e=await SpinQuery.select(()=>document.querySelector(i[t]));if(e!==null&&e.checked!==undefined&&e.checked!==n){e.click()}}}async function a(){for(const t in e.danmakuSettings){const n=await SpinQuery.select(()=>document.querySelector(i[t]));if(!n){return}n.addEventListener("click",()=>{e.danmakuSettings=Object.assign(e.danmakuSettings,{[t]:n.checked});saveSettings(e)})}}n();a()}}})(); -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-player-layout.min.js"] = (()=>{return(e,t)=>{class s{setCookie(e,t){document.cookie=`${e}=${t};path=/;domain=.bilibili.com;max-age=31536000`}clearCookie(e){document.cookie=`${e}=;path=/;domain=.bilibili.com;max-age=0`}getValue(e){return document.cookie.replace(new RegExp(`(?:(?:^|.*;\\s*)${e}\\s*\\=\\s*([^;]*).*$)|^.*$`),"$1")}checkSettings(){return e.useDefaultPlayerLayout}checkCookies(){if(!this.checkSettings()){return}}useNewLayout(){if(!this.checkSettings()){return}}useOldLayout(){if(!this.checkSettings()){return}}setLayout(e){if(e){this.useNewLayout()}else{this.useOldLayout()}}}class o extends s{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<0&&e.defaultPlayerLayout!=="旧版"){this.useNewLayout()}else if(e.defaultPlayerLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustvideo";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,1)}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,-1)}}class i extends s{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<=0&&e.defaultBangumiLayout!=="旧版"){this.useNewLayout()}else if(e.defaultBangumiLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustpgcv";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,"0606")}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,0)}}const u=new o;addSettingsListener("defaultPlayerLayout",e=>{console.log("layout change detected");u.setLayout(e==="新版")});const a=new i;addSettingsListener("defaultBangumiLayout",e=>{a.setLayout(e==="新版")})}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-player-layout.min.js"] = (()=>{return(e,t)=>{class s{setCookie(e,t){document.cookie=`${e}=${t};path=/;domain=.bilibili.com;max-age=31536000`}clearCookie(e){document.cookie=`${e}=;path=/;domain=.bilibili.com;max-age=0`}getValue(e){return document.cookie.replace(new RegExp(`(?:(?:^|.*;\\s*)${e}\\s*\\=\\s*([^;]*).*$)|^.*$`),"$1")}checkSettings(){return e.useDefaultPlayerLayout}checkCookies(){if(!this.checkSettings()){return}}useNewLayout(){if(!this.checkSettings()){return}}useOldLayout(){if(!this.checkSettings()){return}}setLayout(e){if(e){this.useNewLayout()}else{this.useOldLayout()}}}class o extends s{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<0&&e.defaultPlayerLayout!=="旧版"){this.useNewLayout()}else if(e.defaultPlayerLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustvideo";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,1)}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,-1)}}class i extends s{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<=0&&e.defaultBangumiLayout!=="旧版"){this.useNewLayout()}else if(e.defaultBangumiLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustpgcv";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,"0606")}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,0)}}const u=new o;addSettingsListener("defaultPlayerLayout",e=>{u.setLayout(e==="新版")});const a=new i;addSettingsListener("defaultBangumiLayout",e=>{a.setLayout(e==="新版")})}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-player-mode.min.js"] = (()=>{return(e,i)=>{if(typeof isEmbeddedPlayer!=="undefined"&&isEmbeddedPlayer()){return}const n=[{name:"常规",action:()=>{}},{name:"宽屏",action:()=>{document.querySelector(".bilibili-player-video-btn-widescreen").click();document.querySelector("#bofqi").scrollIntoView({behavior:"smooth"})}},{name:"网页全屏",action:()=>{document.querySelector(".bilibili-player-video-web-fullscreen").click()}},{name:"全屏",action:()=>{document.querySelector(".bilibili-player-video-btn-fullscreen").click()}}];let t=()=>{};let o=()=>{};async function l(){if(e.autoLightOff){await SpinQuery.unsafeJquery();const e=await SpinQuery.any(()=>unsafeWindow.$(".bilibili-player-video-btn-setting"));if(!e){return}e.mouseover().mouseout();const i=async e=>{const i=await SpinQuery.select(()=>document.querySelector(".bilibili-player-video-btn-setting-panel-others-content-lightoff .bui-checkbox-input"));i.checked=e;raiseEvent(i,"change")};t=(()=>i(true));o=(()=>i(false))}}async function a(){await l();await SpinQuery.condition(()=>$(".bilibili-player-video,.bilibili-player-video-btn-start,.bilibili-player-area"),e=>e.length===3&&$("video").length>0&&$("video").prop("duration"));const i=document.querySelector("video");if(!i){return}const a=n.find(i=>i.name===e.defaultPlayerMode);{const n=()=>{if(a&&$("#bilibiliPlayer[class*=mode-]").length===0){a.action()}};if(e.applyPlayerModeOnPlay&&!e.autoPlay){i.addEventListener("play",n,{once:true})}else{n()}if(!e.autoPlay){i.addEventListener("play",t,{once:true})}else{t()}i.addEventListener("ended",o,{once:true})}}Observer.videoChange(a)}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/default-video-quality.min.js"] = (()=>{return(e,a)=>{const t=[{name:"1080P60",value:116},{name:"1080P+",value:112},{name:"1080P",value:80},{name:"720P60",value:74},{name:"720P",value:64},{name:"480P",value:32},{name:"360P",value:15},{name:"自动",value:0}];async function i(){const a=await SpinQuery.any(()=>$(".bilibili-player-video-quality-menu .bui-select-list>li.bui-select-item"));if(!a){return}const i=(e,a)=>a-e;const[n]=a.toArray().map(e=>parseInt(e.getAttribute("data-value"))).sort(i);const[l]=t.filter(a=>a.name===e.defaultVideoQuality).map(e=>e.value).sort(i);const[r]=t.map(e=>e.value).filter(e=>e<=Math.min(l,n)).sort(i);const u=await SpinQuery.select(()=>document.querySelector("video"));function s(){a.each((e,a)=>{if(parseInt(a.getAttribute("data-value"))===r){a.click()}});this.removeEventListener("play",s)}u.addEventListener("play",s)}if(Observer.videoChange){Observer.videoChange(i)}else{Observer.childList("#bofqi",()=>i())}}})(); 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:o}=e.import("danmaku-converter");async function a(t,e){const a=n();const r=new i((unsafeWindow||window).cid);await r.fetchInfo();const l=await(async()=>{if(e===true){let t={title:a};try{await loadLazyPanel(".bilibili-player-video-danmaku-setting");const e=t=>{const e=parseFloat(document.querySelector(t).style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const n={0:0,44:1,94:2,144:3,188:4}[e];return n};t.font=document.querySelector(".bilibili-player-video-danmaku-setting-right-font .bui-select-result").innerText;t.alpha=parseFloat(document.querySelector(".bilibili-player-setting-opacity .bui-bar").style.transform.replace(/scaleX\(([\d\.]+)\)/,"$1"));t.duration=(()=>{const t=[10,8,6,4,2][e(".bilibili-player-setting-speedplus .bui-thumb")];return e=>{switch(e.type){case 4:case 5:return 4;default:return t}}})();t.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(document.querySelector(n).classList.contains("disabled")){t=t.concat(i)}}return t.concat(7,8)})();const n=[1.4,1.2,1,.8,.6][e(".bilibili-player-setting-fontsize .bui-thumb")];t.resolution={x:1920*n,y:1080*n};t.bottomMarginPercent=[.75,.5,.25,0,0][e(".bilibili-player-setting-area .bui-thumb")];if(t.bottomMarginPercent===0&&document.querySelector(".bilibili-player-video-danmaku-setting-left-preventshade input").checked){t.bottomMarginPercent=.15}t.bold=document.querySelector(".bilibili-player-video-danmaku-setting-right-font-bold input").checked}catch(e){t={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 e=new o(t);const n=e.convertToAssDocument(r.rawXML);return new Blob([n.generateAss()],{type:"text/plain"})}else{return new Blob([r.rawXML],{type:"text/plain"})}})();const c=URL.createObjectURL(l);const s=$("#danmaku-link");const u=s.attr("href");if(u){URL.revokeObjectURL(u)}clearTimeout(t);document.querySelector("#download-danmaku>span").innerHTML="下载弹幕";s.attr("download",`${a}.${e?"ass":"xml"}`).attr("href",c).get(0).click()}return{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");$("#download-danmaku").on("click",e=>{if(e.target!==t){const t=setTimeout(()=>document.querySelector("#download-danmaku>span").innerHTML="请稍侯...",200);a(t,e.shiftKey)}})}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.css"] = `.download-video-panel.opened{transform:scaleY(1) translateX(-50%)}.download-video-panel{position:absolute;top:calc(100% + 2px);transition:.16s ease-out;transform-origin:top;transform:scaleY(0) translateX(-50%);background:#fff;box-shadow:0 3px 20px 2px #0004;z-index:100;left:50%}.video-action>div,ol.video-quality li{cursor:pointer;align-items:center;margin:0;padding:8px 16px;transition:.2s ease-out;text-align:center;white-space:nowrap}.video-action>div{padding:12px 24px}.video-action>div:hover,ol.video-quality li:hover{background:rgba(0,0,0,.16)}.video-action,.video-error,.video-progress,.video-quality{display:none}.download-video-panel.action:not(.error) .video-action,.download-video-panel.error .video-error,.download-video-panel.progress:not(.error) .video-progress,.download-video-panel.quality:not(.error) .video-quality{display:block}.download-progress-text{display:flex}.download-progress-background{background-color:#8884;height:4px;width:100%;margin-top:4px}.download-progress-foreground{background-color:var(--theme-color);transform-origin:left;transition:.2s ease-out;transform:scaleX(0);height:100%;width:100%}.download-progress-cancel{margin-top:8px;display:flex;justify-content:center}.download-progress-cancel>span{background-color:#8884;padding:4px 8px;cursor:pointer}.download-progress-cancel>span:hover{opacity:.9}.download-progress-cancel>span:active{opacity:.8}.video-error,.video-progress{padding:12px}.video-progress{min-width:120px}#video-action-batch-data,#video-action-batch-download-data,#video-complete{display:none}.batch #video-action-batch-data,.batch #video-action-batch-download-data{display:block}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.html"] = `
        下载视频
        `; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.js"] = (()=>{return(e,t)=>{const{getFriendlyTitle:s}=t.import("title");const n={entity:null,aid:undefined,cid:undefined};let o=null;class r{constructor(){this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}get menuPanel(){return document.querySelector(".download-video-panel")}addMenuClass(){this.menuPanel.classList.remove(...this.menuClasses);this.menuPanel.classList.add(this.currentMenuClass);return this.currentMenuClass}resetMenuClass(){[this.currentMenuClass]=this.menuClasses;this.addMenuClass()}nextMenuClass(){const e=this.menuClasses.indexOf(this.currentMenuClass)+1;const t=this.menuClasses[e>=this.menuClasses.length?0:e];this.currentMenuClass=t;this.addMenuClass();return t}addError(){this.menuPanel.classList.add("error")}removeError(){this.menuPanel.classList.remove("error");this.resetMenuClass()}async getUrl(e){if(e){return`https://api.bilibili.com/x/player/playurl?avid=${n.aid}&cid=${n.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${n.aid}&cid=${n.cid}&otype=json`}}}class a extends r{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${n.aid}&cid=${n.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${n.aid}&cid=${n.cid}&qn=&otype=json`}}}class i{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new c(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{n.entity.getUrl().then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText);if(s.code!==0){t("获取清晰度信息失败.")}const o=s.data||s.result||s;const r=o.accept_quality;const a=o.accept_format.split(",");const l=o.accept_description;const c=[];while(r.length>0){const e=new i(r.pop(),a.pop(),l.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class l{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class c{constructor(e,t){this.format=e;this.fragments=t||[];this.progress=null;this.totalSize=null;this.workingXhr=null;this.fragmentSplitFactor=6*5}fetchVideoInfo(){return new Promise((e,t)=>{n.entity.getUrl(this.format.quality).then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText.replace(/http:/g,"https:"));const o=s.data||s.result||s;if(o.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const r=o.durl;this.fragments=r.map(e=>new l(e.length,e.size,e.url,e.backup_url));e(this.fragments)});n.withCredentials=true;n.open("GET",s);n.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(){if("forEach"in this.workingXhr){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const s=Math.round(e.size/this.fragmentSplitFactor);let n=0;const o=e=>[...this.progressMap.keys()].indexOf(e)+1;while(n{const n=new XMLHttpRequest;n.open("GET",e.url);n.responseType="arraybuffer";n.withCredentials=false;n.addEventListener("progress",e=>{console.log(`[下载视频] 视频片段${o(n)}下载进度: ${e.loaded}/${i} bytes loaded, ${a}`);this.progressMap.set(n,e.loaded);this.updateProgress()});n.addEventListener("load",()=>{if((""+n.status)[0]==="2"){t(n.response)}else{s(`请求失败.`)}});n.addEventListener("abort",()=>s("下载已取消."));n.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${o(n)}下载失败: ${a}`);this.progressMap.set(n,0);this.updateProgress();n.open("GET",e.url);n.setRequestHeader("Range",a);n.send()});n.setRequestHeader("Range",a);this.progressMap.set(n,0);n.send();this.workingXhr.push(n)}));n=Math.round(n+s)+1}return Promise.all(t)}copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}exportData(e=false){const t=JSON.stringify({fragments:this.fragments,title:s(true),totalSize:this.fragments.map(e=>e.size).reduce((e,t)=>e+t)});if(e){GM_setClipboard(t,"text")}else{const e=document.createElement("a");const s=new Blob([t],{type:"text/json"});const n=URL.createObjectURL(s);e.setAttribute("href",n);e.setAttribute("download",`cid${unsafeWindow.cid}.json`);document.body.appendChild(e);e.click();e.remove();URL.revokeObjectURL(n)}}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t=null){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=document.querySelector("a#video-complete").getAttribute("href");if(e&&!document.querySelector(`.link[href="${e}"]`)){URL.revokeObjectURL(e)}[...document.querySelectorAll(".toast-card-header")].filter(e=>e.innerText.includes("下载视频")).forEach(e=>e.querySelector(".toast-card-dismiss").click())}downloadSingle(e){const[t]=e;const n=this.makeBlob(t);const o=s()+this.extension();return[n,o]}async downloadMultiple(e){const t=new JSZip;const n=s();if(e.length>1){e.forEach((e,s)=>{const o=this.fragments[s];t.file(`${n} - ${s+1}${this.extension(o)}`,this.makeBlob(e,o))})}else{const[s]=e;t.file(`${n}${this.extension()}`,this.makeBlob(s))}const o=await t.generateAsync({type:"blob"});const r=n+".zip";return[o,r]}async download(){const e=[];this.totalSize=this.fragments.map(e=>e.size).reduce((e,t)=>e+t);for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let t=null;let s=null;if(e.length===1){[t,s]=this.downloadSingle(e)}else{[t,s]=await this.downloadMultiple(e)}this.cleanUpOldBlobUrl();const n=URL.createObjectURL(t);this.progress&&this.progress(0);return{url:n,filename:s}}}async function d(){const e=["/www.bilibili.com/bangumi"];if(e.some(e=>document.URL.includes(e))){const{BatchExtractor:e}=await t.importAsync("batchDownload");const s=new e;document.getElementById("download-video").classList.add("batch");document.getElementById("video-action-batch-data").addEventListener("click",async()=>{if(!o){return}n.entity.resetMenuClass();const e=Toast.info("获取链接中...","批量下载");const t=await s.collectData(o,e);if(!t){return}GM_setClipboard(t,{type:"text/json"});Toast.success("已复制批量数据到剪贴板.","复制批量数据",3e3)});document.getElementById("video-action-batch-download-data").addEventListener("click",async()=>{if(!o){return}n.entity.resetMenuClass();const e=Toast.info("获取链接中...","批量下载");const t=await s.collectData(o,e);if(!t){return}const r=document.createElement("a");const a=new Blob([t],{type:"text/json"});const i=URL.createObjectURL(a);r.setAttribute("href",i);r.setAttribute("download",`export.json`);document.body.appendChild(r);r.click();r.remove();URL.revokeObjectURL(i)})}}async function u(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);n.aid=e;n.cid=t;if(document.URL.indexOf("bangumi")!==-1){n.entity=new a}else{n.entity=new r}return Boolean(e&&t)}async function p(){let e=await i.availableFormats;o=e[0];const s=async()=>{await u();e=await i.availableFormats;const t=$("ol.video-quality");t.html("");e.forEach(e=>{$(`
      • ${e.displayName}
      • `).on("click",()=>{o=e;n.entity.nextMenuClass()}).prependTo(t)})};if(Observer.videoChange){Observer.videoChange(s)}else{Observer.childList("#bofqi",s)}const r=()=>o.downloadInfo().catch(e=>{n.entity.addError();$(".video-error").text(e)});async function a(){if(!o){return}n.entity.nextMenuClass();const e=await r();e.progress=(e=>{$(".download-progress-value").text(`${fixed(e*100)}`);$(".download-progress-foreground").css("transform",`scaleX(${e})`)});document.querySelector(".download-progress-cancel>span").onclick=(()=>e.cancelDownload());const t=await e.download().catch(e=>{n.entity.addError();$(".video-error").text(e)});if(!t){return}const s=document.getElementById("video-complete");s.setAttribute("href",t.url);s.setAttribute("download",t.filename);s.click();const a=`下载完成. 再次保存`;Toast.success(a,"下载视频");n.entity.resetMenuClass()}async function l(){if(!o){return}const e=await r();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);n.entity.resetMenuClass()}document.querySelector("#video-action-download").addEventListener("click",a);document.querySelector("#video-action-copy").addEventListener("click",l);document.querySelector("#video-action-copy-data").addEventListener("click",async()=>{if(!o){return}const e=await r();e.exportData(true);Toast.success("已复制数据到剪贴板.","复制数据",3e3);n.entity.resetMenuClass()});document.querySelector("#video-action-download-data").addEventListener("click",async()=>{if(!o){return}const e=await r();e.exportData(false);n.entity.resetMenuClass()});t.applyStyle("downloadVideoStyle");const c=document.querySelector(".download-video-panel");const p=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!c.contains(e.target)){p()}});$(".video-error").on("click",()=>{$(".video-error").text("");n.entity.removeError()});await SpinQuery.select(()=>document.querySelector(".download-video-panel"));n.entity.addMenuClass();d()}return{widget:{content:(t.data.downloadVideoDom||t.data.downloadVideoHtml).text,condition:u,success:p}}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.js"] = (()=>{return(e,t)=>{const{getFriendlyTitle:s}=t.import("title");const n={entity:null,aid:undefined,cid:undefined};let o=null;class r{constructor(){this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}get menuPanel(){return document.querySelector(".download-video-panel")}addMenuClass(){this.menuPanel.classList.remove(...this.menuClasses);this.menuPanel.classList.add(this.currentMenuClass);return this.currentMenuClass}resetMenuClass(){[this.currentMenuClass]=this.menuClasses;this.addMenuClass()}nextMenuClass(){const e=this.menuClasses.indexOf(this.currentMenuClass)+1;const t=this.menuClasses[e>=this.menuClasses.length?0:e];this.currentMenuClass=t;this.addMenuClass();return t}addError(){this.menuPanel.classList.add("error")}removeError(){this.menuPanel.classList.remove("error");this.resetMenuClass()}async getUrl(e){if(e){return`https://api.bilibili.com/x/player/playurl?avid=${n.aid}&cid=${n.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${n.aid}&cid=${n.cid}&otype=json`}}}class a extends r{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${n.aid}&cid=${n.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${n.aid}&cid=${n.cid}&qn=&otype=json`}}}class i{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new c(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{n.entity.getUrl().then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText);if(s.code!==0){t("获取清晰度信息失败.")}const o=s.data||s.result||s;const r=o.accept_quality;const a=o.accept_format.split(",");const l=o.accept_description;const c=[];while(r.length>0){const e=new i(r.pop(),a.pop(),l.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class l{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class c{constructor(e,t){this.format=e;this.fragments=t||[];this.progress=null;this.totalSize=null;this.workingXhr=null;this.fragmentSplitFactor=6*5}fetchVideoInfo(){return new Promise((e,t)=>{n.entity.getUrl(this.format.quality).then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText.replace(/http:/g,"https:"));const o=s.data||s.result||s;if(o.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const r=o.durl;this.fragments=r.map(e=>new l(e.length,e.size,e.url,e.backup_url));e(this.fragments)});n.withCredentials=true;n.open("GET",s);n.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(){if("forEach"in this.workingXhr){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const s=Math.round(e.size/this.fragmentSplitFactor);let n=0;const o=e=>[...this.progressMap.keys()].indexOf(e)+1;while(n{const n=new XMLHttpRequest;n.open("GET",e.url);n.responseType="arraybuffer";n.withCredentials=false;n.addEventListener("progress",e=>{console.log(`[下载视频] 视频片段${o(n)}下载进度: ${e.loaded}/${i} bytes loaded, ${a}`);this.progressMap.set(n,e.loaded);this.updateProgress()});n.addEventListener("load",()=>{if((""+n.status)[0]==="2"){t(n.response)}else{s(`请求失败.`)}});n.addEventListener("abort",()=>s("下载已取消."));n.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${o(n)}下载失败: ${a}`);this.progressMap.set(n,0);this.updateProgress();n.open("GET",e.url);n.setRequestHeader("Range",a);n.send()});n.setRequestHeader("Range",a);this.progressMap.set(n,0);n.send();this.workingXhr.push(n)}));n=Math.round(n+s)+1}return Promise.all(t)}copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}exportData(e=false){const t=JSON.stringify({fragments:this.fragments,title:s(true),totalSize:this.fragments.map(e=>e.size).reduce((e,t)=>e+t)});if(e){GM_setClipboard(t,"text")}else{const e=document.createElement("a");const s=new Blob([t],{type:"text/json"});const n=URL.createObjectURL(s);e.setAttribute("href",n);e.setAttribute("download",`cid${unsafeWindow.cid}.json`);document.body.appendChild(e);e.click();e.remove();URL.revokeObjectURL(n)}}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t=null){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=document.querySelector("a#video-complete").getAttribute("href");if(e&&!document.querySelector(`.link[href="${e}"]`)){URL.revokeObjectURL(e)}[...document.querySelectorAll(".toast-card-header")].filter(e=>e.innerText.includes("下载视频")).forEach(e=>e.querySelector(".toast-card-dismiss").click())}downloadSingle(e){const[t]=e;const n=this.makeBlob(t);const o=s()+this.extension();return[n,o]}async downloadMultiple(e){const t=new JSZip;const n=s();if(e.length>1){e.forEach((e,s)=>{const o=this.fragments[s];t.file(`${n} - ${s+1}${this.extension(o)}`,this.makeBlob(e,o))})}else{const[s]=e;t.file(`${n}${this.extension()}`,this.makeBlob(s))}const o=await t.generateAsync({type:"blob"});const r=n+".zip";return[o,r]}async download(){const e=[];this.totalSize=this.fragments.map(e=>e.size).reduce((e,t)=>e+t);for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let t=null;let s=null;if(e.length===1){[t,s]=this.downloadSingle(e)}else{[t,s]=await this.downloadMultiple(e)}this.cleanUpOldBlobUrl();const n=URL.createObjectURL(t);this.progress&&this.progress(0);return{url:n,filename:s}}}async function d(){const e=["/www.bilibili.com/bangumi"];if(e.some(e=>document.URL.includes(e))){const{BatchExtractor:e}=await t.importAsync("batchDownload");const s=new e;document.getElementById("download-video").classList.add("batch");document.getElementById("video-action-batch-data").addEventListener("click",async()=>{if(!o){return}n.entity.resetMenuClass();const e=Toast.info("获取链接中...","批量下载");const t=await s.collectData(o,e);if(!t){return}GM_setClipboard(t,{type:"text/json"});Toast.success("已复制批量数据到剪贴板.","复制批量数据",3e3)});document.getElementById("video-action-batch-download-data").addEventListener("click",async()=>{if(!o){return}n.entity.resetMenuClass();const e=Toast.info("获取链接中...","批量下载");const t=await s.collectData(o,e);if(!t){return}const r=document.createElement("a");const a=new Blob([t],{type:"text/json"});const i=URL.createObjectURL(a);r.setAttribute("href",i);r.setAttribute("download",`export.json`);document.body.appendChild(r);r.click();r.remove();URL.revokeObjectURL(i)})}}async function u(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);n.aid=e;n.cid=t;if(document.URL.indexOf("bangumi")!==-1){n.entity=new a}else{n.entity=new r}return Boolean(e&&t)}async function p(){let e=await i.availableFormats;o=e[0];const s=async()=>{await u();e=await i.availableFormats;const t=$("ol.video-quality");t.html("");e.forEach(e=>{$(`
      • ${e.displayName}
      • `).on("click",()=>{o=e;n.entity.nextMenuClass()}).prependTo(t)})};if(Observer.videoChange){Observer.videoChange(s)}else{Observer.childList("#bofqi",s)}const r=()=>o.downloadInfo().catch(e=>{n.entity.addError();$(".video-error").text(e)});async function a(){if(!o){return}n.entity.nextMenuClass();const e=await r();e.progress=(e=>{$(".download-progress-value").text(`${fixed(e*100)}`);$(".download-progress-foreground").css("transform",`scaleX(${e})`)});document.querySelector(".download-progress-cancel>span").onclick=(()=>e.cancelDownload());const t=await e.download().catch(e=>{n.entity.addError();$(".video-error").text(e)});if(!t){return}const s=document.getElementById("video-complete");s.setAttribute("href",t.url);s.setAttribute("download",t.filename);s.click();const a=`下载完成. 再次保存`;Toast.success(a,"下载视频");n.entity.resetMenuClass()}async function l(){if(!o){return}const e=await r();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);n.entity.resetMenuClass()}document.querySelector("#video-action-download").addEventListener("click",a);document.querySelector("#video-action-copy").addEventListener("click",l);document.querySelector("#video-action-copy-data").addEventListener("click",async()=>{if(!o){return}const e=await r();e.exportData(true);Toast.success("已复制数据到剪贴板.","复制数据",3e3);n.entity.resetMenuClass()});document.querySelector("#video-action-download-data").addEventListener("click",async()=>{if(!o){return}const e=await r();e.exportData(false);n.entity.resetMenuClass()});t.applyStyle("downloadVideoStyle");const c=document.querySelector(".download-video-panel");const p=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!c.contains(e.target)){p()}});$(".video-error").on("click",()=>{$(".video-error").text("");n.entity.removeError()});await SpinQuery.select(()=>document.querySelector(".download-video-panel"));n.entity.addMenuClass();d()}return{widget:{content:t.data.downloadVideoHtml.text,condition:u,success:p}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/expand-danmaku.min.js"] = (()=>{return(e,i)=>{if(typeof isEmbeddedPlayer!=="undefined"&&isEmbeddedPlayer()){return}const r=()=>{SpinQuery.any(()=>$(".bui-collapse-header"),e=>{if(parseInt($(".bui-collapse-body").css("height"))===0&&$(".bui-collapse-arrow-text").text()==="展开"){e.click()}})};if(Observer.videoChange){Observer.videoChange(r)}else{Observer.childList("#bofqi",r)}}})(); 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")}})(); @@ -1055,7 +1055,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/full-tweets-title.min.js"] = (()=>{return(e,l)=>{l.applyStyle("fullTweetsTitleStyle")}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/gui-settings.min.css"] = `.gui-settings-icon-panel{height:auto;display:flex;flex-direction:column;justify-content:center;align-items:center;position:fixed;top:50%;left:0;width:32px;z-index:99999;transform:translateY(-50%)}.gui-settings-icon-panel i{transition:.2s;opacity:.6;transform:rotate(180deg)}.gui-settings-widgets:hover i,.gui-settings:hover i{opacity:.75;transform:rotate(0)}.gui-settings,.gui-settings-widgets{display:flex;justify-content:center;align-items:center;cursor:pointer;-webkit-tap-highlight-color:transparent;margin:16px 0;width:24px;height:24px;transition:.2s;opacity:1;transform-origin:center!important;transform:translateX(-16px);background-color:rgba(255,255,255,.75);border-radius:0 50% 50% 0;padding:6px}body.dark .gui-settings,body.dark .gui-settings-widgets{background-color:rgba(0,0,0,.75)}.gui-settings-widgets:hover,.gui-settings:hover{opacity:1;transform:translateX(0)}.gui-settings-footer,.gui-settings-header{flex-grow:0;display:flex;align-items:center;justify-content:space-between;flex-shrink:0;z-index:10;padding:32px}.gui-settings-footer{height:80px;justify-content:center;position:relative}.gui-settings-content{flex-grow:1;overflow:auto;position:relative;overscroll-behavior:contain}.gui-settings-content ul{padding:0;margin:0}.gui-settings-content ul li{font-size:16px;margin-bottom:18px;display:flex;height:24px;transition:.2s}.gui-settings-content ul li.disabled,.gui-settings-content ul li:not(.category).folded{height:0;margin:0;overflow:hidden}.gui-settings-content ul li.indent-0{margin-left:16px}.gui-settings-content ul li.indent-1{margin-left:80px}.gui-settings-content ul li.indent-2{margin-left:144px}.gui-settings-content ul li.indent-center{align-items:center;justify-content:center}.gui-settings-content ul li.category{padding:16px 0;margin-bottom:18px;border-top:1px dashed #8884;border-bottom:1px dashed #8884;background:#fff;position:sticky;top:0;z-index:10;cursor:pointer;transition:.2s ease-out;-webkit-tap-highlight-color:transparent}.gui-settings-content ul li.category.folded{margin-bottom:-1px}.gui-settings-content ul li.category *{opacity:.8}.gui-settings-title{font-size:16pt;flex:0 0 auto}.gui-settings-box .gui-settings-title{margin-right:64px}.gui-settings-search[type=text]{flex:1 0 auto;height:auto;border:none;padding:6px;font-size:12pt;width:40%;border-bottom:1px solid #8884;transition:.2s;color:inherit;background:0 0;box-sizing:border-box;outline:0!important}.gui-settings-close{width:24px;height:24px;padding:16px}.gui-settings-header .gui-settings-close{cursor:pointer;-webkit-tap-highlight-color:transparent}.gui-settings-textbox-container{display:flex;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent}.gui-settings-dropdown-span,.gui-settings-textbox-container span{margin:0 16px;transition:.2s}.gui-settings-textbox-container input{border:none;height:100%;max-width:90px;padding:4px 8px;background:#8884;transition:.2s;font-size:16px}.gui-settings-textbox-container input:disabled,.gui-settings-textbox-container.disabled div,.gui-settings-textbox-container.disabled span{opacity:.5}.gui-settings-checkbox-container{cursor:pointer;display:flex;width:100%;justify-content:start;align-items:center;padding:0 16px;-webkit-tap-highlight-color:transparent}.gui-settings-checkbox-container input{visibility:collapse;transition:.2s;width:0}.gui-settings-checkbox-container .gui-settings-ok{width:24px;height:24px;margin-right:16px;transition:.2s}.gui-settings-checkbox-container input~.gui-settings-ok{background-color:#8884}.gui-settings-checkbox-container input:checked~.gui-settings-ok{background-color:var(--theme-color)}.gui-settings-checkbox-container input~.gui-settings-ok>i{opacity:0;transform-origin:center;transform:scale(.9)}.gui-settings-checkbox-container input:checked~.gui-settings-ok>i{opacity:1}.gui-settings-checkbox-container input:disabled~.gui-settings-ok,.gui-settings-checkbox-container input:disabled~span{opacity:.5}button.gui-settings-button{padding:6px 20px;margin:0 4px;max-height:34px;border:none;background:#8884;font-size:16px;cursor:pointer;transition:.2s ease-out;font-family:inherit;-webkit-tap-highlight-color:transparent}button.gui-settings-button:hover{opacity:.9}button.gui-settings-button:active{opacity:.8}button.gui-settings-button:focus{outline:0}.custom-color-preview{width:28px;height:28px;border-radius:50%;background:var(--theme-color);margin-right:16px;position:relative;cursor:pointer;box-sizing:border-box;box-shadow:0 2px 8px 1px var(--theme-color-70)}.predefined-colors{transition:.2s;display:flex;opacity:0;background:#fff;width:168px;height:168px;position:absolute;box-shadow:0 3px 20px 2px #0004;top:32px;left:calc(-84px + 50%);transform:scale(0);transform-origin:top;z-index:9}.predefined-colors.opened{opacity:1;transform:scale(1)}.predefined-colors-grid{display:grid;grid-template-columns:auto auto auto auto;margin:0;flex-grow:1}.predefined-colors-grid-block{width:100%;height:100%;justify-self:center;align-self:center;cursor:pointer;transform-origin:center;transition:.1s ease-out}.predefined-colors-grid-block:hover{transform:scale(1.1);box-shadow:0 0 8px 1px #0004}input[key]:focus{outline:0}input[type=text][key]{height:auto;border:none}.gui-settings-label{margin:0 16px;font-size:16px}.hidden{display:none!important}@supports (backdrop-filter:blur(24px)) or (-webkit-backdrop-filter:blur(24px)){.gui-settings-box.blur li.category{-webkit-backdrop-filter:blur(24px);backdrop-filter:blur(24px);background:0 0}.gui-settings-box.blur,.gui-settings-box.blur .gui-settings-content,.gui-settings-box.blur .gui-settings-footer,.gui-settings-box.blur .gui-settings-header{background:#fff8}.gui-settings-box.blur .gui-settings-content,.gui-settings-box.blur .gui-settings-footer,.gui-settings-box.blur .gui-settings-header{-webkit-backdrop-filter:blur(64px);backdrop-filter:blur(64px)}}li.category i.icon-arrow{transition:.2s ease-out}li.category.folded i.icon-arrow{transform:rotate(180deg)}.gui-settings-dropdown-container{display:flex;align-items:center}.gui-settings-dropdown{position:relative;cursor:pointer;-webkit-tap-highlight-color:transparent;background-color:#8884;display:inline-flex;align-items:center;height:32px}.gui-settings-dropdown>i{transition:.2s ease-out;transform-origin:center;transform:rotate(180deg)}.gui-settings-dropdown>ul{position:absolute;top:calc(100%);width:100%;cursor:pointer;background:#fff;transform-origin:top;transform:scaleY(0);transition:.2s ease-out;display:flex;flex-direction:column;align-items:center;box-shadow:0 3px 20px 2px #0004;z-index:100}.gui-settings-dropdown ul li{margin:0;padding:12px 0;height:auto;width:100%;justify-content:center}.gui-settings-dropdown ul li:hover{background:rgba(0,0,0,.16)}.gui-settings-dropdown.opened>ul{transform:scaleY(1)}.gui-settings-dropdown.opened>i{transform:rotate(0)}.gui-settings-dropdown input{cursor:pointer;border:none;height:100%;max-width:80px;padding:4px 8px;transition:.2s;font-size:16px;background-color:transparent}.gui-settings-mask{height:calc(100% + 5px);width:calc(100% + 5px);opacity:0;background:#000a;position:fixed;top:0;left:0;z-index:99999;pointer-events:none;transition:.3s cubic-bezier(0,.86,.58,1);overscroll-behavior:contain}.gui-settings-mask.opened{opacity:1;pointer-events:initial}.gui-settings-mask.opened.transparent{opacity:0;transition:.3s cubic-bezier(0,.86,.58,1) .3s}.gui-settings-box,.gui-settings-widgets-box{height:100%;width:400px;background:#fff;color:#000;position:fixed;top:0;left:0;z-index:100000;transform:translateX(-100%);transition:.3s cubic-bezier(0,.86,.58,1);display:none;flex-direction:column;box-shadow:4px 0 16px 0 #0000}.gui-settings-box.loaded,.gui-settings-widgets-box.loaded{display:flex}.gui-settings-widgets-box{min-width:200px;width:auto}.gui-settings-box.opened,.gui-settings-widgets-box.opened{transform:translateX(0);box-shadow:4px 0 16px 0 #0005}.gui-settings-widgets-box>.title{margin:32px;font-size:16pt}.gui-settings-widgets-box>.widgets-container{padding:32px;display:flex;flex-direction:column;align-items:stretch;justify-content:start;position:relative;overscroll-behavior:contain;overflow:auto;height:100%}.gui-settings-widgets-box>.widgets-container .empty-tip{font-size:10pt;display:none}.gui-settings-widgets-box>.widgets-container .empty-tip.show{display:block}.gui-settings-widgets-box>.gui-settings-header{justify-content:start}.gui-settings-flat-button,.gui-settings-flat-button a,.gui-settings-flat-button a:hover{display:flex;align-items:center;justify-content:center;color:inherit}.gui-settings-flat-button{width:auto;padding:8px 16px;background:#8884;border:none;color:#000;cursor:pointer;transition:.2s ease-out;font-size:10pt;border-bottom:2px solid var(--theme-color-50);flex:0 0 auto;margin:4px}.gui-settings-flat-button:disabled{opacity:.5;cursor:not-allowed}.gui-settings-flat-button:hover:not(:disabled){border-bottom-color:var(--theme-color-90)}.gui-settings-flat-button:active:not(:disabled){border-bottom-color:var(--theme-color)}.gui-settings-flat-button:focus{outline:0}.gui-settings-flat-button i{margin-right:8px;line-height:24px;height:24px}.gui-settings-checkbox{width:28px;margin-right:24px;height:12px;background:#8884;border-radius:16px;position:relative}.gui-settings-checkbox::after{content:"";width:20px;height:20px;background:#c6c6c6;position:absolute;border-radius:50%;top:-4px;left:-4px;box-shadow:0 2px 8px 1px #0003;transition:.2s ease-out}.gui-settings-checkbox-container input:checked~.gui-settings-checkbox{background:var(--theme-color-80)}.gui-settings-checkbox-container input:checked~.gui-settings-checkbox::after{background:var(--theme-color)!important;box-shadow:0 2px 8px 1px var(--theme-color-70);left:calc(100% - 16px)}.gui-settings-checkbox-container input:disabled~.gui-settings-checkbox{opacity:.5}.gui-settings-header>i{margin-right:8px}.player-full-win .app-content,.player-full-win .live-room-app .app-content,.player-mode-webfullscreen .player-module{z-index:100000!important}.gui-settings-flat-button .popup{position:absolute;top:calc(100% + 2px);transition:.16s ease-out;transform-origin:top;transform:scaleY(0) translateX(-50%);left:50%;background:#fff;box-shadow:0 3px 20px 2px #0004;z-index:200;display:flex;flex-direction:column;align-items:center;width:max-content}.gui-settings-flat-button .popup *{transition:.2s}.gui-settings-flat-button .popup.opened{transform:scaleY(1) translateX(-50%)}.gui-settings-flat-button .popup ul{list-style:none;margin:0;padding:0}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/gui-settings.min.html"] = `
        附加功能
        空空如也哦 = ̄ω ̄=
        设置
        • 视频
        • 样式
        • 工具
        • 触摸
        • 其他
        `; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/gui-settings.min.js"] = (()=>{return(e,t)=>{const{ThemeColors:n}=t.import("theme-colors");const{SettingsSearch:i}=t.import("settings-search");const{Validator:s}=t.import("text-validate");let o=[];let r=[];let c=[];function a(e){let t=e.nextElementSibling;const n=[];while(t!==null&&!t.classList.contains("category")){n.push(t);t=t.nextElementSibling}return n}function l(){c.forEach(t=>t.value=e[t.getAttribute("key")]);r.forEach(t=>t.checked=e[t.getAttribute("key")])}function u(){document.querySelector(".gui-settings-mask").addEventListener("click",()=>{document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask,.bilibili-evolved-about").forEach(e=>e.classList.remove("opened"))});c.forEach(t=>{t.setAttribute("placeholder",e[t.getAttribute("key")])});document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.addEventListener("click",e=>{const t=document.querySelector(".gui-settings-search");if(t.value!==""){t.value="";raiseEvent(t,"input")}e.currentTarget.classList.toggle("folded");a(e.currentTarget).forEach(e=>e.classList.toggle("folded"))})});document.querySelectorAll(".gui-settings-dropdown>input").forEach(e=>{e.addEventListener("click",e=>{e.currentTarget.parentElement.classList.toggle("opened")})})}function d(){const t=e=>{};r.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const s=n.checked;e[i]=s;t(i);saveSettings(e)})});c.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const o=s.getValidator(i).validate(n.value);e[i]=o;n.value=o;t(i);saveSettings(e)})})}function g(){const e=o.map(e=>[e.getAttribute("dependencies").split(" ").map(e=>o.find(t=>t.getAttribute("key")===e)),e]);const t=e=>e.nodeName.toUpperCase()==="LI"?e:t(e.parentElement);e.forEach(([e,n])=>{if(e[0]===undefined){return}const i=()=>{if(e.every(e=>e.checked)){t(n).classList.remove("disabled")}else{t(n).classList.add("disabled")}};e.forEach(e=>e.addEventListener("change",i));i()})}function f(){if(typeof offlineData!=="undefined"){document.querySelector(".gui-settings-checkbox-container>input[key=useCache]").parentElement.parentElement.classList.add("disabled");document.querySelector("input[key=useCache]").disabled=true}}function b(){document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.click()})}function m(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){o.find(e=>e.getAttribute("key")==="blurVideoControl").disabled=true;e.blurVideoControl=false;saveSettings(e)}if(window.devicePixelRatio===1){o.find(e=>e.getAttribute("key")==="harunaScale").disabled=true;o.find(e=>e.getAttribute("key")==="imageResolution").disabled=true;e.harunaScale=false;e.imageResolution=false;saveSettings(e)}if(e.defaultPlayerLayout==="旧版"){const t=o.find(e=>e.getAttribute("key")==="overrideNavBar");t.disabled=true;raiseEvent(t,"change");if(e.overrideNavBar){t.checked=false;raiseEvent(t,"change");e.overrideNavBar=false;saveSettings(e)}}}function y(){for(const[e,t]of Object.entries(Resource.displayNames)){const n=o.find(t=>t.getAttribute("key")===e);if(!n){continue}switch(n.type){case"checkbox":n.nextElementSibling.nextElementSibling.innerHTML=t;break;case"text":const e=n.parentElement;if(e.classList.contains("gui-settings-textbox-container")){n.previousElementSibling.innerHTML=t}else if(e.classList.contains("gui-settings-dropdown")){e.previousElementSibling.innerHTML=t}break;default:break}}}(async()=>{t.applyStyle("guiSettingsStyle");document.body.insertAdjacentHTML("afterbegin",``);const e=document.body&&unsafeWindow.parent.window!==unsafeWindow;if(e){document.querySelector(".gui-settings-icon-panel").style.display="none"}const s=(t.data.guiSettingsDom||t.data.guiSettingsHtml).text;document.body.insertAdjacentHTML("beforeend",s);const a=document.querySelector(".widgets-container");const p=a.querySelector(".empty-tip");Observer.childList(a,()=>{if(a.childElementCount<=1){p.classList.add("show")}else{p.classList.remove("show")}});o=[...document.querySelectorAll("input[key]")];r=o.filter(e=>e.type==="checkbox");c=o.filter(e=>e.type==="text");u();f();l();g();d();b();m();y();(new n).setupDom();new i;const h=document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box");document.querySelector(".gui-settings-icon-panel").addEventListener("mouseover",()=>{h.forEach(e=>e.classList.add("loaded"))},{once:true})})()}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/gui-settings.min.js"] = (()=>{return(e,t)=>{const{ThemeColors:n}=t.import("theme-colors");const{SettingsSearch:i}=t.import("settings-search");const{Validator:s}=t.import("text-validate");let o=[];let r=[];let c=[];function a(e){let t=e.nextElementSibling;const n=[];while(t!==null&&!t.classList.contains("category")){n.push(t);t=t.nextElementSibling}return n}function l(){c.forEach(t=>t.value=e[t.getAttribute("key")]);r.forEach(t=>t.checked=e[t.getAttribute("key")])}function u(){document.querySelector(".gui-settings-mask").addEventListener("click",()=>{document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask,.bilibili-evolved-about").forEach(e=>e.classList.remove("opened"))});c.forEach(t=>{t.setAttribute("placeholder",e[t.getAttribute("key")])});document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.addEventListener("click",e=>{const t=document.querySelector(".gui-settings-search");if(t.value!==""){t.value="";raiseEvent(t,"input")}e.currentTarget.classList.toggle("folded");a(e.currentTarget).forEach(e=>e.classList.toggle("folded"))})});document.querySelectorAll(".gui-settings-dropdown>input").forEach(e=>{e.addEventListener("click",e=>{e.currentTarget.parentElement.classList.toggle("opened")})})}function d(){const t=e=>{};r.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const s=n.checked;e[i]=s;t(i);saveSettings(e)})});c.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const o=s.getValidator(i).validate(n.value);e[i]=o;n.value=o;t(i);saveSettings(e)})})}function g(){const e=o.map(e=>[e.getAttribute("dependencies").split(" ").map(e=>o.find(t=>t.getAttribute("key")===e)),e]);const t=e=>e.nodeName.toUpperCase()==="LI"?e:t(e.parentElement);e.forEach(([e,n])=>{if(e[0]===undefined){return}const i=()=>{if(e.every(e=>e.checked)){t(n).classList.remove("disabled")}else{t(n).classList.add("disabled")}};e.forEach(e=>e.addEventListener("change",i));i()})}function f(){if(typeof offlineData!=="undefined"){document.querySelector(".gui-settings-checkbox-container>input[key=useCache]").parentElement.parentElement.classList.add("disabled");document.querySelector("input[key=useCache]").disabled=true}}function b(){document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.click()})}function m(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){o.find(e=>e.getAttribute("key")==="blurVideoControl").disabled=true;e.blurVideoControl=false;saveSettings(e)}if(window.devicePixelRatio===1){o.find(e=>e.getAttribute("key")==="harunaScale").disabled=true;o.find(e=>e.getAttribute("key")==="imageResolution").disabled=true;e.harunaScale=false;e.imageResolution=false;saveSettings(e)}if(e.defaultPlayerLayout==="旧版"){const t=o.find(e=>e.getAttribute("key")==="overrideNavBar");t.disabled=true;raiseEvent(t,"change");if(e.overrideNavBar){t.checked=false;raiseEvent(t,"change");e.overrideNavBar=false;saveSettings(e)}}}function y(){for(const[e,t]of Object.entries(Resource.displayNames)){const n=o.find(t=>t.getAttribute("key")===e);if(!n){continue}switch(n.type){case"checkbox":n.nextElementSibling.nextElementSibling.innerHTML=t;break;case"text":const e=n.parentElement;if(e.classList.contains("gui-settings-textbox-container")){n.previousElementSibling.innerHTML=t}else if(e.classList.contains("gui-settings-dropdown")){e.previousElementSibling.innerHTML=t}break;default:break}}}(async()=>{t.applyStyle("guiSettingsStyle");document.body.insertAdjacentHTML("afterbegin",``);const e=document.body&&unsafeWindow.parent.window!==unsafeWindow;if(e){document.querySelector(".gui-settings-icon-panel").style.display="none"}const s=t.data.guiSettingsHtml.text;document.body.insertAdjacentHTML("beforeend",s);const a=document.querySelector(".widgets-container");const p=a.querySelector(".empty-tip");Observer.childList(a,()=>{if(a.childElementCount<=1){p.classList.add("show")}else{p.classList.remove("show")}});(new n).setupDom();const h=document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box");document.querySelector(".gui-settings-icon-panel").addEventListener("mouseover",()=>{h.forEach(e=>e.classList.add("loaded"));o=[...document.querySelectorAll("input[key]")];r=o.filter(e=>e.type==="checkbox");c=o.filter(e=>e.type==="text");u();f();l();g();d();b();m();y();new i},{once:true})})()}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/haruna-scale.min.js"] = (()=>{return(n,t)=>{const a="bilibili-haruna-scale";if($(a).length===0){t.applyStyleFromText(`\n \n `)}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/hide-banner.min.css"] = `#banner_link,.custom-navbar .blur-layer,.z-top-container.has-banner>.header{display:none!important}.b-header-mask-wrp .b-header-mask-bg,div.blur-bg{opacity:0!important}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/hide-banner.min.js"] = (()=>{return(e,l)=>{const r="hideBannerStyle";l.applyStyle(r);return{reload:()=>l.applyStyle(r),unload:()=>l.removeStyle(r)}}})(); @@ -1073,7 +1073,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/image-viewer.min.html"] = `
        `; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/medal-helper.min.css"] = `.medal-popup{position:absolute;top:calc(100% + 2px);transition:.16s ease-out;transform-origin:top;transform:scaleY(0) translateX(-50%);left:50%;background:#fff;box-shadow:0 3px 20px 2px #0004;z-index:100}.medal-popup.opened{transform:scaleY(1) translateX(-50%)}.medal-popup *{transition:.2s}.medal-popup ul{list-style:none;margin:0;padding:0}.medal-popup ul>li.active{box-shadow:0 0 4px 0 var(--theme-color)}.medal-popup ul>li:hover{background-color:rgba(0,0,0,.16)}.medal-popup label{display:flex;align-items:center;justify-content:center;cursor:pointer;padding:8px}.medal-popup label>*{flex-shrink:0}.medal-popup input[type=radio]{visibility:collapse;width:0;margin:0;padding:0}.medal-popup input[type=radio]~i{opacity:0;transform:scale(.8);margin:0}.medal-popup input[type=radio]~.fans-medal-item{margin:0 8px}.medal-popup input[type=radio]:checked~i{opacity:1}.title-image{display:inline-block;vertical-align:middle;height:20px}.fans-medal-item .label{width:40px;text-align:center;padding:0 2px;color:#fff}.fans-medal-item .level{width:16px;background-color:#fff;text-align:center;color:#61decb}.fans-medal-item .label,.fans-medal-item .level{position:relative;display:block;float:left}.fans-medal-item{display:inline-block;height:14px;line-height:14px;color:#fff;border:1px solid #61decb;border-left:0;white-space:nowrap;border-radius:2px;flex-shrink:0;font-size:12px}.level-1,.level-2,.level-3,.level-4{border-color:#61decb}.level-1 .label,.level-2 .label,.level-3 .label,.level-4 .label{background-color:#61decb}.level-1 .level,.level-2 .level,.level-3 .level,.level-4 .level{color:#61decb}.level-5,.level-6,.level-7,.level-8{border-color:#5896de}.level-5 .label,.level-6 .label,.level-7 .label,.level-8 .label{background-color:#5896de}.level-5 .level,.level-6 .level,.level-7 .level,.level-8 .level{color:#5896de}.level-10,.level-11,.level-12,.level-9{border-color:#a068f1}.level-10 .label,.level-11 .label,.level-12 .label,.level-9 .label{background-color:#a068f1}.level-10 .level,.level-11 .level,.level-12 .level,.level-9 .level{color:#a068f1}.level-13,.level-14,.level-15,.level-16{border-color:#ff86b2}.level-13 .label,.level-14 .label,.level-15 .label,.level-16 .label{background-color:#ff86b2}.level-13 .level,.level-14 .level,.level-15 .level,.level-16 .level{color:#ff86b2}.level-17,.level-18,.level-19,.level-20{border-color:#f6be18}.level-17 .label,.level-18 .label,.level-19 .label,.level-20 .label{background-color:#f6be18}.level-17 .level,.level-18 .level,.level-19 .level,.level-20 .level{color:#f6be18}`; offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/medal-helper.min.html"] = `
        更换勋章
          更换头衔
            `; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/medal-helper.min.js"] = (()=>{return(e,t)=>{class i{constructor(e,t){this.isActive=e;this.id=t}static parseJson(e,{successAction:t,errorMessage:i,errorAction:a}){const s=JSON.parse(e);if(s.code!==0){logError(`${i} 错误码:${s.code} ${s.message||""}`);return a(s)}return t(s)}}class a extends i{constructor({medal_id:e,status:t,level:i,medalName:a,uname:s}){super(t===1,e);this.level=i;this.name=a;this.upName=s}static async getList(){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/i/api/medal?page=1&pageSize=256"),{successAction:e=>e.data.fansMedalList.map(e=>new a(e)),errorAction:()=>[],errorMessage:"无法获取勋章列表."})}static getContainer(){return document.querySelector("#medal-helper .medal-popup ul")}static getItemTemplate(e){return`
          • \n \n
          • `}async activate(){return i.parseJson(await Ajax.getTextWithCredentials(`https://api.live.bilibili.com/i/ajaxWearFansMedal?medal_id=${this.id}`),{successAction:()=>{this.isActive=true;return true},errorAction:()=>false,errorMessage:"佩戴勋章失败."})}async deactivate(){return i.parseJson(await Ajax.getTextWithCredentials(`https://api.live.bilibili.com/i/ajaxCancelWear`),{successAction:()=>{this.isActive=false;return true},errorAction:()=>false,errorMessage:"卸下勋章失败."})}}class s extends i{constructor({id:e,cid:t,wear:i,css:a,name:r,source:c}){super(i,a);this.tid=e;this.cid=t;this.name=r;this.source=c;s.getImageMap().then(e=>{this.imageUrl=e[this.id]})}static async getImageMap(){if(s.imageMap===undefined){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/rc/v1/Title/webTitles"),{successAction(e){s.imageMap={};e.data.forEach(e=>{s.imageMap[e.identification]=e.web_pic_url});return s.imageMap},errorAction:()=>{return{}},errorMessage:"获取头衔图片失败."})}else{return s.imageMap}}static async getList(){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/i/api/ajaxTitleInfo?page=1&pageSize=256&had=1"),{successAction:e=>e.data.list.map(e=>new s(e)),errorAction:()=>[],errorMessage:"无法获取头衔列表."})}static getContainer(){return document.querySelector("#title-helper .medal-popup ul")}static getItemTemplate(e){return`
          • \n \n
          • `}async activate(){return i.parseJson(await Ajax.postTextWithCredentials(`https://api.live.bilibili.com/i/ajaxWearTitle`,`id=${this.tid}&cid=${this.cid}`),{successAction:()=>{this.isActive=true;return true},errorAction:()=>false,errorMessage:"佩戴头衔失败."})}async deactivate(){return i.parseJson(await Ajax.postTextWithCredentials(`https://api.live.bilibili.com/i/ajaxCancelWearTitle`,""),{successAction:()=>{this.isActive=false;return true},errorAction:()=>false,errorMessage:"卸下头衔失败."})}}async function r(e){const t=e.getContainer();const i=await e.getList();const a=async()=>{const i=await e.getList();i.forEach(e=>{const i=t.querySelector(`li[data-id='${e.id}']`);if(e.isActive){i.classList.add("active")}else{i.classList.remove("active")}i.querySelector(`input`).checked=e.isActive})};i.forEach(s=>{const r=e.getItemTemplate(s);t.insertAdjacentHTML("beforeend",r);const c=t.querySelector(`li[data-id='${s.id}']`);const n=c.querySelector(`input`);c.addEventListener("click",e=>{if(e.target===n){return}if(s.isActive){s.deactivate().then(a)}else{const e=i.find(e=>e.isActive);if(e){e.isActive=false}s.activate().then(a)}})})}return{export:{Badge:i,Medal:a,Title:s},widget:{condition:()=>document.domain==="live.bilibili.com",content:(t.data.medalHelperDom||t.data.medalHelperHtml).text,success:()=>{document.querySelectorAll(".medal-helper").forEach(e=>{const t=e.querySelector(".medal-popup");e.addEventListener("click",e=>{if(!t.contains(e.target)){t.classList.toggle("opened")}})});r(a);s.getImageMap().then(()=>r(s))}}}}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/medal-helper.min.js"] = (()=>{return(e,t)=>{class i{constructor(e,t){this.isActive=e;this.id=t}static parseJson(e,{successAction:t,errorMessage:i,errorAction:a}){const s=JSON.parse(e);if(s.code!==0){logError(`${i} 错误码:${s.code} ${s.message||""}`);return a(s)}return t(s)}}class a extends i{constructor({medal_id:e,status:t,level:i,medalName:a,uname:s}){super(t===1,e);this.level=i;this.name=a;this.upName=s}static async getList(){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/i/api/medal?page=1&pageSize=256"),{successAction:e=>e.data.fansMedalList.map(e=>new a(e)),errorAction:()=>[],errorMessage:"无法获取勋章列表."})}static getContainer(){return document.querySelector("#medal-helper .medal-popup ul")}static getItemTemplate(e){return`
          • \n \n
          • `}async activate(){return i.parseJson(await Ajax.getTextWithCredentials(`https://api.live.bilibili.com/i/ajaxWearFansMedal?medal_id=${this.id}`),{successAction:()=>{this.isActive=true;return true},errorAction:()=>false,errorMessage:"佩戴勋章失败."})}async deactivate(){return i.parseJson(await Ajax.getTextWithCredentials(`https://api.live.bilibili.com/i/ajaxCancelWear`),{successAction:()=>{this.isActive=false;return true},errorAction:()=>false,errorMessage:"卸下勋章失败."})}}class s extends i{constructor({id:e,cid:t,wear:i,css:a,name:r,source:c}){super(i,a);this.tid=e;this.cid=t;this.name=r;this.source=c;s.getImageMap().then(e=>{this.imageUrl=e[this.id]})}static async getImageMap(){if(s.imageMap===undefined){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/rc/v1/Title/webTitles"),{successAction(e){s.imageMap={};e.data.forEach(e=>{s.imageMap[e.identification]=e.web_pic_url});return s.imageMap},errorAction:()=>{return{}},errorMessage:"获取头衔图片失败."})}else{return s.imageMap}}static async getList(){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/i/api/ajaxTitleInfo?page=1&pageSize=256&had=1"),{successAction:e=>e.data.list.map(e=>new s(e)),errorAction:()=>[],errorMessage:"无法获取头衔列表."})}static getContainer(){return document.querySelector("#title-helper .medal-popup ul")}static getItemTemplate(e){return`
          • \n \n
          • `}async activate(){return i.parseJson(await Ajax.postTextWithCredentials(`https://api.live.bilibili.com/i/ajaxWearTitle`,`id=${this.tid}&cid=${this.cid}`),{successAction:()=>{this.isActive=true;return true},errorAction:()=>false,errorMessage:"佩戴头衔失败."})}async deactivate(){return i.parseJson(await Ajax.postTextWithCredentials(`https://api.live.bilibili.com/i/ajaxCancelWearTitle`,""),{successAction:()=>{this.isActive=false;return true},errorAction:()=>false,errorMessage:"卸下头衔失败."})}}async function r(e){const t=e.getContainer();const i=await e.getList();const a=async()=>{const i=await e.getList();i.forEach(e=>{const i=t.querySelector(`li[data-id='${e.id}']`);if(e.isActive){i.classList.add("active")}else{i.classList.remove("active")}i.querySelector(`input`).checked=e.isActive})};i.forEach(s=>{const r=e.getItemTemplate(s);t.insertAdjacentHTML("beforeend",r);const c=t.querySelector(`li[data-id='${s.id}']`);const n=c.querySelector(`input`);c.addEventListener("click",e=>{if(e.target===n){return}if(s.isActive){s.deactivate().then(a)}else{const e=i.find(e=>e.isActive);if(e){e.isActive=false}s.activate().then(a)}})})}return{export:{Badge:i,Medal:a,Title:s},widget:{condition:()=>document.domain==="live.bilibili.com",content:t.data.medalHelperHtml.text,success:()=>{document.querySelectorAll(".medal-helper").forEach(e=>{const t=e.querySelector(".medal-popup");e.addEventListener("click",e=>{if(!t.contains(e.target)){t.classList.toggle("opened")}})});r(a);s.getImageMap().then(()=>r(s))}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/narrow-danmaku.min.js"] = (()=>{return(e,l)=>{const i=``;l.applyStyleFromText(i);return{reload:()=>l.applyStyleFromText(i),unload:()=>document.getElementById("narrow-danmaku-style").remove()}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/new-styles.min.js"] = (()=>{return(e,l)=>{if(document.URL===`https://h.bilibili.com/`){return}if(document.querySelector(`.z_header`)!==null){l.removeStyle("tweetsStyle");return}SpinQuery.any(()=>$(".custom-scrollbar"),e=>e.removeClass("custom-scrollbar"));SpinQuery.any(()=>$("#banner_link"),()=>l.removeStyle("tweetsStyle"));if(["/h.bilibili.com","/live.bilibili.com","/link.bilibili.com"].some(e=>document.URL.includes(e))){l.applyStyle("style","bilibili-style-optimization")}else{Promise.race([SpinQuery.select(()=>document.querySelector(".bili-header-m")).then(e=>e!==null&&e.classList.contains("stardust-video")),SpinQuery.select(()=>document.querySelector("body>#Header")).then(e=>e!==null)]).then(e=>l.applyStyle(e?"style":"oldStyle","bilibili-style-optimization"))}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/no-banner.min.css"] = `#banner_link,.z-top-container.has-banner>.header{display:none!important}.b-header-mask-wrp .b-header-mask-bg,div.blur-bg{opacity:0!important}`; @@ -1115,7 +1115,7 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/touch-player.min.js"] = (()=>{return(t,i)=>{const e=t=>{let i=0;let e=0;while(t&&!isNaN(t.offsetLeft)&&!isNaN(t.offsetTop)){i+=t.offsetLeft-t.scrollLeft;e+=t.offsetTop-t.scrollTop;t=t.offsetParent}return{x:i,y:e}};const s=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const s=t-i*3600-e*60;let o=fixed(s)+"秒";if(e>0){o=e+"分"+o}if(i>0){o=i+"时"+o}return o};const o=t=>{t=Math.abs(t);const i=Math.floor(t/3600);const e=Math.floor((t-i*3600)/60);const s=t-i*3600-e*60;let o=(s<10?"0":"")+fixed(s);o=(e<10?"0":"")+e+":"+o;o=(i<10?"0":"")+i+":"+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",i=>{if(!this.xDown||!this.yDown){return}const s=i.touches[0].clientX;const o=i.touches[0].clientY;const n=e(t);const l={x:(i.touches[0].pageX-n.x)/t.clientWidth,y:(i.touches[0].pageY-n.y)/t.clientHeight,width:t.clientWidth,height:t.clientHeight};const a=this.xDown-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;i.preventDefault()}else{if(this.direction==="vertical"){this.action.startAction(this.direction,c,l)}else if(this.direction==="horizontal"){this.action.startAction(this.direction,-a,l)}i.preventDefault()}});t.addEventListener("touchend",t=>{this.xDown=null;this.yDown=null;this.direction=null;if(this.onTouchEnd){this.onTouchEnd(t)}})}}class l{constructor(t){this.lowSpeedForward=null;this.lowSpeedBackward=null;this.mediumSpeedForward=null;this.mediumSpeedBackward=null;this.highSpeedForward=null;this.highSpeedBackward=null;this.lowVolumeUp=null;this.lowVolumeDown=null;this.mediumVolumeUp=null;this.mediumVolumeDown=null;this.highVolumeUp=null;this.highVolumeDown=null;this.speedCancel=null;this.volumeCancel=null;this.minSwipeDistance=20;this.onActionStart=null;this.onActionEnd=null;this.element=t;this.touchStart=false;this.startPosition=null;this.lastAction=null;t.addEventListener("touchstart",t=>{this.touchStart=true});t.addEventListener("touchend",t=>{this.startPosition=null;this.onActionEnd&&this.onActionEnd(this.lastAction);this.lastAction=null})}startAction(t,i,e){if(this.touchStart){this.onActionStart&&this.onActionStart(t);this.startPosition=e;this.touchStart=false}if(t==="vertical"){if(Math.abs(i)=1/3&&this.startPosition.x<=2/3){t=1;s=this.mediumVolumeUp;o=this.mediumVolumeDown}else{t=2;s=this.highVolumeUp;o=this.highVolumeDown}if(i>0){const o=Math.round(t*100*(i-this.minSwipeDistance)/(1.5*e.height));s&&s(o);this.lastAction={type:"volume",volume:o}}else{const s=Math.round(t*100*(i+this.minSwipeDistance)/(1.5*e.height));o&&o(s);this.lastAction={type:"volume",volume:s}}}}else if(t==="horizontal"){if(e.y<1/3&&(e.x<.1||e.x>.9)||Math.abs(i)=1/3&&this.startPosition.y<=2/3){t=.2;e=this.mediumSpeedForward;s=this.mediumSpeedBackward}else{t=1;e=this.highSpeedForward;s=this.highSpeedBackward}if(i>0){const s=(i-this.minSwipeDistance)*t;e&&e(s);this.lastAction={type:"playback",seconds:s}}else{const e=(i+this.minSwipeDistance)*t;s&&s(e);this.lastAction={type:"playback",seconds:e}}}}}}class a{constructor(){this.aid=unsafeWindow.aid;this.cid=unsafeWindow.cid;this.cidData=null;this.supportWebp=a.supportWebp}getVideoshot(t,i){if(!(this.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(e=>{this.cidData=JSON.parse(e).data;this.getVideoshot(t,i)})}else{const e=this.cidData;const s=e.index;let o=0;for(let i=0;i=s[i]&&tt.replace(".jpg",".jpg@.webp"))}const l=parseInt(e.pv_x_len)||10;const a=parseInt(e.pv_y_len)||10;const c=parseInt(e.pv_x_size)||160;const r=parseInt(e.pv_y_size)||90;const d=-(o%100%l)*c;const h=-Math.floor(o%100/a)*r;i({width:c,height:r,backgroundImage:`url(${n[Math.floor(o/100)]})`,backgroundPosition:`${d}px ${h}px`})}}static get supportWebp(){try{const t=document.createElement("canvas");if(t.getContext&&t.getContext("2d"))try{return t.toDataURL("image/webp").indexOf("data:image/webp")===0}catch(t){return false}else return false}catch(t){return false}}}function c(t){t.unbind("click")}function r(i){if($(".touch-video-box").length!==0){return}$(".bilibili-player-video-subtitle").before(`\n
            \n
            \n
            \n
            \n
            \n
            `);const e=$("video");const l=e.prop("duration");const c=new n(i.get(0));const r=document.getElementsByClassName("touch-video-info")[0];const d=document.getElementsByClassName("touch-video-box")[0];let h=Math.round(e.prop("volume")*100);const u=t=>{t/=100;if(t<0){t=0}else if(t>1){t=1}e.prop("volume",t);const i=JSON.parse(localStorage.bilibili_player_settings);i.video_status.volume=t;localStorage.bilibili_player_settings=JSON.stringify(i);$(".bilibili-player-video-volume-num").text(Math.round(t*100));$(".bui-thumb").css("transform",`translateY(-${48*t}px)`);$(".bui-track-vertical .bui-bar").css("transform",`scaleY(${t})`);if(t===0){$(".bilibili-player-video-btn-volume").addClass("video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-max");e.prop("muted",true)}else if(t===1){$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-min");$(".bilibili-player-video-btn-volume").addClass("video-state-volume-max");e.prop("muted",false)}else{$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-min");$(".bilibili-player-video-btn-volume").removeClass("video-state-volume-max");e.prop("muted",false)}};if(t.touchVideoPlayerAnimation){d.classList.add("animation")}c.action.onActionStart=(t=>{d.classList.add("adjust-opened");r.innerHTML="";h=Math.round(e.prop("volume")*100)});const p=new a;const m=t=>{return i=>{const n=e.prop("currentTime");const a=fixed(100*n/l);let c=n+i;let d=fixed(100*c/l);let h=i;if(c>l){c=l;d=100;h=l-n}else if(c<0){c=0;d=0;h=n}const u=`${o(n)} (${a}%)
            👇
            ${o(c)} (${d}%)`;const m=`\n
            \n
            \n ${t}速\n
            \n
            \n 进度: ${i>0?"+":"-"}${s(h)}\n
            \n
            \n
            \n
            \n
            \n
            \n
            \n ${u}\n
            \n
            \n `;r.innerHTML=m;p.getVideoshot(c,t=>$(".videoshot").css(t));$(".touch-progress").css("transform",`scaleX(${d/100})`)}};c.action.lowSpeedBackward=m("低");c.action.lowSpeedForward=m("低");c.action.mediumSpeedBackward=m("中");c.action.mediumSpeedForward=m("中");c.action.highSpeedBackward=m("高");c.action.highSpeedForward=m("高");const v=t=>{return i=>{let e=h+i;let s=Math.abs(i);if(e>100){e=100;s=100-h}else if(e<0){e=0;s=h}const o=`${h} 👉 ${e}`;u(e);const n=`\n
            \n
            \n ${t}速\n
            \n
            \n 音量: ${i>0?"+":"-"}${s}\n
            \n
            \n
            \n
            \n ${o}\n
            \n
            \n `;r.innerHTML=n;$(".touch-progress").css("transform",`scaleX(${e/100})`)}};c.action.lowVolumeUp=v("低");c.action.lowVolumeDown=v("低");c.action.mediumVolumeUp=v("中");c.action.mediumVolumeDown=v("中");c.action.highVolumeUp=v("高");c.action.highVolumeDown=v("高");c.action.speedCancel=(()=>{r.innerHTML=`松开手指,取消进退`;$(".touch-progress").css("transform","scaleX(0)")});c.action.volumeCancel=(()=>{r.innerHTML=`松开手指,取消调整`;$(".touch-progress").css("transform","scaleX(0)");u(h)});if(!unsafeWindow.TOUCH_PLAYER_DEBUG){c.action.onActionEnd=(t=>{r.innerHTML="";if(t){if(t.type==="playback"){let i=e.prop("currentTime");i+=t.seconds;if(i<0){i=0}else if(i>l){i=l}e.prop("currentTime",i)}}d.classList.remove("adjust-opened")})}}function d(t){if(!t.hasClass("disable-original-hover")){t.addClass("disable-original-hover");const i=unsafeWindow.$(".bilibili-player-video");const e="touch-video-control-show";const s=i.data("events").click[0].handler;const o=new DoubleClickEvent(t=>s(t),()=>t.toggleClass(e));i.unbind("click");o.bind(i[0])}}const h=()=>{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"),d).start()}};if(Observer.videoChange){Observer.videoChange(h)}else{Observer.childList("#bofqi",()=>h())}i.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/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);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=[].map.call(i.querySelectorAll("d[p]"),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/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($(".image-viewer").length===0){this.createContainer()}this.viewer=$(".image-viewer-container");this.downloadImage()}createContainer(){$("body").append((t.data.imageViewerDom||t.data.imageViewerHtml).text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=n();const i=URL.createObjectURL(e.response);if(this.imageData){URL.revokeObjectURL(this.imageData)}this.imageData=i;this.viewer.find(".download").attr("href",i).attr("download",t+this.url.substring(this.url.lastIndexOf(".")));this.viewer.find(".copy-link").on("click",()=>GM_setClipboard(this.url));this.viewer.find(".new-tab").attr("href",this.url);this.viewer.find(".image").prop("src",i)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}return(()=>{if($("meta[itemprop='image'],meta[property='og:image']").length>0){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);await t.fetchInfo();return t.coverUrl}let t=new o(await e());$("#view-cover").on("click",()=>{t.show()});const n=async()=>{t=new o(await e())};if(Observer.videoChange){Observer.videoChange(n)}else{Observer.childList("#bofqi",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=$(".header-info-ctnr .room-cover");const t=e.attr("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.getText(i);const s=JSON.parse(n).data.cover;const a=new o(s);$("#view-cover").on("click",()=>{a.show()})}}}}}})()}})(); +offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/view-cover.min.js"] = (()=>{return(e,t)=>{const{VideoInfo:i}=t.import("video-info");const{getFriendlyTitle:n}=t.import("title");class o{constructor(e){this.url=e;if($(".image-viewer").length===0){this.createContainer()}this.viewer=$(".image-viewer-container");this.downloadImage()}createContainer(){$("body").append(t.data.imageViewerHtml.text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=n();const i=URL.createObjectURL(e.response);if(this.imageData){URL.revokeObjectURL(this.imageData)}this.imageData=i;this.viewer.find(".download").attr("href",i).attr("download",t+this.url.substring(this.url.lastIndexOf(".")));this.viewer.find(".copy-link").on("click",()=>GM_setClipboard(this.url));this.viewer.find(".new-tab").attr("href",this.url);this.viewer.find(".image").prop("src",i)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}return(()=>{if($("meta[itemprop='image'],meta[property='og:image']").length>0){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);await t.fetchInfo();return t.coverUrl}let t=new o(await e());$("#view-cover").on("click",()=>{t.show()});const n=async()=>{t=new o(await e())};if(Observer.videoChange){Observer.videoChange(n)}else{Observer.childList("#bofqi",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=$(".header-info-ctnr .room-cover");const t=e.attr("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.getText(i);const s=JSON.parse(n).data.cover;const a=new o(s);$("#view-cover").on("click",()=>{a.show()})}}}}}})()}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/watchlater.min.js"] = (()=>{return(e,t)=>{const r=e=>{const t=e.match(/(av[\d]+)\/p([\d]+)/);if(t){return`https://www.bilibili.com/video/${t[1]}/?p=${t[2]}`}else{return"javascript:;"}};const a=e=>{const t=e.map(e=>{const t=e.getAttribute("href");if(!t){return"javascript:;"}if(t.match(/.*watchlater.*|javascript:;/g)){return r(t)}if(t.indexOf("video/av")!==-1){return t}});e.forEach((e,r)=>$(e).attr("href",t[r]).attr("target","_blank"))};const i=(...e)=>{for(const t of e){SpinQuery.select(()=>document.querySelectorAll(t),e=>a([...e]))}};SpinQuery.any(()=>$(".watch-later-list"),()=>{(Observer.childListSubtree||Observer.subtree)("#viewlater-app",()=>{SpinQuery.condition(()=>document.URL.match(/(av[\d]+)\/p([\d]+)/),e=>e&&document.URL.indexOf("watchlater")!==-1,()=>{const e=r(document.URL);if(e!==null){window.location.replace(e)}});SpinQuery.any(()=>$("#viewlater-app .s-btn[href='#/']"),e=>e.remove());i(".av-pic",".av-about>a")})});SpinQuery.any(()=>$("li.nav-item[report-id*=watchlater]"),()=>{(Observer.childListSubtree||Observer.subtree)("li.nav-item[report-id*=watchlater]",()=>{i(".av-item>a",".av-about>a","div.watch-later-m>ul>div>li>a");SpinQuery.any(()=>$(".read-more.mr"),e=>e.remove());SpinQuery.any(()=>$(".read-more-grp>.read-more"),e=>e.css({float:"none",width:"auto"}))})})}})(); class ResourceType diff --git a/min/default-player-layout.min.js b/min/default-player-layout.min.js index b70876f9b..d0eb20c25 100644 --- a/min/default-player-layout.min.js +++ b/min/default-player-layout.min.js @@ -1 +1 @@ -(()=>{return(e,t)=>{class s{setCookie(e,t){document.cookie=`${e}=${t};path=/;domain=.bilibili.com;max-age=31536000`}clearCookie(e){document.cookie=`${e}=;path=/;domain=.bilibili.com;max-age=0`}getValue(e){return document.cookie.replace(new RegExp(`(?:(?:^|.*;\\s*)${e}\\s*\\=\\s*([^;]*).*$)|^.*$`),"$1")}checkSettings(){return e.useDefaultPlayerLayout}checkCookies(){if(!this.checkSettings()){return}}useNewLayout(){if(!this.checkSettings()){return}}useOldLayout(){if(!this.checkSettings()){return}}setLayout(e){if(e){this.useNewLayout()}else{this.useOldLayout()}}}class o extends s{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<0&&e.defaultPlayerLayout!=="旧版"){this.useNewLayout()}else if(e.defaultPlayerLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustvideo";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,1)}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,-1)}}class i extends s{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<=0&&e.defaultBangumiLayout!=="旧版"){this.useNewLayout()}else if(e.defaultBangumiLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustpgcv";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,"0606")}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,0)}}const u=new o;addSettingsListener("defaultPlayerLayout",e=>{console.log("layout change detected");u.setLayout(e==="新版")});const a=new i;addSettingsListener("defaultBangumiLayout",e=>{a.setLayout(e==="新版")})}})(); \ No newline at end of file +(()=>{return(e,t)=>{class s{setCookie(e,t){document.cookie=`${e}=${t};path=/;domain=.bilibili.com;max-age=31536000`}clearCookie(e){document.cookie=`${e}=;path=/;domain=.bilibili.com;max-age=0`}getValue(e){return document.cookie.replace(new RegExp(`(?:(?:^|.*;\\s*)${e}\\s*\\=\\s*([^;]*).*$)|^.*$`),"$1")}checkSettings(){return e.useDefaultPlayerLayout}checkCookies(){if(!this.checkSettings()){return}}useNewLayout(){if(!this.checkSettings()){return}}useOldLayout(){if(!this.checkSettings()){return}}setLayout(e){if(e){this.useNewLayout()}else{this.useOldLayout()}}}class o extends s{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<0&&e.defaultPlayerLayout!=="旧版"){this.useNewLayout()}else if(e.defaultPlayerLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustvideo";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,1)}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,-1)}}class i extends s{checkCookies(){super.checkCookies();const t=this.getValue(this.cookieKey);if(t===""||parseInt(t)<=0&&e.defaultBangumiLayout!=="旧版"){this.useNewLayout()}else if(e.defaultBangumiLayout!=="新版"){this.useOldLayout()}}constructor(){super();this.cookieKey="stardustpgcv";this.checkCookies()}useNewLayout(){super.useNewLayout();this.setCookie(this.cookieKey,"0606")}useOldLayout(){super.useOldLayout();this.setCookie(this.cookieKey,0)}}const u=new o;addSettingsListener("defaultPlayerLayout",e=>{u.setLayout(e==="新版")});const a=new i;addSettingsListener("defaultBangumiLayout",e=>{a.setLayout(e==="新版")})}})(); \ No newline at end of file diff --git a/min/download-video.min.js b/min/download-video.min.js index b80570c7a..31d206534 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 n={entity:null,aid:undefined,cid:undefined};let o=null;class r{constructor(){this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}get menuPanel(){return document.querySelector(".download-video-panel")}addMenuClass(){this.menuPanel.classList.remove(...this.menuClasses);this.menuPanel.classList.add(this.currentMenuClass);return this.currentMenuClass}resetMenuClass(){[this.currentMenuClass]=this.menuClasses;this.addMenuClass()}nextMenuClass(){const e=this.menuClasses.indexOf(this.currentMenuClass)+1;const t=this.menuClasses[e>=this.menuClasses.length?0:e];this.currentMenuClass=t;this.addMenuClass();return t}addError(){this.menuPanel.classList.add("error")}removeError(){this.menuPanel.classList.remove("error");this.resetMenuClass()}async getUrl(e){if(e){return`https://api.bilibili.com/x/player/playurl?avid=${n.aid}&cid=${n.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${n.aid}&cid=${n.cid}&otype=json`}}}class a extends r{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${n.aid}&cid=${n.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${n.aid}&cid=${n.cid}&qn=&otype=json`}}}class i{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new c(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{n.entity.getUrl().then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText);if(s.code!==0){t("获取清晰度信息失败.")}const o=s.data||s.result||s;const r=o.accept_quality;const a=o.accept_format.split(",");const l=o.accept_description;const c=[];while(r.length>0){const e=new i(r.pop(),a.pop(),l.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class l{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class c{constructor(e,t){this.format=e;this.fragments=t||[];this.progress=null;this.totalSize=null;this.workingXhr=null;this.fragmentSplitFactor=6*5}fetchVideoInfo(){return new Promise((e,t)=>{n.entity.getUrl(this.format.quality).then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText.replace(/http:/g,"https:"));const o=s.data||s.result||s;if(o.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const r=o.durl;this.fragments=r.map(e=>new l(e.length,e.size,e.url,e.backup_url));e(this.fragments)});n.withCredentials=true;n.open("GET",s);n.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(){if("forEach"in this.workingXhr){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const s=Math.round(e.size/this.fragmentSplitFactor);let n=0;const o=e=>[...this.progressMap.keys()].indexOf(e)+1;while(n{const n=new XMLHttpRequest;n.open("GET",e.url);n.responseType="arraybuffer";n.withCredentials=false;n.addEventListener("progress",e=>{console.log(`[下载视频] 视频片段${o(n)}下载进度: ${e.loaded}/${i} bytes loaded, ${a}`);this.progressMap.set(n,e.loaded);this.updateProgress()});n.addEventListener("load",()=>{if((""+n.status)[0]==="2"){t(n.response)}else{s(`请求失败.`)}});n.addEventListener("abort",()=>s("下载已取消."));n.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${o(n)}下载失败: ${a}`);this.progressMap.set(n,0);this.updateProgress();n.open("GET",e.url);n.setRequestHeader("Range",a);n.send()});n.setRequestHeader("Range",a);this.progressMap.set(n,0);n.send();this.workingXhr.push(n)}));n=Math.round(n+s)+1}return Promise.all(t)}copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}exportData(e=false){const t=JSON.stringify({fragments:this.fragments,title:s(true),totalSize:this.fragments.map(e=>e.size).reduce((e,t)=>e+t)});if(e){GM_setClipboard(t,"text")}else{const e=document.createElement("a");const s=new Blob([t],{type:"text/json"});const n=URL.createObjectURL(s);e.setAttribute("href",n);e.setAttribute("download",`cid${unsafeWindow.cid}.json`);document.body.appendChild(e);e.click();e.remove();URL.revokeObjectURL(n)}}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t=null){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=document.querySelector("a#video-complete").getAttribute("href");if(e&&!document.querySelector(`.link[href="${e}"]`)){URL.revokeObjectURL(e)}[...document.querySelectorAll(".toast-card-header")].filter(e=>e.innerText.includes("下载视频")).forEach(e=>e.querySelector(".toast-card-dismiss").click())}downloadSingle(e){const[t]=e;const n=this.makeBlob(t);const o=s()+this.extension();return[n,o]}async downloadMultiple(e){const t=new JSZip;const n=s();if(e.length>1){e.forEach((e,s)=>{const o=this.fragments[s];t.file(`${n} - ${s+1}${this.extension(o)}`,this.makeBlob(e,o))})}else{const[s]=e;t.file(`${n}${this.extension()}`,this.makeBlob(s))}const o=await t.generateAsync({type:"blob"});const r=n+".zip";return[o,r]}async download(){const e=[];this.totalSize=this.fragments.map(e=>e.size).reduce((e,t)=>e+t);for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let t=null;let s=null;if(e.length===1){[t,s]=this.downloadSingle(e)}else{[t,s]=await this.downloadMultiple(e)}this.cleanUpOldBlobUrl();const n=URL.createObjectURL(t);this.progress&&this.progress(0);return{url:n,filename:s}}}async function d(){const e=["/www.bilibili.com/bangumi"];if(e.some(e=>document.URL.includes(e))){const{BatchExtractor:e}=await t.importAsync("batchDownload");const s=new e;document.getElementById("download-video").classList.add("batch");document.getElementById("video-action-batch-data").addEventListener("click",async()=>{if(!o){return}n.entity.resetMenuClass();const e=Toast.info("获取链接中...","批量下载");const t=await s.collectData(o,e);if(!t){return}GM_setClipboard(t,{type:"text/json"});Toast.success("已复制批量数据到剪贴板.","复制批量数据",3e3)});document.getElementById("video-action-batch-download-data").addEventListener("click",async()=>{if(!o){return}n.entity.resetMenuClass();const e=Toast.info("获取链接中...","批量下载");const t=await s.collectData(o,e);if(!t){return}const r=document.createElement("a");const a=new Blob([t],{type:"text/json"});const i=URL.createObjectURL(a);r.setAttribute("href",i);r.setAttribute("download",`export.json`);document.body.appendChild(r);r.click();r.remove();URL.revokeObjectURL(i)})}}async function u(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);n.aid=e;n.cid=t;if(document.URL.indexOf("bangumi")!==-1){n.entity=new a}else{n.entity=new r}return Boolean(e&&t)}async function p(){let e=await i.availableFormats;o=e[0];const s=async()=>{await u();e=await i.availableFormats;const t=$("ol.video-quality");t.html("");e.forEach(e=>{$(`
          • ${e.displayName}
          • `).on("click",()=>{o=e;n.entity.nextMenuClass()}).prependTo(t)})};if(Observer.videoChange){Observer.videoChange(s)}else{Observer.childList("#bofqi",s)}const r=()=>o.downloadInfo().catch(e=>{n.entity.addError();$(".video-error").text(e)});async function a(){if(!o){return}n.entity.nextMenuClass();const e=await r();e.progress=(e=>{$(".download-progress-value").text(`${fixed(e*100)}`);$(".download-progress-foreground").css("transform",`scaleX(${e})`)});document.querySelector(".download-progress-cancel>span").onclick=(()=>e.cancelDownload());const t=await e.download().catch(e=>{n.entity.addError();$(".video-error").text(e)});if(!t){return}const s=document.getElementById("video-complete");s.setAttribute("href",t.url);s.setAttribute("download",t.filename);s.click();const a=`下载完成. 再次保存`;Toast.success(a,"下载视频");n.entity.resetMenuClass()}async function l(){if(!o){return}const e=await r();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);n.entity.resetMenuClass()}document.querySelector("#video-action-download").addEventListener("click",a);document.querySelector("#video-action-copy").addEventListener("click",l);document.querySelector("#video-action-copy-data").addEventListener("click",async()=>{if(!o){return}const e=await r();e.exportData(true);Toast.success("已复制数据到剪贴板.","复制数据",3e3);n.entity.resetMenuClass()});document.querySelector("#video-action-download-data").addEventListener("click",async()=>{if(!o){return}const e=await r();e.exportData(false);n.entity.resetMenuClass()});t.applyStyle("downloadVideoStyle");const c=document.querySelector(".download-video-panel");const p=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!c.contains(e.target)){p()}});$(".video-error").on("click",()=>{$(".video-error").text("");n.entity.removeError()});await SpinQuery.select(()=>document.querySelector(".download-video-panel"));n.entity.addMenuClass();d()}return{widget:{content:(t.data.downloadVideoDom||t.data.downloadVideoHtml).text,condition:u,success:p}}}})(); \ No newline at end of file +(()=>{return(e,t)=>{const{getFriendlyTitle:s}=t.import("title");const n={entity:null,aid:undefined,cid:undefined};let o=null;class r{constructor(){this.menuClasses=["quality","action","progress"];this.currentMenuClass="quality"}get menuPanel(){return document.querySelector(".download-video-panel")}addMenuClass(){this.menuPanel.classList.remove(...this.menuClasses);this.menuPanel.classList.add(this.currentMenuClass);return this.currentMenuClass}resetMenuClass(){[this.currentMenuClass]=this.menuClasses;this.addMenuClass()}nextMenuClass(){const e=this.menuClasses.indexOf(this.currentMenuClass)+1;const t=this.menuClasses[e>=this.menuClasses.length?0:e];this.currentMenuClass=t;this.addMenuClass();return t}addError(){this.menuPanel.classList.add("error")}removeError(){this.menuPanel.classList.remove("error");this.resetMenuClass()}async getUrl(e){if(e){return`https://api.bilibili.com/x/player/playurl?avid=${n.aid}&cid=${n.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/x/player/playurl?avid=${n.aid}&cid=${n.cid}&otype=json`}}}class a extends r{async getUrl(e){if(e){return`https://api.bilibili.com/pgc/player/web/playurl?avid=${n.aid}&cid=${n.cid}&qn=${e}&otype=json`}else{return`https://api.bilibili.com/pgc/player/web/playurl?avid=${n.aid}&cid=${n.cid}&qn=&otype=json`}}}class i{constructor(e,t,s){this.quality=e;this.internalName=t;this.displayName=s}async downloadInfo(){const e=new c(this);await e.fetchVideoInfo();return e}static get availableFormats(){return new Promise((e,t)=>{n.entity.getUrl().then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText);if(s.code!==0){t("获取清晰度信息失败.")}const o=s.data||s.result||s;const r=o.accept_quality;const a=o.accept_format.split(",");const l=o.accept_description;const c=[];while(r.length>0){const e=new i(r.pop(),a.pop(),l.pop());c.push(e)}e(c)});n.addEventListener("error",()=>t(`获取清晰度信息失败.`));n.withCredentials=true;n.open("GET",s);n.send()})})}}class l{constructor(e,t,s,n){this.length=e;this.size=t;this.url=s;this.backupUrls=n}}class c{constructor(e,t){this.format=e;this.fragments=t||[];this.progress=null;this.totalSize=null;this.workingXhr=null;this.fragmentSplitFactor=6*5}fetchVideoInfo(){return new Promise((e,t)=>{n.entity.getUrl(this.format.quality).then(s=>{const n=new XMLHttpRequest;n.addEventListener("load",()=>{const s=JSON.parse(n.responseText.replace(/http:/g,"https:"));const o=s.data||s.result||s;if(o.quality!==this.format.quality){t("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const r=o.durl;this.fragments=r.map(e=>new l(e.length,e.size,e.url,e.backup_url));e(this.fragments)});n.withCredentials=true;n.open("GET",s);n.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(){if("forEach"in this.workingXhr){this.workingXhr.forEach(e=>e.abort())}else{logError("Cancel Download Failed: forEach in this.workingXhr not found.")}}downloadFragment(e){const t=[];this.workingXhr=[];this.progressMap=new Map;this.updateProgress();const s=Math.round(e.size/this.fragmentSplitFactor);let n=0;const o=e=>[...this.progressMap.keys()].indexOf(e)+1;while(n{const n=new XMLHttpRequest;n.open("GET",e.url);n.responseType="arraybuffer";n.withCredentials=false;n.addEventListener("progress",e=>{console.log(`[下载视频] 视频片段${o(n)}下载进度: ${e.loaded}/${i} bytes loaded, ${a}`);this.progressMap.set(n,e.loaded);this.updateProgress()});n.addEventListener("load",()=>{if((""+n.status)[0]==="2"){t(n.response)}else{s(`请求失败.`)}});n.addEventListener("abort",()=>s("下载已取消."));n.addEventListener("error",()=>{console.error(`[下载视频] 视频片段${o(n)}下载失败: ${a}`);this.progressMap.set(n,0);this.updateProgress();n.open("GET",e.url);n.setRequestHeader("Range",a);n.send()});n.setRequestHeader("Range",a);this.progressMap.set(n,0);n.send();this.workingXhr.push(n)}));n=Math.round(n+s)+1}return Promise.all(t)}copyUrl(){const e=this.fragments.map(e=>e.url).reduce((e,t)=>e+"\r\n"+t);GM_setClipboard(e,"text")}exportData(e=false){const t=JSON.stringify({fragments:this.fragments,title:s(true),totalSize:this.fragments.map(e=>e.size).reduce((e,t)=>e+t)});if(e){GM_setClipboard(t,"text")}else{const e=document.createElement("a");const s=new Blob([t],{type:"text/json"});const n=URL.createObjectURL(s);e.setAttribute("href",n);e.setAttribute("download",`cid${unsafeWindow.cid}.json`);document.body.appendChild(e);e.click();e.remove();URL.revokeObjectURL(n)}}extension(e){return(e||this.fragments[0]).url.indexOf(".flv")!==-1?".flv":".mp4"}makeBlob(e,t=null){return new Blob(Array.isArray(e)?e:[e],{type:this.extension(t)===".flv"?"video/x-flv":"video/mp4"})}cleanUpOldBlobUrl(){const e=document.querySelector("a#video-complete").getAttribute("href");if(e&&!document.querySelector(`.link[href="${e}"]`)){URL.revokeObjectURL(e)}[...document.querySelectorAll(".toast-card-header")].filter(e=>e.innerText.includes("下载视频")).forEach(e=>e.querySelector(".toast-card-dismiss").click())}downloadSingle(e){const[t]=e;const n=this.makeBlob(t);const o=s()+this.extension();return[n,o]}async downloadMultiple(e){const t=new JSZip;const n=s();if(e.length>1){e.forEach((e,s)=>{const o=this.fragments[s];t.file(`${n} - ${s+1}${this.extension(o)}`,this.makeBlob(e,o))})}else{const[s]=e;t.file(`${n}${this.extension()}`,this.makeBlob(s))}const o=await t.generateAsync({type:"blob"});const r=n+".zip";return[o,r]}async download(){const e=[];this.totalSize=this.fragments.map(e=>e.size).reduce((e,t)=>e+t);for(const t of this.fragments){const s=await this.downloadFragment(t);e.push(s)}if(e.length<1){throw new Error("下载失败.")}let t=null;let s=null;if(e.length===1){[t,s]=this.downloadSingle(e)}else{[t,s]=await this.downloadMultiple(e)}this.cleanUpOldBlobUrl();const n=URL.createObjectURL(t);this.progress&&this.progress(0);return{url:n,filename:s}}}async function d(){const e=["/www.bilibili.com/bangumi"];if(e.some(e=>document.URL.includes(e))){const{BatchExtractor:e}=await t.importAsync("batchDownload");const s=new e;document.getElementById("download-video").classList.add("batch");document.getElementById("video-action-batch-data").addEventListener("click",async()=>{if(!o){return}n.entity.resetMenuClass();const e=Toast.info("获取链接中...","批量下载");const t=await s.collectData(o,e);if(!t){return}GM_setClipboard(t,{type:"text/json"});Toast.success("已复制批量数据到剪贴板.","复制批量数据",3e3)});document.getElementById("video-action-batch-download-data").addEventListener("click",async()=>{if(!o){return}n.entity.resetMenuClass();const e=Toast.info("获取链接中...","批量下载");const t=await s.collectData(o,e);if(!t){return}const r=document.createElement("a");const a=new Blob([t],{type:"text/json"});const i=URL.createObjectURL(a);r.setAttribute("href",i);r.setAttribute("download",`export.json`);document.body.appendChild(r);r.click();r.remove();URL.revokeObjectURL(i)})}}async function u(){const e=await SpinQuery.select(()=>(unsafeWindow||window).aid);const t=await SpinQuery.select(()=>(unsafeWindow||window).cid);n.aid=e;n.cid=t;if(document.URL.indexOf("bangumi")!==-1){n.entity=new a}else{n.entity=new r}return Boolean(e&&t)}async function p(){let e=await i.availableFormats;o=e[0];const s=async()=>{await u();e=await i.availableFormats;const t=$("ol.video-quality");t.html("");e.forEach(e=>{$(`
          • ${e.displayName}
          • `).on("click",()=>{o=e;n.entity.nextMenuClass()}).prependTo(t)})};if(Observer.videoChange){Observer.videoChange(s)}else{Observer.childList("#bofqi",s)}const r=()=>o.downloadInfo().catch(e=>{n.entity.addError();$(".video-error").text(e)});async function a(){if(!o){return}n.entity.nextMenuClass();const e=await r();e.progress=(e=>{$(".download-progress-value").text(`${fixed(e*100)}`);$(".download-progress-foreground").css("transform",`scaleX(${e})`)});document.querySelector(".download-progress-cancel>span").onclick=(()=>e.cancelDownload());const t=await e.download().catch(e=>{n.entity.addError();$(".video-error").text(e)});if(!t){return}const s=document.getElementById("video-complete");s.setAttribute("href",t.url);s.setAttribute("download",t.filename);s.click();const a=`下载完成. 再次保存`;Toast.success(a,"下载视频");n.entity.resetMenuClass()}async function l(){if(!o){return}const e=await r();e.copyUrl();Toast.success("已复制链接到剪贴板.","复制链接",3e3);n.entity.resetMenuClass()}document.querySelector("#video-action-download").addEventListener("click",a);document.querySelector("#video-action-copy").addEventListener("click",l);document.querySelector("#video-action-copy-data").addEventListener("click",async()=>{if(!o){return}const e=await r();e.exportData(true);Toast.success("已复制数据到剪贴板.","复制数据",3e3);n.entity.resetMenuClass()});document.querySelector("#video-action-download-data").addEventListener("click",async()=>{if(!o){return}const e=await r();e.exportData(false);n.entity.resetMenuClass()});t.applyStyle("downloadVideoStyle");const c=document.querySelector(".download-video-panel");const p=()=>$(".download-video-panel").toggleClass("opened");$("#download-video").on("click",e=>{if(!c.contains(e.target)){p()}});$(".video-error").on("click",()=>{$(".video-error").text("");n.entity.removeError()});await SpinQuery.select(()=>document.querySelector(".download-video-panel"));n.entity.addMenuClass();d()}return{widget:{content:t.data.downloadVideoHtml.text,condition:u,success:p}}}})(); \ No newline at end of file diff --git a/min/gui-settings.min.js b/min/gui-settings.min.js index 3a985bf11..742e9b193 100644 --- a/min/gui-settings.min.js +++ b/min/gui-settings.min.js @@ -1 +1 @@ -(()=>{return(e,t)=>{const{ThemeColors:n}=t.import("theme-colors");const{SettingsSearch:i}=t.import("settings-search");const{Validator:s}=t.import("text-validate");let o=[];let r=[];let c=[];function a(e){let t=e.nextElementSibling;const n=[];while(t!==null&&!t.classList.contains("category")){n.push(t);t=t.nextElementSibling}return n}function l(){c.forEach(t=>t.value=e[t.getAttribute("key")]);r.forEach(t=>t.checked=e[t.getAttribute("key")])}function u(){document.querySelector(".gui-settings-mask").addEventListener("click",()=>{document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask,.bilibili-evolved-about").forEach(e=>e.classList.remove("opened"))});c.forEach(t=>{t.setAttribute("placeholder",e[t.getAttribute("key")])});document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.addEventListener("click",e=>{const t=document.querySelector(".gui-settings-search");if(t.value!==""){t.value="";raiseEvent(t,"input")}e.currentTarget.classList.toggle("folded");a(e.currentTarget).forEach(e=>e.classList.toggle("folded"))})});document.querySelectorAll(".gui-settings-dropdown>input").forEach(e=>{e.addEventListener("click",e=>{e.currentTarget.parentElement.classList.toggle("opened")})})}function d(){const t=e=>{};r.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const s=n.checked;e[i]=s;t(i);saveSettings(e)})});c.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const o=s.getValidator(i).validate(n.value);e[i]=o;n.value=o;t(i);saveSettings(e)})})}function g(){const e=o.map(e=>[e.getAttribute("dependencies").split(" ").map(e=>o.find(t=>t.getAttribute("key")===e)),e]);const t=e=>e.nodeName.toUpperCase()==="LI"?e:t(e.parentElement);e.forEach(([e,n])=>{if(e[0]===undefined){return}const i=()=>{if(e.every(e=>e.checked)){t(n).classList.remove("disabled")}else{t(n).classList.add("disabled")}};e.forEach(e=>e.addEventListener("change",i));i()})}function f(){if(typeof offlineData!=="undefined"){document.querySelector(".gui-settings-checkbox-container>input[key=useCache]").parentElement.parentElement.classList.add("disabled");document.querySelector("input[key=useCache]").disabled=true}}function b(){document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.click()})}function m(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){o.find(e=>e.getAttribute("key")==="blurVideoControl").disabled=true;e.blurVideoControl=false;saveSettings(e)}if(window.devicePixelRatio===1){o.find(e=>e.getAttribute("key")==="harunaScale").disabled=true;o.find(e=>e.getAttribute("key")==="imageResolution").disabled=true;e.harunaScale=false;e.imageResolution=false;saveSettings(e)}if(e.defaultPlayerLayout==="旧版"){const t=o.find(e=>e.getAttribute("key")==="overrideNavBar");t.disabled=true;raiseEvent(t,"change");if(e.overrideNavBar){t.checked=false;raiseEvent(t,"change");e.overrideNavBar=false;saveSettings(e)}}}function y(){for(const[e,t]of Object.entries(Resource.displayNames)){const n=o.find(t=>t.getAttribute("key")===e);if(!n){continue}switch(n.type){case"checkbox":n.nextElementSibling.nextElementSibling.innerHTML=t;break;case"text":const e=n.parentElement;if(e.classList.contains("gui-settings-textbox-container")){n.previousElementSibling.innerHTML=t}else if(e.classList.contains("gui-settings-dropdown")){e.previousElementSibling.innerHTML=t}break;default:break}}}(async()=>{t.applyStyle("guiSettingsStyle");document.body.insertAdjacentHTML("afterbegin",``);const e=document.body&&unsafeWindow.parent.window!==unsafeWindow;if(e){document.querySelector(".gui-settings-icon-panel").style.display="none"}const s=(t.data.guiSettingsDom||t.data.guiSettingsHtml).text;document.body.insertAdjacentHTML("beforeend",s);const a=document.querySelector(".widgets-container");const p=a.querySelector(".empty-tip");Observer.childList(a,()=>{if(a.childElementCount<=1){p.classList.add("show")}else{p.classList.remove("show")}});o=[...document.querySelectorAll("input[key]")];r=o.filter(e=>e.type==="checkbox");c=o.filter(e=>e.type==="text");u();f();l();g();d();b();m();y();(new n).setupDom();new i;const h=document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box");document.querySelector(".gui-settings-icon-panel").addEventListener("mouseover",()=>{h.forEach(e=>e.classList.add("loaded"))},{once:true})})()}})(); \ No newline at end of file +(()=>{return(e,t)=>{const{ThemeColors:n}=t.import("theme-colors");const{SettingsSearch:i}=t.import("settings-search");const{Validator:s}=t.import("text-validate");let o=[];let r=[];let c=[];function a(e){let t=e.nextElementSibling;const n=[];while(t!==null&&!t.classList.contains("category")){n.push(t);t=t.nextElementSibling}return n}function l(){c.forEach(t=>t.value=e[t.getAttribute("key")]);r.forEach(t=>t.checked=e[t.getAttribute("key")])}function u(){document.querySelector(".gui-settings-mask").addEventListener("click",()=>{document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask,.bilibili-evolved-about").forEach(e=>e.classList.remove("opened"))});c.forEach(t=>{t.setAttribute("placeholder",e[t.getAttribute("key")])});document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.addEventListener("click",e=>{const t=document.querySelector(".gui-settings-search");if(t.value!==""){t.value="";raiseEvent(t,"input")}e.currentTarget.classList.toggle("folded");a(e.currentTarget).forEach(e=>e.classList.toggle("folded"))})});document.querySelectorAll(".gui-settings-dropdown>input").forEach(e=>{e.addEventListener("click",e=>{e.currentTarget.parentElement.classList.toggle("opened")})})}function d(){const t=e=>{};r.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const s=n.checked;e[i]=s;t(i);saveSettings(e)})});c.forEach(n=>{n.addEventListener("change",()=>{const i=n.getAttribute("key");const o=s.getValidator(i).validate(n.value);e[i]=o;n.value=o;t(i);saveSettings(e)})})}function g(){const e=o.map(e=>[e.getAttribute("dependencies").split(" ").map(e=>o.find(t=>t.getAttribute("key")===e)),e]);const t=e=>e.nodeName.toUpperCase()==="LI"?e:t(e.parentElement);e.forEach(([e,n])=>{if(e[0]===undefined){return}const i=()=>{if(e.every(e=>e.checked)){t(n).classList.remove("disabled")}else{t(n).classList.add("disabled")}};e.forEach(e=>e.addEventListener("change",i));i()})}function f(){if(typeof offlineData!=="undefined"){document.querySelector(".gui-settings-checkbox-container>input[key=useCache]").parentElement.parentElement.classList.add("disabled");document.querySelector("input[key=useCache]").disabled=true}}function b(){document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.click()})}function m(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){o.find(e=>e.getAttribute("key")==="blurVideoControl").disabled=true;e.blurVideoControl=false;saveSettings(e)}if(window.devicePixelRatio===1){o.find(e=>e.getAttribute("key")==="harunaScale").disabled=true;o.find(e=>e.getAttribute("key")==="imageResolution").disabled=true;e.harunaScale=false;e.imageResolution=false;saveSettings(e)}if(e.defaultPlayerLayout==="旧版"){const t=o.find(e=>e.getAttribute("key")==="overrideNavBar");t.disabled=true;raiseEvent(t,"change");if(e.overrideNavBar){t.checked=false;raiseEvent(t,"change");e.overrideNavBar=false;saveSettings(e)}}}function y(){for(const[e,t]of Object.entries(Resource.displayNames)){const n=o.find(t=>t.getAttribute("key")===e);if(!n){continue}switch(n.type){case"checkbox":n.nextElementSibling.nextElementSibling.innerHTML=t;break;case"text":const e=n.parentElement;if(e.classList.contains("gui-settings-textbox-container")){n.previousElementSibling.innerHTML=t}else if(e.classList.contains("gui-settings-dropdown")){e.previousElementSibling.innerHTML=t}break;default:break}}}(async()=>{t.applyStyle("guiSettingsStyle");document.body.insertAdjacentHTML("afterbegin",``);const e=document.body&&unsafeWindow.parent.window!==unsafeWindow;if(e){document.querySelector(".gui-settings-icon-panel").style.display="none"}const s=t.data.guiSettingsHtml.text;document.body.insertAdjacentHTML("beforeend",s);const a=document.querySelector(".widgets-container");const p=a.querySelector(".empty-tip");Observer.childList(a,()=>{if(a.childElementCount<=1){p.classList.add("show")}else{p.classList.remove("show")}});(new n).setupDom();const h=document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box");document.querySelector(".gui-settings-icon-panel").addEventListener("mouseover",()=>{h.forEach(e=>e.classList.add("loaded"));o=[...document.querySelectorAll("input[key]")];r=o.filter(e=>e.type==="checkbox");c=o.filter(e=>e.type==="text");u();f();l();g();d();b();m();y();new i},{once:true})})()}})(); \ No newline at end of file diff --git a/min/medal-helper.min.js b/min/medal-helper.min.js index 58624b40a..4619505bb 100644 --- a/min/medal-helper.min.js +++ b/min/medal-helper.min.js @@ -1 +1 @@ -(()=>{return(e,t)=>{class i{constructor(e,t){this.isActive=e;this.id=t}static parseJson(e,{successAction:t,errorMessage:i,errorAction:a}){const s=JSON.parse(e);if(s.code!==0){logError(`${i} 错误码:${s.code} ${s.message||""}`);return a(s)}return t(s)}}class a extends i{constructor({medal_id:e,status:t,level:i,medalName:a,uname:s}){super(t===1,e);this.level=i;this.name=a;this.upName=s}static async getList(){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/i/api/medal?page=1&pageSize=256"),{successAction:e=>e.data.fansMedalList.map(e=>new a(e)),errorAction:()=>[],errorMessage:"无法获取勋章列表."})}static getContainer(){return document.querySelector("#medal-helper .medal-popup ul")}static getItemTemplate(e){return`
          • \n \n
          • `}async activate(){return i.parseJson(await Ajax.getTextWithCredentials(`https://api.live.bilibili.com/i/ajaxWearFansMedal?medal_id=${this.id}`),{successAction:()=>{this.isActive=true;return true},errorAction:()=>false,errorMessage:"佩戴勋章失败."})}async deactivate(){return i.parseJson(await Ajax.getTextWithCredentials(`https://api.live.bilibili.com/i/ajaxCancelWear`),{successAction:()=>{this.isActive=false;return true},errorAction:()=>false,errorMessage:"卸下勋章失败."})}}class s extends i{constructor({id:e,cid:t,wear:i,css:a,name:r,source:c}){super(i,a);this.tid=e;this.cid=t;this.name=r;this.source=c;s.getImageMap().then(e=>{this.imageUrl=e[this.id]})}static async getImageMap(){if(s.imageMap===undefined){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/rc/v1/Title/webTitles"),{successAction(e){s.imageMap={};e.data.forEach(e=>{s.imageMap[e.identification]=e.web_pic_url});return s.imageMap},errorAction:()=>{return{}},errorMessage:"获取头衔图片失败."})}else{return s.imageMap}}static async getList(){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/i/api/ajaxTitleInfo?page=1&pageSize=256&had=1"),{successAction:e=>e.data.list.map(e=>new s(e)),errorAction:()=>[],errorMessage:"无法获取头衔列表."})}static getContainer(){return document.querySelector("#title-helper .medal-popup ul")}static getItemTemplate(e){return`
          • \n \n
          • `}async activate(){return i.parseJson(await Ajax.postTextWithCredentials(`https://api.live.bilibili.com/i/ajaxWearTitle`,`id=${this.tid}&cid=${this.cid}`),{successAction:()=>{this.isActive=true;return true},errorAction:()=>false,errorMessage:"佩戴头衔失败."})}async deactivate(){return i.parseJson(await Ajax.postTextWithCredentials(`https://api.live.bilibili.com/i/ajaxCancelWearTitle`,""),{successAction:()=>{this.isActive=false;return true},errorAction:()=>false,errorMessage:"卸下头衔失败."})}}async function r(e){const t=e.getContainer();const i=await e.getList();const a=async()=>{const i=await e.getList();i.forEach(e=>{const i=t.querySelector(`li[data-id='${e.id}']`);if(e.isActive){i.classList.add("active")}else{i.classList.remove("active")}i.querySelector(`input`).checked=e.isActive})};i.forEach(s=>{const r=e.getItemTemplate(s);t.insertAdjacentHTML("beforeend",r);const c=t.querySelector(`li[data-id='${s.id}']`);const n=c.querySelector(`input`);c.addEventListener("click",e=>{if(e.target===n){return}if(s.isActive){s.deactivate().then(a)}else{const e=i.find(e=>e.isActive);if(e){e.isActive=false}s.activate().then(a)}})})}return{export:{Badge:i,Medal:a,Title:s},widget:{condition:()=>document.domain==="live.bilibili.com",content:(t.data.medalHelperDom||t.data.medalHelperHtml).text,success:()=>{document.querySelectorAll(".medal-helper").forEach(e=>{const t=e.querySelector(".medal-popup");e.addEventListener("click",e=>{if(!t.contains(e.target)){t.classList.toggle("opened")}})});r(a);s.getImageMap().then(()=>r(s))}}}}})(); \ No newline at end of file +(()=>{return(e,t)=>{class i{constructor(e,t){this.isActive=e;this.id=t}static parseJson(e,{successAction:t,errorMessage:i,errorAction:a}){const s=JSON.parse(e);if(s.code!==0){logError(`${i} 错误码:${s.code} ${s.message||""}`);return a(s)}return t(s)}}class a extends i{constructor({medal_id:e,status:t,level:i,medalName:a,uname:s}){super(t===1,e);this.level=i;this.name=a;this.upName=s}static async getList(){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/i/api/medal?page=1&pageSize=256"),{successAction:e=>e.data.fansMedalList.map(e=>new a(e)),errorAction:()=>[],errorMessage:"无法获取勋章列表."})}static getContainer(){return document.querySelector("#medal-helper .medal-popup ul")}static getItemTemplate(e){return`
          • \n \n
          • `}async activate(){return i.parseJson(await Ajax.getTextWithCredentials(`https://api.live.bilibili.com/i/ajaxWearFansMedal?medal_id=${this.id}`),{successAction:()=>{this.isActive=true;return true},errorAction:()=>false,errorMessage:"佩戴勋章失败."})}async deactivate(){return i.parseJson(await Ajax.getTextWithCredentials(`https://api.live.bilibili.com/i/ajaxCancelWear`),{successAction:()=>{this.isActive=false;return true},errorAction:()=>false,errorMessage:"卸下勋章失败."})}}class s extends i{constructor({id:e,cid:t,wear:i,css:a,name:r,source:c}){super(i,a);this.tid=e;this.cid=t;this.name=r;this.source=c;s.getImageMap().then(e=>{this.imageUrl=e[this.id]})}static async getImageMap(){if(s.imageMap===undefined){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/rc/v1/Title/webTitles"),{successAction(e){s.imageMap={};e.data.forEach(e=>{s.imageMap[e.identification]=e.web_pic_url});return s.imageMap},errorAction:()=>{return{}},errorMessage:"获取头衔图片失败."})}else{return s.imageMap}}static async getList(){return i.parseJson(await Ajax.getTextWithCredentials("https://api.live.bilibili.com/i/api/ajaxTitleInfo?page=1&pageSize=256&had=1"),{successAction:e=>e.data.list.map(e=>new s(e)),errorAction:()=>[],errorMessage:"无法获取头衔列表."})}static getContainer(){return document.querySelector("#title-helper .medal-popup ul")}static getItemTemplate(e){return`
          • \n \n
          • `}async activate(){return i.parseJson(await Ajax.postTextWithCredentials(`https://api.live.bilibili.com/i/ajaxWearTitle`,`id=${this.tid}&cid=${this.cid}`),{successAction:()=>{this.isActive=true;return true},errorAction:()=>false,errorMessage:"佩戴头衔失败."})}async deactivate(){return i.parseJson(await Ajax.postTextWithCredentials(`https://api.live.bilibili.com/i/ajaxCancelWearTitle`,""),{successAction:()=>{this.isActive=false;return true},errorAction:()=>false,errorMessage:"卸下头衔失败."})}}async function r(e){const t=e.getContainer();const i=await e.getList();const a=async()=>{const i=await e.getList();i.forEach(e=>{const i=t.querySelector(`li[data-id='${e.id}']`);if(e.isActive){i.classList.add("active")}else{i.classList.remove("active")}i.querySelector(`input`).checked=e.isActive})};i.forEach(s=>{const r=e.getItemTemplate(s);t.insertAdjacentHTML("beforeend",r);const c=t.querySelector(`li[data-id='${s.id}']`);const n=c.querySelector(`input`);c.addEventListener("click",e=>{if(e.target===n){return}if(s.isActive){s.deactivate().then(a)}else{const e=i.find(e=>e.isActive);if(e){e.isActive=false}s.activate().then(a)}})})}return{export:{Badge:i,Medal:a,Title:s},widget:{condition:()=>document.domain==="live.bilibili.com",content:t.data.medalHelperHtml.text,success:()=>{document.querySelectorAll(".medal-helper").forEach(e=>{const t=e.querySelector(".medal-popup");e.addEventListener("click",e=>{if(!t.contains(e.target)){t.classList.toggle("opened")}})});r(a);s.getImageMap().then(()=>r(s))}}}}})(); \ No newline at end of file diff --git a/min/view-cover.min.js b/min/view-cover.min.js index 2b89cc8a9..2f3dca30a 100644 --- a/min/view-cover.min.js +++ b/min/view-cover.min.js @@ -1 +1 @@ -(()=>{return(e,t)=>{const{VideoInfo:i}=t.import("video-info");const{getFriendlyTitle:n}=t.import("title");class o{constructor(e){this.url=e;if($(".image-viewer").length===0){this.createContainer()}this.viewer=$(".image-viewer-container");this.downloadImage()}createContainer(){$("body").append((t.data.imageViewerDom||t.data.imageViewerHtml).text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=n();const i=URL.createObjectURL(e.response);if(this.imageData){URL.revokeObjectURL(this.imageData)}this.imageData=i;this.viewer.find(".download").attr("href",i).attr("download",t+this.url.substring(this.url.lastIndexOf(".")));this.viewer.find(".copy-link").on("click",()=>GM_setClipboard(this.url));this.viewer.find(".new-tab").attr("href",this.url);this.viewer.find(".image").prop("src",i)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}return(()=>{if($("meta[itemprop='image'],meta[property='og:image']").length>0){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);await t.fetchInfo();return t.coverUrl}let t=new o(await e());$("#view-cover").on("click",()=>{t.show()});const n=async()=>{t=new o(await e())};if(Observer.videoChange){Observer.videoChange(n)}else{Observer.childList("#bofqi",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=$(".header-info-ctnr .room-cover");const t=e.attr("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.getText(i);const s=JSON.parse(n).data.cover;const a=new o(s);$("#view-cover").on("click",()=>{a.show()})}}}}}})()}})(); \ No newline at end of file +(()=>{return(e,t)=>{const{VideoInfo:i}=t.import("video-info");const{getFriendlyTitle:n}=t.import("title");class o{constructor(e){this.url=e;if($(".image-viewer").length===0){this.createContainer()}this.viewer=$(".image-viewer-container");this.downloadImage()}createContainer(){$("body").append(t.data.imageViewerHtml.text);$(".image-viewer-container .close").on("click",()=>this.hide());t.applyStyle("imageViewerStyle")}downloadImage(){const e=new XMLHttpRequest;e.open("GET",this.url.replace("http:","https:"),true);e.responseType="blob";e.onload=(()=>{const t=n();const i=URL.createObjectURL(e.response);if(this.imageData){URL.revokeObjectURL(this.imageData)}this.imageData=i;this.viewer.find(".download").attr("href",i).attr("download",t+this.url.substring(this.url.lastIndexOf(".")));this.viewer.find(".copy-link").on("click",()=>GM_setClipboard(this.url));this.viewer.find(".new-tab").attr("href",this.url);this.viewer.find(".image").prop("src",i)});e.send()}show(){this.viewer.addClass("opened")}hide(){this.viewer.removeClass("opened")}}return(()=>{if($("meta[itemprop='image'],meta[property='og:image']").length>0){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);await t.fetchInfo();return t.coverUrl}let t=new o(await e());$("#view-cover").on("click",()=>{t.show()});const n=async()=>{t=new o(await e())};if(Observer.videoChange){Observer.videoChange(n)}else{Observer.childList("#bofqi",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=$(".header-info-ctnr .room-cover");const t=e.attr("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.getText(i);const s=JSON.parse(n).data.cover;const a=new o(s);$("#view-cover").on("click",()=>{a.show()})}}}}}})()}})(); \ No newline at end of file diff --git a/utils/gui-settings/gui-settings.js b/utils/gui-settings/gui-settings.js index 3dbed4a0d..b2a2b7d90 100644 --- a/utils/gui-settings/gui-settings.js +++ b/utils/gui-settings/gui-settings.js @@ -282,7 +282,7 @@ function setDisplayNames() // return; } - const settingsBox = (resources.data.guiSettingsDom || resources.data.guiSettingsHtml).text; + const settingsBox = resources.data.guiSettingsHtml.text; document.body.insertAdjacentHTML("beforeend", settingsBox); const widgetsContainer = document.querySelector(".widgets-container"); @@ -299,23 +299,23 @@ function setDisplayNames() } }); - inputs = [...document.querySelectorAll("input[key]")]; - checkBoxes = inputs.filter(it => it.type === "checkbox"); - textBoxes = inputs.filter(it => it.type === "text"); - setupEvents(); - checkOfflineData(); - syncGui(); - listenDependencies(); - listenSettingsChange(); - foldAllCategories(); - checkCompatibility(); - setDisplayNames(); new ThemeColors().setupDom(); - new SettingsSearch(); const boxes = document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box"); document.querySelector(".gui-settings-icon-panel").addEventListener("mouseover", () => { boxes.forEach(it => it.classList.add("loaded")); + inputs = [...document.querySelectorAll("input[key]")]; + checkBoxes = inputs.filter(it => it.type === "checkbox"); + textBoxes = inputs.filter(it => it.type === "text"); + setupEvents(); + checkOfflineData(); + syncGui(); + listenDependencies(); + listenSettingsChange(); + foldAllCategories(); + checkCompatibility(); + setDisplayNames(); + new SettingsSearch(); }, { once: true }); })(); \ No newline at end of file diff --git a/utils/medal-helper/medal-helper.js b/utils/medal-helper/medal-helper.js index 7ed0a4a58..572e0c561 100644 --- a/utils/medal-helper/medal-helper.js +++ b/utils/medal-helper/medal-helper.js @@ -228,7 +228,7 @@ export default { }, widget: { condition: () => document.domain === "live.bilibili.com", - content: (resources.data.medalHelperDom || resources.data.medalHelperHtml).text, + content: resources.data.medalHelperHtml.text, success: () => { document.querySelectorAll(".medal-helper").forEach(it => diff --git a/video/download-video/download-video.js b/video/download-video/download-video.js index 1c5571a9a..020a17c9a 100644 --- a/video/download-video/download-video.js +++ b/video/download-video/download-video.js @@ -554,7 +554,7 @@ async function loadWidget() export default { widget: { - content: (resources.data.downloadVideoDom || resources.data.downloadVideoHtml).text, + content: resources.data.downloadVideoHtml.text, condition: loadPageData, success: loadWidget, }, diff --git a/video/view-cover/view-cover.js b/video/view-cover/view-cover.js index d13ff1407..ad138895a 100644 --- a/video/view-cover/view-cover.js +++ b/video/view-cover/view-cover.js @@ -14,7 +14,7 @@ class ImageViewer } createContainer() { - $("body").append((resources.data.imageViewerDom || resources.data.imageViewerHtml).text); + $("body").append(resources.data.imageViewerHtml.text); $(".image-viewer-container .close").on("click", () => this.hide()); resources.applyStyle("imageViewerStyle"); }