diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index 327181c66..6ded6920d 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Offline) -// @version 608.19 +// @version 609.03 // @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2020, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -1223,8 +1223,8 @@ offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/m offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-live-records.min.js"] = (()=>{return(t,o)=>{const e=()=>document.URL.replace(location.search,"").match(/https:\/\/live\.bilibili\.com\/record\/(.+)/);return{widget:{content:`\n`,condition:async()=>{const t=e();return Boolean(t)},success:()=>{const t=dq("#download-live-records");t.addEventListener("click",async()=>{try{t.disabled=true;const o=e()[1];const n=await Ajax.getJson(`https://api.live.bilibili.com/xlive/web-room/v1/record/getLiveRecordUrl?rid=${o}&platform=html5`);if(n.code!==0){logError(new Error(`获取录像链接失败: ${n.message}`));return}const i=n.data.list.map(t=>t.url);Toast.success(i.map(t=>`${t}`).join("\n"),"下载录像")}catch(t){logError(t)}finally{t.disabled=false}})}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-subtitle.min.js"] = (()=>{return(t,e)=>{let i;const o=(t,e)=>{const o=document.createElement("a");const n=URL.createObjectURL(new Blob([t]));if(i){URL.revokeObjectURL(i)}i=n;o.setAttribute("href",n);o.setAttribute("download",escapeFilename(e));document.body.appendChild(o);o.click();o.remove()};return{widget:{content:`\n`,condition:videoCondition,success:()=>{const t=dq("#download-subtitle");t.addEventListener("click",async i=>{try{t.disabled=true;const{aid:n,cid:s}=unsafeWindow;if(!n||!s){logError("未找到视频AID和CID");return}const{VideoInfo:l}=await e.importAsync("video-info");const{getFriendlyTitle:c}=await e.importAsync("title");const r=new l(n);r.cid=parseInt(s);await r.fetchInfo();const a=r.subtitles;if(a.length===0){Toast.info("当前视频没有字幕.","下载字幕",3e3);return}const d=await loadSubtitleSettingsPanel();if(!d){logError("未找到字幕设置");return}const u=d.querySelector(".bilibili-player-video-subtitle-setting-lan .bui-select-result").innerHTML;const b=a.find(t=>t.language===u)||a[0];const f=await Ajax.getJson(b.url);const p=f.body;const y=c(true);if(i.shiftKey){const{SubtitleConverter:t,SubtitleSize:i,SubtitleLocation:n}=await e.importAsync("subtitle-converter");const s=d.querySelector(".bilibili-player-video-subtitle-setting-fontsize .bui-thumb");const l=parseFloat(s.style.transform.replace(/translateX\(([\d\.]+)/,"$1"));const c={214:i.VeryLarge,163.5:i.Large,107:i.Medium,50.5:i.Small,0:i.VerySmall};const r=c[l];const a=d.querySelector(".bilibili-player-video-subtitle-setting-color .bui-select-result span:first-child");const u=a.getAttribute("style").match(/background:[ ]*(.+);/)[1];const b=d.querySelector(".bilibili-player-video-subtitle-setting-opacity .bui-bar");const f=parseFloat(b.style.transform.replace(/scaleX\(([\d\.]+)/,"$1"));const g=dq(".subtitle-position");const m={bc:n.BottomCenter,bl:n.BottomLeft,br:n.BottomRight,tc:n.TopCenter,tl:n.TopLeft,tr:n.TopRight};const h=Object.entries(m).filter(([t])=>{return g.classList.contains(`subtitle-position-${t}`)}).map(([,t])=>t).shift();const w=dq("video");const v={title:y,height:w.videoHeight,width:w.videoWidth,color:u,location:h,opacity:f,size:r};const S=new t(v);const L=await S.convertToAss(p);o(L,y+".ass")}else{o(JSON.stringify(p),y+".json")}}catch(t){logError(t)}finally{t.disabled=false}})}}}}})(); offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.css"] = `.download-video{--download-video-background:white;--download-video-foreground:black;position:absolute;top:96px;left:50%;transform:translateX(-50%) scale(.95);background:var(--download-video-background);color:var(--download-video-foreground);box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;z-index:10001;pointer-events:none;opacity:0;padding:16px;width:300px;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;box-sizing:content-box;line-height:normal}.download-video,.download-video *{transition:.2s ease-out;-webkit-tap-highlight-color:transparent!important}.download-video.opened{pointer-events:initial;opacity:1;transform:translateX(-50%) scale(1)}body.dark .download-video{--download-video-background:#222;--download-video-foreground:#eee}.round-corner .download-video,.round-corner .download-video .episode-list .v-checkbox,.round-corner .download-video .rpc-settings{border-radius:var(--large-corner-radius)}.round-corner .download-video .button,.round-corner .download-video .cover,.round-corner .download-video .direct-download .progress .background,.round-corner .download-video .direct-download .progress .foreground,.round-corner .download-video .rpc-settings input[type=text],.round-corner .download-video .size-warning-tip,.round-corner .download-video .title,.round-corner .download-video button{border-radius:var(--corner-radius)}.download-video .cover{min-height:100px;max-height:120px;object-fit:contain}.download-video h1{font-size:13pt;font-weight:700;color:var(--download-video-foreground)}.download-video h2{font-size:11pt;font-weight:700;color:var(--download-video-foreground)}.download-video .header{display:flex;justify-content:space-between;align-items:center}.download-video .header .grow{flex-grow:1}.download-video .header .mdi-download{font-size:16pt;color:var(--download-video-foreground);margin-right:8px}.download-video .header .mdi-close{font-size:16pt;color:var(--download-video-foreground);cursor:pointer}.download-video .header .mdi-close:hover{color:var(--theme-color)}.download-video .info{display:flex;flex-direction:column;align-items:center;margin-top:12px}.download-video .title{display:flex;flex-direction:column;justify-content:space-between;align-items:stretch;margin-top:12px}.download-video .title .bold{width:300px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}.download-video .title .size{font-size:10pt;color:var(--download-video-foreground);align-self:center;display:flex;align-items:center;height:24px}.download-video .bold{color:var(--download-video-foreground);font-weight:700;font-size:12pt}.download-video .option-item{display:flex;justify-content:space-between;align-items:center;padding-top:12px;font-size:10pt}.download-video .tabs{display:flex;padding:12px 0;font-size:10pt}.download-video .tabs .tab{cursor:pointer;position:relative;opacity:.5}.download-video .tabs .tab.active{font-weight:700;opacity:1}.download-video .tabs .tab:not(:last-child){margin-right:16px}.download-video .tabs .tab::after{content:"";position:absolute;border-radius:2px;background-color:var(--theme-color);height:3px;width:80%;left:10%;bottom:-8px;transition:.2s ease-out;transform:scaleX(0)}.download-video .tabs .tab.active::after{transform:scaleX(1)}.download-video .separator{height:1px;background:#8884;width:100%;margin:12px 0;flex-shrink:0}.download-video .direct-download{display:flex;flex-direction:column;align-items:start;justify-content:space-between}.download-video .button,.download-video button{border:none;outline:0!important;padding:6px 16px;font-size:10pt;cursor:pointer;background:#8884;color:var(--download-video-foreground)}.download-video .button:hover,.download-video button:hover{background:#8886}.download-video .primary{background:var(--theme-color);color:var(--foreground-color);align-self:center}.download-video .primary:hover{background:var(--theme-color-90)}.download-video .busy .button,.download-video .busy .primary,.download-video .busy button,.download-video button:disabled{background-color:#0001;color:#8884;cursor:not-allowed}.download-video .busy .button,.download-video .busy button{cursor:wait!important}.download-video .direct-download .progress{align-self:stretch;display:flex;align-items:center;margin-top:8px}.download-video .direct-download .progress .background{flex-grow:1;height:4px;background:#8884;margin-right:4px;position:relative}.download-video .direct-download .progress .background .foreground{position:absolute;top:0;left:0;height:4px;background:linear-gradient(to right,var(--theme-color),var(--theme-color-60))}.download-video .direct-download .progress .percent{width:50px;text-align:right;font-size:12px}.download-video .actions{display:flex;flex-wrap:wrap;justify-content:space-between;margin:8px -4px 0}.download-video .actions>*{margin:4px;flex-grow:1;flex-basis:calc(50% - 16px);display:flex;justify-content:center;align-items:center;white-space:nowrap}.download-video i.mdi-alert-circle{font-size:14pt;color:#ff9800}.download-video .size-warning{position:relative;padding:0 8px}.download-video .size-warning-tip{position:absolute;bottom:100%;left:50%;transform:translateX(-50%);background:var(--download-video-background);color:var(--download-video-foreground);border:1px dashed var(--theme-color);z-index:2;font-size:10pt;width:200px;padding:8px;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;pointer-events:none;opacity:0}.download-video .size-warning:hover .size-warning-tip{opacity:1}.download-video .episode-list .v-checkbox{padding:4px 8px;margin:4px 0;position:relative;background-color:transparent}.download-video .episode-list .v-checkbox.checked{background-color:#8882}.download-video .episode-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}.download-video .episode-list{overflow:auto;max-height:320px}.download-video button.list-tool{padding:4px;line-height:1;font-size:12pt;margin:0 4px}.download-video .episode-header h2{flex-grow:1}.download-video .selected-count{width:64px;font-size:12px;text-align:right}.download-video .aria2-rpc .mdi{margin-left:8px;font-size:14pt;line-height:1}.download-video .aria2-rpc{position:relative}.download-video .rpc-settings{position:absolute;display:flex;flex-direction:column;align-items:stretch;color:var(--download-video-foreground);background:#fff;bottom:120%;left:50%;cursor:initial;box-shadow:rgba(0,0,0,.2) 0 4px 8px 0;transform-origin:bottom;transform:translateX(-50%) scale(.9);opacity:0;pointer-events:none;padding:8px;z-index:3;transition:.3s cubic-bezier(.18,.89,.32,1.28);width:120%}body.dark .download-video .rpc-settings{background:#282828}.download-video .rpc-settings>*{margin:8px}.download-video .rpc-settings.show{opacity:1;transform:translateX(-50%) scale(1);pointer-events:initial}.download-video .rpc-settings input[type=text]{background:0 0;color:var(--download-video-foreground);border:1px solid #8884;padding:4px;margin-left:8px}.download-video .rpc-settings input[type=text]:focus{border-color:var(--theme-color)}.download-video .rpc-settings .operations{display:flex;align-items:center;justify-content:space-evenly}.download-video .final-dir{white-space:normal;word-break:break-all}.download-video .rpc-settings-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap}.download-video .rpc-settings-item input[type=text]{flex-grow:1;margin-left:24px}.download-video button.cancel-download,.download-video button.start-download{margin-top:8px}.download-video .direct-download-header{align-self:stretch;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-header{margin-bottom:12px;display:flex;justify-content:space-between;align-items:center}.download-video .manual-input-content{display:flex;justify-content:stretch}.download-video .manual-input-content textarea{margin:0;height:180px;resize:none;padding:8px;border-radius:4px;flex:1 0 0;outline:0!important;border-color:#dfdfdf}.download-video .manual-input-content textarea:focus,.download-video .manual-input-content textarea:focus-within{border-color:var(--theme-color)}body.dark .download-video .direct-download .progress .foreground{background:linear-gradient(to right,var(--theme-color-70),var(--theme-color))}`; -offlineData["https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/min/download-video.min.html"] = `