Add loading message

This commit is contained in:
the1812 2018-12-10 19:25:06 +08:00
parent 1c9c19ef8c
commit a844ce950b
4 changed files with 12 additions and 7 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 +1 @@
(()=>{return(n,t)=>{const e=t.attributes.videoInfo.export.DanmakuInfo;async function a(){const n=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","");const t=new e((unsafeWindow||window).cid);await t.fetchInfo();const a=new Blob([t.rawXML],{type:"text/plain"});const i=URL.createObjectURL(a);const o=$("#danmaku-link");const d=o.attr("href");if(d){URL.revokeObjectURL(d)}o.attr("download",`${n}.xml`).attr("href",i).get(0).click()}return{widget:{content:`\n <button\n class="gui-settings-flat-button"\n id="download-danmaku">\n <i class="icon-danmaku"></i>\n <span>下载弹幕</span>\n <a id="danmaku-link" style="display:none"></a>\n </button>`,condition:async()=>{let n=(unsafeWindow||window).aid;let t=(unsafeWindow||window).cid;if(n===undefined||t===undefined){const e=document.URL.match(/\/av(\d+)/);if(e&&e[1]){const a=await new VideoInfo(e[1]).fetchInfo();n=a.aid;t=a.cid}}return t!==undefined},success:()=>{const n=document.querySelector("#danmaku-link");$("#download-danmaku").on("click",t=>{if(t.target!==n){a()}})}}}}})();
(()=>{return(n,t)=>{const e=t.attributes.videoInfo.export.DanmakuInfo;async function o(n){const t=document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili","");const o=new e((unsafeWindow||window).cid);await o.fetchInfo();const a=new Blob([o.rawXML],{type:"text/plain"});const i=URL.createObjectURL(a);const d=$("#danmaku-link");const c=d.attr("href");if(c){URL.revokeObjectURL(c)}clearTimeout(n);document.querySelector("#download-danmaku>span").innerHTML="下载弹幕";d.attr("download",`${t}.xml`).attr("href",i).get(0).click()}return{widget:{content:`\n <button\n class="gui-settings-flat-button"\n id="download-danmaku">\n <i class="icon-danmaku"></i>\n <span>下载弹幕</span>\n <a id="danmaku-link" style="display:none"></a>\n </button>`,condition:async()=>{let n=(unsafeWindow||window).aid;let t=(unsafeWindow||window).cid;if(n===undefined||t===undefined){const e=document.URL.match(/\/av(\d+)/);if(e&&e[1]){const o=await new VideoInfo(e[1]).fetchInfo();n=o.aid;t=o.cid}}return t!==undefined},success:()=>{const n=document.querySelector("#danmaku-link");$("#download-danmaku").on("click",t=>{if(t.target!==n){const n=setTimeout(()=>document.querySelector("#download-danmaku>span").innerHTML="请稍侯...",200);o(n)}})}}}}})();

View File

@ -3,7 +3,7 @@
return (settings, resources) =>
{
const DanmakuInfo = resources.attributes.videoInfo.export.DanmakuInfo;
async function downloadDanmaku()
async function downloadDanmaku(timeout)
{
const title = document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili", "");
const danmaku = new DanmakuInfo((unsafeWindow || window).cid);
@ -18,6 +18,8 @@
{
URL.revokeObjectURL(oldUrl);
}
clearTimeout(timeout);
document.querySelector("#download-danmaku>span").innerHTML = "下载弹幕";
link.attr("download", `${title}.xml`).attr("href", url).get(0).click();
}
return {
@ -53,7 +55,10 @@
{
if (e.target !== link)
{
downloadDanmaku();
const timeout = setTimeout(
() => document.querySelector("#download-danmaku>span").innerHTML = "请稍侯...",
200);
downloadDanmaku(timeout);
}
});
},