Compile files

This commit is contained in:
the1812 2018-10-25 11:37:11 +08:00
parent 4424e196f7
commit bbff7ed820
10 changed files with 73 additions and 16 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name Bilibili Evolved (Preview)
// @version 1.5.11
// @version 1.5.12
// @description 增强哔哩哔哩Web端体验. (预览版分支)
// @author Grant Howard, Coulomb-G
// @match *://*.bilibili.com/*
@ -56,8 +56,9 @@
notifyNewVersion: true,
clearCache: true,
fixFullscreen: false,
downloadVideo: true,
latestVersionLink: "https://github.com/the1812/Bilibili-Evolved/raw/preview/bilibili-evolved.preview.user.js",
currentVersion: "1.5.10"
currentVersion: "1.5.12"
};
function loadSettings()
{
@ -104,9 +105,11 @@
toastStyle: new Resource("min/toast.min.scss", 9),
blurVideoControlStyle: new Resource("min/blur-video-control.min.css", 10),
forceWideStyle: new Resource("min/force-wide.min.scss"),
downloadVideoStyle: new Resource("min/download-video.min.scss"),
guiSettingsDom: new Resource("min/gui-settings.min.html"),
imageViewerDom: new Resource("min/image-viewer.min.html"),
downloadVideoDom: new Resource("min/download-video.min.html"),
latestVersion: new Resource("version.txt"),
guiSettings: new Resource("min/gui-settings.min.js"),
@ -129,7 +132,8 @@
blurVideoControl: new Resource("min/blur-video-control.min.js"),
darkSchedule: new Resource("min/dark-schedule.min.js"),
forceWide: new Resource("min/force-wide.min.js"),
clearCache: new Resource("min/clear-cache.min.js")
clearCache: new Resource("min/clear-cache.min.js"),
downloadVideo: new Resource("min/download-video.min.js")
};
(function ()
{

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name Bilibili Evolved
// @version 1.5.10
// @version 1.5.12
// @description 增强哔哩哔哩Web端体验.
// @author Grant Howard, Coulomb-G
// @match *://*.bilibili.com/*
@ -56,8 +56,9 @@
notifyNewVersion: true,
clearCache: true,
fixFullscreen: false,
downloadVideo: true,
latestVersionLink: "https://github.com/the1812/Bilibili-Evolved/raw/master/bilibili-evolved.user.js",
currentVersion: "1.5.10"
currentVersion: "1.5.12"
};
function loadSettings()
{
@ -104,9 +105,11 @@
toastStyle: new Resource("min/toast.min.scss", 9),
blurVideoControlStyle: new Resource("min/blur-video-control.min.css", 10),
forceWideStyle: new Resource("min/force-wide.min.scss"),
downloadVideoStyle: new Resource("min/download-video.min.scss"),
guiSettingsDom: new Resource("min/gui-settings.min.html"),
imageViewerDom: new Resource("min/image-viewer.min.html"),
downloadVideoDom: new Resource("min/download-video.min.html"),
latestVersion: new Resource("version.txt"),
guiSettings: new Resource("min/gui-settings.min.js"),
@ -129,7 +132,8 @@
blurVideoControl: new Resource("min/blur-video-control.min.js"),
darkSchedule: new Resource("min/dark-schedule.min.js"),
forceWide: new Resource("min/force-wide.min.js"),
clearCache: new Resource("min/clear-cache.min.js")
clearCache: new Resource("min/clear-cache.min.js"),
downloadVideo: new Resource("min/download-video.min.js")
};
(function ()
{
@ -207,6 +211,7 @@
const xhr = new XMLHttpRequest();
xhr.addEventListener("load", () => load && load(xhr.responseText));
xhr.addEventListener("error", () => error && error(xhr.responseText));
xhr.withCredentials = true;
xhr.open("GET", url);
xhr.send();
}

View File

@ -0,0 +1 @@
<li class="indent-center hidden"><button class="gui-settings-button" title="下载当前视频" id="download-video">下载视频</button><div class="download-video-panel quality"><ol class="video-quality"></ol><div class="video-progress"><div>正在下载<span class="download-progress-value">0</span>%</div><div class="download-progress-background"><div class="download-progress-foreground"></div></div></div><a href="" class="video-complete"></a></div></li>

1
min/download-video.min.js vendored Normal file
View File

@ -0,0 +1 @@
(()=>{return(t,e)=>{class a{constructor(t,e,a){this.quality=t;this.internalName=e;this.displayName=a}static get availableFormats(){return new Promise((t,e)=>{const i=`https://api.bilibili.com/x/player/playurl?avid=${unsafeWinodw.aid}&cid=${unsafeWinodw.cid}&otype=json`;downloadText(i,e=>{const i=JSON.parse(e).data;const n=i.accept_quality;const s=i.accept_format.split(",");const o=i.accept_description;const l=[];while(n.length>0){const t=new a(n.pop(),s.pop(),o.pop());l.push(t)}t(l)},t=>e(`获取清晰度信息失败: ${t}`))})}}class i{constructor(t,e,a,i){this.length=t;this.size=e;this.url=a;this.backupUrls=i}}class n{constructor(t,e){this.format=t;this.fragments=e||[]}fetchVideoInfo(){return new Promise((t,e)=>{const a=`https://api.bilibili.com/x/player/playurl?avid=${unsafeWinodw.aid}&cid=${unsafeWinodw.cid}&qn=${this.format.quality}&otype=json`;downloadText(a,a=>{const n=JSON.parse(a).data;if(n.quality!==this.format.quality){e("获取下载链接失败, 请确认当前账号有下载权限后重试.")}const s=n.durl;this.fragments=s.map(t=>new i(t.length,t.size,t.url,t.backup_url));if(this.fragments.length>1){e("暂不支持分段视频的下载.")}t()})})}}return{settingsWidget:{after:()=>$("span.settings-category").filter((t,e)=>e.innerHTML==="视频与直播").parent(),content:e.data.downloadVideoDom.text,success:()=>{new SpinQuery(()=>$("#download-video"),t=>t.length>0&&typeof unsafeWinodw!=="undefined",()=>{a.availableFormats.then(t=>{t.forEach(t=>{$("ol.video-quality").append(`<li>${t.displayName}</li>`)});e.applyStyle("downloadVideoStyle");$("#download-video").on("click",()=>{$(".download-video-panel").toggleClass("opened")}).parent().removeClass("hidden")})}).start()}}}}})();

View File

@ -0,0 +1 @@
#download-video{position:relative;}.download-video-panel.opened{transform:scale(1);}.download-video-panel{position:absolute;top:0;transition:all .2s ease-out;transform-origin:top;transform:scale(0);}

View File

@ -1 +1 @@
1.5.10
1.5.12

View File

@ -85,7 +85,24 @@
content: resources.data.downloadVideoDom.text,
success: () =>
{
resources.applyStyle("downloadVideoStyle");
new SpinQuery(() => $("#download-video"),
it => it.length > 0 && typeof unsafeWinodw !== "undefined",
() =>
{
VideoFormat.availableFormats.then((formats) =>
{
formats.forEach(format =>
{
$("ol.video-quality").append(`<li>${format.displayName}</li>`);
});
resources.applyStyle("downloadVideoStyle");
$("#download-video").on("click", () =>
{
$(".download-video-panel").toggleClass("opened");
}).parent().removeClass("hidden");
});
}
).start();
}
}
};

View File

@ -2,3 +2,15 @@
{
position: relative;
}
.download-video-panel.opened
{
transform: scale(1);
}
.download-video-panel
{
position: absolute;
top: 0;
transition: all .2s ease-out;
transform-origin: top;
transform: scale(0);
}