mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Add download danmaku
This commit is contained in:
parent
d5b7ba3a8d
commit
7ed206d20d
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name Bilibili Evolved (Preview)
|
||||
// @version 1.6.8
|
||||
// @version 1.6.9
|
||||
// @description 增强哔哩哔哩Web端体验(预览版分支): 修复界面瑕疵, 删除广告, 使用夜间模式浏览, 下载视频或视频封面, 以及增加对触屏设备的支持等.
|
||||
// @author Grant Howard, Coulomb-G
|
||||
// @copyright 2018, Grant Howrad (https://github.com/the1812)
|
||||
@ -58,7 +58,6 @@
|
||||
defaultVideoQuality: "自动",
|
||||
useDefaultVideoQuality: false,
|
||||
autoLightOff: false,
|
||||
downloadDanmaku: false,
|
||||
useCache: true,
|
||||
comboLike: true,
|
||||
doubleCoins: true,
|
||||
@ -72,6 +71,7 @@
|
||||
clearCache: true,
|
||||
fixFullscreen: false,
|
||||
downloadVideo: true,
|
||||
downloadDanmaku: true,
|
||||
useDefaultPlayerMode: true,
|
||||
about: false,
|
||||
blurSettingsPanel: false,
|
||||
@ -419,10 +419,18 @@
|
||||
"videoInfo",
|
||||
],
|
||||
displayNames: {
|
||||
"downloadDanmaku": "下载视频时包含弹幕",
|
||||
"downloadVideo": "下载视频",
|
||||
},
|
||||
},
|
||||
downloadDanmaku: {
|
||||
path: "min/download-danmaku.min.js",
|
||||
dependencies: [
|
||||
"videoInfo",
|
||||
],
|
||||
displayNames: {
|
||||
"downloadDanmaku": "下载弹幕",
|
||||
},
|
||||
},
|
||||
videoInfo: {
|
||||
path: "min/video-info.min.js",
|
||||
},
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name Bilibili Evolved
|
||||
// @version 1.6.8
|
||||
// @version 1.6.9
|
||||
// @description 增强哔哩哔哩Web端体验: 修复界面瑕疵, 删除广告, 使用夜间模式浏览, 下载视频或视频封面, 以及增加对触屏设备的支持等.
|
||||
// @author Grant Howard, Coulomb-G
|
||||
// @copyright 2018, Grant Howrad (https://github.com/the1812)
|
||||
@ -58,7 +58,6 @@
|
||||
defaultVideoQuality: "自动",
|
||||
useDefaultVideoQuality: false,
|
||||
autoLightOff: false,
|
||||
downloadDanmaku: false,
|
||||
useCache: true,
|
||||
comboLike: true,
|
||||
doubleCoins: true,
|
||||
@ -72,6 +71,7 @@
|
||||
clearCache: true,
|
||||
fixFullscreen: false,
|
||||
downloadVideo: true,
|
||||
downloadDanmaku: true,
|
||||
useDefaultPlayerMode: true,
|
||||
about: false,
|
||||
blurSettingsPanel: false,
|
||||
@ -419,10 +419,18 @@
|
||||
"videoInfo",
|
||||
],
|
||||
displayNames: {
|
||||
"downloadDanmaku": "下载视频时包含弹幕",
|
||||
"downloadVideo": "下载视频",
|
||||
},
|
||||
},
|
||||
downloadDanmaku: {
|
||||
path: "min/download-danmaku.min.js",
|
||||
dependencies: [
|
||||
"videoInfo",
|
||||
],
|
||||
displayNames: {
|
||||
"downloadDanmaku": "下载弹幕",
|
||||
},
|
||||
},
|
||||
videoInfo: {
|
||||
path: "min/video-info.min.js",
|
||||
},
|
||||
|
||||
1
min/download-danmaku.min.js
vendored
Normal file
1
min/download-danmaku.min.js
vendored
Normal file
@ -0,0 +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()}})}}}}})();
|
||||
2
min/download-video.min.js
vendored
2
min/download-video.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
<div class="gui-settings-mask"></div><div class="gui-settings-widgets-box icons-enabled"><div class="gui-settings-header"><i class="icon-widgets"></i><span class="gui-settings-title">附加功能</span></div><div class="widgets-container"></div></div><div class="gui-settings-box icons-enabled"><div class="gui-settings-header"><i class="icon-settings"></i><span class="gui-settings-title">设置</span></div><div class="gui-settings-content"><ul><category icon="video">视频与直播</category><dropdown indent="0" key="defaultPlayerMode" dependencies=""></dropdown><checkbox indent="0" key="useDefaultVideoQuality" dependencies=""></checkbox><dropdown indent="1" key="defaultVideoQuality" dependencies="useDefaultVideoQuality"></dropdown><checkbox indent="0" key="downloadDanmaku" dependencies=""></checkbox><checkbox indent="0" key="autoLightOff" dependencies=""></checkbox><checkbox indent="0" key="expandDanmakuList" dependencies=""></checkbox><checkbox indent="0" key="harunaScale" dependencies=""></checkbox><checkbox indent="0" key="removeLiveWatermark" dependencies=""></checkbox><checkbox indent="0" key="removeVideoTopMask" dependencies=""></checkbox><checkbox indent="0" key="blurVideoControl" dependencies=""></checkbox><checkbox indent="0" key="customControlBackground" dependencies=""></checkbox><textbox indent="1" key="customControlBackgroundOpacity" dependencies="customControlBackground"></textbox><category icon="style">样式</category><li class="indent-0"><label class="gui-settings-textbox-container"><span>主题颜色</span><div class="custom-color-preview"><div class="predefined-colors popup"><div class="predefined-colors-grid"></div></div></div><input key="customStyleColor" dependencies="" spellcheck="false" type="text"/></label></li><checkbox indent="0" key="useNewStyle" dependencies=""></checkbox><textbox indent="1" key="blurBackgroundOpacity" dependencies="useNewStyle"></textbox><checkbox indent="0" key="useDarkStyle" dependencies=""></checkbox><checkbox indent="0" key="darkSchedule" dependencies=""></checkbox><textbox indent="1" key="darkScheduleStart" dependencies="darkSchedule"></textbox><textbox indent="1" key="darkScheduleEnd" dependencies="darkSchedule"></textbox><checkbox indent="0" key="overrideNavBar" dependencies=""></checkbox><checkbox indent="1" key="showBanner" dependencies="overrideNavBar"></checkbox><checkbox indent="1" key="preserveRank" dependencies="overrideNavBar"></checkbox><checkbox indent="0" key="forceWide" dependencies=""></checkbox><textbox indent="1" key="forceWideMinWidth" dependencies="forceWide"></textbox><category icon="tool">工具</category><checkbox indent="0" key="removeAds" dependencies=""></checkbox><checkbox indent="0" key="watchLaterRedirect" dependencies=""></checkbox><checkbox indent="0" key="hideTopSearch" dependencies=""></checkbox><checkbox indent="0" key="fullTweetsTitle" dependencies=""></checkbox><checkbox indent="0" key="comboLike" dependencies=""></checkbox><checkbox indent="1" key="doubleCoins" dependencies="comboLike"></checkbox><category icon="touch">触摸优化</category><checkbox indent="0" key="touchNavBar" dependencies=""></checkbox><checkbox indent="0" key="touchVideoPlayer" dependencies=""></checkbox><checkbox indent="1" key="touchVideoPlayerAnimation" dependencies="touchVideoPlayer"></checkbox><checkbox indent="1" key="touchVideoPlayerDoubleTapControl" dependencies="touchVideoPlayer"></checkbox><category icon="other">其他</category><checkbox indent="0" key="toast" dependencies=""></checkbox><checkbox indent="1" key="toastInternalError" dependencies="toast"></checkbox><checkbox indent="0" key="useCache" dependencies=""></checkbox></ul></div></div>
|
||||
<div class="gui-settings-mask"></div><div class="gui-settings-widgets-box icons-enabled"><div class="gui-settings-header"><i class="icon-widgets"></i><span class="gui-settings-title">附加功能</span></div><div class="widgets-container"></div></div><div class="gui-settings-box icons-enabled"><div class="gui-settings-header"><i class="icon-settings"></i><span class="gui-settings-title">设置</span></div><div class="gui-settings-content"><ul><category icon="video">视频与直播</category><dropdown indent="0" key="defaultPlayerMode" dependencies=""></dropdown><checkbox indent="0" key="useDefaultVideoQuality" dependencies=""></checkbox><dropdown indent="1" key="defaultVideoQuality" dependencies="useDefaultVideoQuality"></dropdown><checkbox indent="0" key="autoLightOff" dependencies=""></checkbox><checkbox indent="0" key="expandDanmakuList" dependencies=""></checkbox><checkbox indent="0" key="harunaScale" dependencies=""></checkbox><checkbox indent="0" key="removeLiveWatermark" dependencies=""></checkbox><checkbox indent="0" key="removeVideoTopMask" dependencies=""></checkbox><checkbox indent="0" key="blurVideoControl" dependencies=""></checkbox><checkbox indent="0" key="customControlBackground" dependencies=""></checkbox><textbox indent="1" key="customControlBackgroundOpacity" dependencies="customControlBackground"></textbox><category icon="style">样式</category><li class="indent-0"><label class="gui-settings-textbox-container"><span>主题颜色</span><div class="custom-color-preview"><div class="predefined-colors popup"><div class="predefined-colors-grid"></div></div></div><input key="customStyleColor" dependencies="" spellcheck="false" type="text"/></label></li><checkbox indent="0" key="useNewStyle" dependencies=""></checkbox><textbox indent="1" key="blurBackgroundOpacity" dependencies="useNewStyle"></textbox><checkbox indent="0" key="useDarkStyle" dependencies=""></checkbox><checkbox indent="0" key="darkSchedule" dependencies=""></checkbox><textbox indent="1" key="darkScheduleStart" dependencies="darkSchedule"></textbox><textbox indent="1" key="darkScheduleEnd" dependencies="darkSchedule"></textbox><checkbox indent="0" key="overrideNavBar" dependencies=""></checkbox><checkbox indent="1" key="showBanner" dependencies="overrideNavBar"></checkbox><checkbox indent="1" key="preserveRank" dependencies="overrideNavBar"></checkbox><checkbox indent="0" key="forceWide" dependencies=""></checkbox><textbox indent="1" key="forceWideMinWidth" dependencies="forceWide"></textbox><category icon="tool">工具</category><checkbox indent="0" key="removeAds" dependencies=""></checkbox><checkbox indent="0" key="watchLaterRedirect" dependencies=""></checkbox><checkbox indent="0" key="hideTopSearch" dependencies=""></checkbox><checkbox indent="0" key="fullTweetsTitle" dependencies=""></checkbox><checkbox indent="0" key="comboLike" dependencies=""></checkbox><checkbox indent="1" key="doubleCoins" dependencies="comboLike"></checkbox><category icon="touch">触摸优化</category><checkbox indent="0" key="touchNavBar" dependencies=""></checkbox><checkbox indent="0" key="touchVideoPlayer" dependencies=""></checkbox><checkbox indent="1" key="touchVideoPlayerAnimation" dependencies="touchVideoPlayer"></checkbox><checkbox indent="1" key="touchVideoPlayerDoubleTapControl" dependencies="touchVideoPlayer"></checkbox><category icon="other">其他</category><checkbox indent="0" key="toast" dependencies=""></checkbox><checkbox indent="1" key="toastInternalError" dependencies="toast"></checkbox><checkbox indent="0" key="useCache" dependencies=""></checkbox></ul></div></div>
|
||||
2
min/icons.min.css
vendored
2
min/icons.min.css
vendored
File diff suppressed because one or more lines are too long
@ -17,7 +17,6 @@
|
||||
<dropdown indent="0" key="defaultPlayerMode" dependencies=""></dropdown>
|
||||
<checkbox indent="0" key="useDefaultVideoQuality" dependencies=""></checkbox>
|
||||
<dropdown indent="1" key="defaultVideoQuality" dependencies="useDefaultVideoQuality"></dropdown>
|
||||
<checkbox indent="0" key="downloadDanmaku" dependencies=""></checkbox>
|
||||
<checkbox indent="0" key="autoLightOff" dependencies=""></checkbox>
|
||||
<checkbox indent="0" key="expandDanmakuList" dependencies=""></checkbox>
|
||||
<checkbox indent="0" key="harunaScale" dependencies=""></checkbox>
|
||||
|
||||
@ -79,4 +79,8 @@
|
||||
.icons-enabled .icon-like::after
|
||||
{
|
||||
background-image: url('data:image/svg+xml;utf-8,<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24"><path fill="black" d="M20.9,11.2c0-0.9-0.7-1.6-1.6-1.6h-5.1l0.8-3.7c0-0.1,0-0.2,0-0.3c0-0.3-0.1-0.6-0.4-0.9l-0.9-0.9L8.4,9.2 c-0.3,0.3-0.5,0.7-0.5,1.2v8.1c0,0.9,0.7,1.6,1.6,1.6h7.3c0.7,0,1.2-0.4,1.5-1l2.4-5.7c0.1-0.2,0.1-0.4,0.1-0.6V11.2 M3.1,20.1h3.2v-9.7H3.1V20.1z"/></svg>');
|
||||
}
|
||||
.icons-enabled .icon-danmaku::after
|
||||
{
|
||||
background-image: url('data:image/svg+xml;utf-8,<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24" height="24" viewBox="0 0 24 24"><path fill="black" d="M20,4H4C2.9,4,2,4.9,2,6v12c0,1.1,0.9,2,2,2h4h5.9H20c1.1,0,2-0.9,2-2V6C22,4.9,21.1,4,20,4z M5,7h8v2H5V7z M7,17H5v-2h2V17z M6.3,13v-2H18v2H6.3z M19,17H9v-2h10V17z M19,9h-4.1V7H19V9z"/></svg>');
|
||||
}
|
||||
@ -1 +1 @@
|
||||
1.6.8
|
||||
1.6.9
|
||||
63
video/download-danmaku.js
Normal file
63
video/download-danmaku.js
Normal file
@ -0,0 +1,63 @@
|
||||
(() =>
|
||||
{
|
||||
return (settings, resources) =>
|
||||
{
|
||||
const DanmakuInfo = resources.attributes.videoInfo.export.DanmakuInfo;
|
||||
async function downloadDanmaku()
|
||||
{
|
||||
const title = document.title.replace("_哔哩哔哩 (゜-゜)つロ 干杯~-bilibili", "");
|
||||
const danmaku = new DanmakuInfo((unsafeWindow || window).cid);
|
||||
await danmaku.fetchInfo();
|
||||
const blob = new Blob([danmaku.rawXML], {
|
||||
type: 'text/plain'
|
||||
});
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = $("#danmaku-link");
|
||||
const oldUrl = link.attr("href");
|
||||
if (oldUrl)
|
||||
{
|
||||
URL.revokeObjectURL(oldUrl);
|
||||
}
|
||||
link.attr("download", `${title}.xml`).attr("href", url).get(0).click();
|
||||
}
|
||||
return {
|
||||
widget: {
|
||||
content: `
|
||||
<button
|
||||
class="gui-settings-flat-button"
|
||||
id="download-danmaku">
|
||||
<i class="icon-danmaku"></i>
|
||||
<span>下载弹幕</span>
|
||||
<a id="danmaku-link" style="display:none"></a>
|
||||
</button>`,
|
||||
condition: async () =>
|
||||
{
|
||||
let aid = (unsafeWindow || window).aid;
|
||||
let cid = (unsafeWindow || window).cid;
|
||||
if (aid === undefined || cid === undefined)
|
||||
{
|
||||
const aidMatch = document.URL.match(/\/av(\d+)/);
|
||||
if (aidMatch && aidMatch[1])
|
||||
{
|
||||
const info = await new VideoInfo(aidMatch[1]).fetchInfo();
|
||||
aid = info.aid;
|
||||
cid = info.cid;
|
||||
}
|
||||
}
|
||||
return cid !== undefined;
|
||||
},
|
||||
success: () =>
|
||||
{
|
||||
const link = document.querySelector("#danmaku-link");
|
||||
$("#download-danmaku").on("click", e =>
|
||||
{
|
||||
if (e.target !== link)
|
||||
{
|
||||
downloadDanmaku();
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
};
|
||||
})();
|
||||
@ -4,7 +4,6 @@
|
||||
{
|
||||
const VideoInfo = resources.attributes.videoInfo.export.VideoInfo;
|
||||
const BangumiInfo = resources.attributes.videoInfo.export.BangumiInfo;
|
||||
const DanmakuInfo = resources.attributes.videoInfo.export.DanmakuInfo;
|
||||
const pageData = {
|
||||
aid: undefined,
|
||||
cid: undefined,
|
||||
@ -217,13 +216,6 @@
|
||||
const [data] = downloadedData;
|
||||
zip.file(`${title}${this.extension()}`, this.makeBlob(data));
|
||||
}
|
||||
|
||||
if (settings.downloadDanmaku)
|
||||
{
|
||||
const danmaku = new DanmakuInfo(pageData.cid);
|
||||
await danmaku.fetchInfo();
|
||||
zip.file(`${title}.xml`, danmaku.rawXML);
|
||||
}
|
||||
const blob = await zip.generateAsync({ type: "blob" });
|
||||
const filename = title + ".zip";
|
||||
return [blob, filename];
|
||||
@ -245,7 +237,7 @@
|
||||
|
||||
let blob = null;
|
||||
let filename = null;
|
||||
if (downloadedData.length === 1 && !settings.downloadDanmaku)
|
||||
if (downloadedData.length === 1)
|
||||
{
|
||||
[blob, filename] = this.downloadSingle(downloadedData);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user