mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
feat: add airborne support
This commit is contained in:
parent
48982816b6
commit
5a06427b6f
1
@types/global/index.d.ts
vendored
1
@types/global/index.d.ts
vendored
@ -343,6 +343,7 @@ declare global {
|
||||
autoContinue: boolean,
|
||||
allowJumpContinue: boolean,
|
||||
autoPlay: boolean,
|
||||
airborne: boolean,
|
||||
showDeadVideoTitle: boolean,
|
||||
deadVideoTitleProvider: '稍后再看' | 'BiliPlus',
|
||||
useBiliplusRedirect: boolean,
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
min/airborne.min.js
vendored
Normal file
1
min/airborne.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
(()=>{return(e,i)=>{if(typeof isEmbeddedPlayer!=="undefined"&&isEmbeddedPlayer()){return}function t(e){return e.innerText.search(/\d{1,}[::]\d{2}/)!==-1&&e.childElementCount===0}function n(i){if(e.airborne){airborneDestination=i.innerText.match(/\d{1,}[::]\d{2}/)[0];sep=airborneDestination.includes(":")?":":":";airborneDestination=parseInt(airborneDestination.split(sep)[0])*60+parseInt(airborneDestination.split(sep)[1]);if(0<=airborneDestination<=document.querySelector(".bilibili-player-video video").duration){const e=i.offsetWidth;i.innerHTML="<u>"+i.innerText+"🚁</u>";if(i.style.marginLeft===""){i.style.marginLeft="-"+(i.offsetWidth-e).toString()+"px"}}function t(e){console.log(e);var t=i.offsetLeft;var n=i.offsetTop;var o=i.offsetParent;while(o!==null){t+=o.offsetLeft;n+=o.offsetTop+o.clientTop;o=o.offsetParent}const r=t+i.offsetWidth;const l=n+i.offsetHeight;console.log("horizontal:",t,e.screenX,r);console.log("vertical:",n,e.screenY,l);if(t<=e.clientX&&e.clientX<=r&&n<=e.clientY&&e.clientY<=l&&i.offsetWidth!==0){document.querySelector(".bilibili-player-video video").currentTime=airborneDestination;document.querySelector(".bilibili-player-video video").play()}}document.querySelector(".bilibili-player-video-wrap").addEventListener("click",t);document.querySelector(".bilibili-player-video video").addEventListener("click",t)}}(function e(){SpinQuery.select(()=>document.querySelector(".bilibili-player-video-danmaku")).then(()=>{Observer.childList(".bilibili-player-video-danmaku",e=>{e.forEach(e=>{e.addedNodes.forEach(e=>{if(t(e)){n(e)}Observer.childList(e,e=>{e.forEach(e=>{if(t(e.target)){n(e.target)}})})})})})})})()}})();
|
||||
@ -4,6 +4,7 @@
|
||||
"about.min.js": "FF002C6CBCA0AAAA7CE4414F318A5FCC1788891EB1A2090D8E390D95CC14569E",
|
||||
"activity-apis.min.js": "459D26DB0BB447FEFE6F1842541A119E67C63573A800E56AD7FEC71D20087CEF",
|
||||
"activity-image-saver.min.js": "4117EDC0D59C15461083B2EB56F5061DCABAA5EA9699C438DD0E221FEAAFA8B3",
|
||||
"airborne.min.js": "4E3E5843661F8D4C377E0A4C4BC4F9FCBE0FB2297C4261FE16505176953AA4A7",
|
||||
"aria2-rpc.min.js": "133AE00F1BD5C68E52385D170FA2983A7A82F0326D8C42C4E3CDA14ED4F3626F",
|
||||
"aria2-rpc-profile-item.vue.min.js": "61DCAD1D440E036B89C22E00C51C8357DBB529612CB428D55C3804410D2AD059",
|
||||
"aria2-rpc-profiles.vue.min.js": "CBF3D159566A694BC543EAB5B9E743A13B571743EBDDB8C558AE036483E3AF5A",
|
||||
@ -62,7 +63,7 @@
|
||||
"danmaku-send-bar.min.css": "52149D46CF3A15CF6EB186CB49F298DE18B0723E52D8693228F66099847EDCCB",
|
||||
"danmaku-send-bar.min.js": "7108E72F00C169F26E20409F4AA79F05553310375BABC392EB7E2166224B800A",
|
||||
"dark.min.css": "09BB929B87DA70176FB56A1B012B4DC7BAF50F3FBB1D3345B815E459DBC1B1BE",
|
||||
"dark.user.css": "6F200132828E6BE7D3E4C7341A901D94E23F9EFDD193D3AD4FB0081D2A751072",
|
||||
"dark.user.css": "CFC52BBD88182BE21EDE05D76F55D5A65FC71D79AB71CA3731BE6D153367AE0C",
|
||||
"dark-color-scheme.min.js": "6D353AC738180317ACF9D2E046BFFBA0ACC0FA7A8D22B8E16C51127CDE4FE96B",
|
||||
"dark-important.min.css": "5369385A2C16188FB11E71C4C5B91275646F22F0F09E518E37813CC4FA23A072",
|
||||
"dark-navbar.min.css": "7FAD547E326B768904B3739C978DF86FFDDD5E5064FB8F490710D197CCC3018B",
|
||||
@ -118,7 +119,7 @@
|
||||
"gbk.min.js": "872D7A4562F13A539C4A9AF1825DE89E610C775F1AD026EA6986A80DD74E4B53",
|
||||
"get-number.min.js": "7B81A45D0F7D7F68CC6EDE25E02FCD76F8A05B2CF29274F94A99980BB23D8B76",
|
||||
"gui-settings.min.css": "A282A6720CDCB7E7C909763988BDD39C452C47A626BAC86D7576FA70FB0D6ACD",
|
||||
"gui-settings.min.html": "7492A61262FF58A8704AE4FB419E3068232722D740137BE7E5EE576C3D03C1F1",
|
||||
"gui-settings.min.html": "2F48707A238C6F68FB45B1E13FE3F43B3BA6DB16E1EB9B8D59FF955FEB0AF21F",
|
||||
"gui-settings.min.js": "245A969294CFD6F73C6FE4F249AC9907564FB0C204CA22FD92465E7AD9CC77F7",
|
||||
"haruna-scale.min.js": "FD079C86741F614FD63E733CF9B7B896A7D20110754815A540F3341D4DC252B2",
|
||||
"hide-bangumi-reviews.min.js": "7265C0CE994FDA926355A9A4F9B207E7E68E749D47332F3C537EF93E97927A23",
|
||||
@ -201,8 +202,8 @@
|
||||
"settings-tooltip.ja-JP.min.js": "F19FFF07D588873B8CE89D9FDC66F348C5DA8EA18FA1501EC5BABF5AA95E4D78",
|
||||
"settings-tooltip.loader.min.js": "B3941A6B9A5AC693832EA49015397114DC95137E12E6D1ABC311EFF3A3D6F319",
|
||||
"settings-tooltip.min.css": "0C138D5CF16B9068E73D173D229B2B458C15F50272DA73D6A580921C5A848845",
|
||||
"settings-tooltip.min.js": "E9ABA72B3C29CA850342109E57B055B193F3356DD59876B202E8E908AE6247C9",
|
||||
"settings-tooltip.zh-CN.min.js": "F462822F45041BEA90E598CE06345CAD405D6617036E3FD737BDBD7460FB8524",
|
||||
"settings-tooltip.min.js": "09E2C1C6B2B76C9697DD8B7640D62C49DC88571512761FCEC8697C5BEF4BFC52",
|
||||
"settings-tooltip.zh-CN.min.js": "589ADBD22AC86B5E1CE1D111809FF909341D9985939FF2C79FE5BAD65B42E42C",
|
||||
"show-cover-before-play.min.css": "E4050D66F8014029270CB5A4DEFDE2F847B095BA9ED4274BFED3E131B737B06D",
|
||||
"show-cover-before-play.min.js": "5B32F053E97341C09B7735659A426D6D9DFAF470B4E16FC8E364F77EA4DAE1B6",
|
||||
"show-dead-video-title.min.js": "8D591930421EBA43A1BDF50DC8B645C1BD1A17E109FB1CFBCD6B78E6C74E1D68",
|
||||
|
||||
BIN
min/bundle.zip
BIN
min/bundle.zip
Binary file not shown.
@ -3,7 +3,7 @@
|
||||
@namespace Bilibili-Evolved
|
||||
@homepageURL https://github.com/the1812/Bilibili-Evolved
|
||||
@updateURL https://cdn.jsdelivr.net/gh/the1812/Bilibili-Evolved@preview/min/dark.user.css
|
||||
@version 781.23.0
|
||||
@version 792.99.0
|
||||
@license MIT
|
||||
@author Grant Howard (https://github.com/the1812), Coulomb-G (https://github.com/Coulomb-G)
|
||||
==/UserStyle== */
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
min/settings-tooltip.min.js
vendored
2
min/settings-tooltip.min.js
vendored
File diff suppressed because one or more lines are too long
2
min/settings-tooltip.zh-CN.min.js
vendored
2
min/settings-tooltip.zh-CN.min.js
vendored
File diff suppressed because one or more lines are too long
@ -384,6 +384,12 @@ Resource.manifest = {
|
||||
allowJumpContinue: '允许跨集跳转'
|
||||
}
|
||||
},
|
||||
airborne: {
|
||||
path: 'airborne.min.js',
|
||||
displayNames: {
|
||||
airborne: '启用空降'
|
||||
}
|
||||
},
|
||||
expandDescription: {
|
||||
path: 'expand-description.min.js',
|
||||
style: 'instant',
|
||||
|
||||
@ -100,6 +100,7 @@ export const settings = {
|
||||
useCache: true,
|
||||
autoContinue: false,
|
||||
allowJumpContinue: false,
|
||||
airborne: true,
|
||||
deadVideoTitleProvider: '稍后再看',
|
||||
useBiliplusRedirect: false,
|
||||
biliplusRedirect: false,
|
||||
|
||||
@ -63,6 +63,7 @@
|
||||
<checkbox indent="0" key="expandDescription" dependencies=""></checkbox>
|
||||
<checkbox indent="0" key="autoContinue" dependencies=""></checkbox>
|
||||
<checkbox indent="1" key="allowJumpContinue" dependencies="autoContinue"></checkbox>
|
||||
<checkbox indent="0" key="airborne" dependencies=""></checkbox>
|
||||
<checkbox indent="0" key="skipChargeList" dependencies=""></checkbox>
|
||||
<checkbox indent="0" key="framePlayback" dependencies=""></checkbox>
|
||||
<checkbox indent="0" key="videoScreenshot" dependencies=""></checkbox>
|
||||
|
||||
@ -18,6 +18,7 @@ export const toolTips = {
|
||||
expandDescription: `长的视频简介默认会被折叠, 启用此功能可以强制展开完整的视频简介.`,
|
||||
autoPlay: `进入视频页面时自动开始播放视频.`,
|
||||
autoContinue: `播放视频时如果检测到历史记录信息(<span>上次看到...</span>消息), 则自动跳转到相应的时间播放.`,
|
||||
airborne: `当弹幕出现视频时间点时用🚁标记,点击即可空降到相应时间点.`,
|
||||
skipChargeList: `自动跳过视频结尾的充电鸣谢.`,
|
||||
framePlayback: `在播放器的时间右边增加两个按钮, 用于<span>较</span>精细调整视频时间. 支持键盘快捷键<span>Shift + 左/右方向键</span>. (旧版播放器只能用键盘快捷键, 不会显示按钮)`,
|
||||
playerFocus: `进入视频/番剧页面时, 自动定位到播放器.`,
|
||||
|
||||
@ -18,6 +18,7 @@ export const toolTips = new Map<keyof BilibiliEvolvedSettings, string>([
|
||||
["expandDescription", /*html*/`长的视频简介默认会被折叠, 启用此功能可以强制展开完整的视频简介.`],
|
||||
["autoPlay", /*html*/`进入视频页面时自动开始播放视频.`],
|
||||
["autoContinue", /*html*/`播放视频时如果检测到历史记录信息(<span>上次看到...</span>消息), 则自动跳转到相应的时间播放.`],
|
||||
["airborne", /*html*/`当弹幕出现视频时间点时用🚁标记,点击即可空降到相应时间点.`],
|
||||
["skipChargeList", /*html*/`自动跳过视频结尾的充电鸣谢.`],
|
||||
["framePlayback", /*html*/`在播放器的时间右边增加两个按钮, 用于<span>较</span>精细调整视频时间. 支持键盘快捷键<kbd>Shift</kbd>+<kbd>←</kbd>/<kbd>→</kbd>. (旧版播放器只能用键盘快捷键, 不会显示按钮)`],
|
||||
["playerFocus", /*html*/`进入视频/番剧页面时, 自动定位到播放器.`],
|
||||
|
||||
86
src/video/airborne.js
Normal file
86
src/video/airborne.js
Normal file
@ -0,0 +1,86 @@
|
||||
if (typeof isEmbeddedPlayer !== "undefined" && isEmbeddedPlayer())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
function isAirbornable(danmaku)
|
||||
{
|
||||
return danmaku.innerText.search(/\d{1,}[::]\d{2}/) !== -1 && danmaku.childElementCount === 0; // 无子元素表明没有被检测并加过下划线,防止重复调用陷入死循环
|
||||
}
|
||||
|
||||
function doAirborne(danmaku)
|
||||
{
|
||||
if (settings.airborne)
|
||||
{
|
||||
airborneDestination = danmaku.innerText.match(/\d{1,}[::]\d{2}/)[0];
|
||||
sep = airborneDestination.includes(':') ? ':' : ':';
|
||||
airborneDestination = parseInt(airborneDestination.split(sep)[0]) * 60 + parseInt(airborneDestination.split(sep)[1]);
|
||||
if (0 <= airborneDestination <= document.querySelector('.bilibili-player-video video').duration)
|
||||
{
|
||||
const originalWidth = danmaku.offsetWidth;
|
||||
danmaku.innerHTML = '<u>' + danmaku.innerText + '🚁</u>';
|
||||
// 弹幕离开视频后并不一定会删除该元素,如果不向左移有可能会导致画面最左边弹幕离开的地方有一个 🚁 一直在那里
|
||||
if (danmaku.style.marginLeft === '')
|
||||
{
|
||||
danmaku.style.marginLeft = '-' + (danmaku.offsetWidth - originalWidth).toString() + 'px';
|
||||
}
|
||||
}
|
||||
// const videoWrap = document.querySelector('.bilibili-player-video-wrap');
|
||||
function clickHandler(event)
|
||||
{
|
||||
console.log(event);
|
||||
// 计算弹幕区域
|
||||
var left = danmaku.offsetLeft;
|
||||
var top = danmaku.offsetTop;
|
||||
var offParent = danmaku.offsetParent;
|
||||
while (offParent !== null)
|
||||
{
|
||||
left += offParent.offsetLeft;
|
||||
top += (offParent.offsetTop + offParent.clientTop);
|
||||
offParent = offParent.offsetParent;
|
||||
}
|
||||
const right = left + danmaku.offsetWidth;
|
||||
const bottom = top + danmaku.offsetHeight;
|
||||
console.log('horizontal:',left,event.screenX,right);
|
||||
console.log('vertical:',top,event.screenY,bottom)
|
||||
if (left <= event.clientX &&
|
||||
event.clientX <= right &&
|
||||
top <= event.clientY &&
|
||||
event.clientY <= bottom &&
|
||||
danmaku.offsetWidth !== 0)
|
||||
{
|
||||
document.querySelector('.bilibili-player-video video').currentTime = airborneDestination;
|
||||
document.querySelector('.bilibili-player-video video').play();
|
||||
}
|
||||
}
|
||||
// videoWrap.addEventListener('click', clickHandler);
|
||||
document.querySelector('.bilibili-player-video-wrap').addEventListener('click', clickHandler);
|
||||
document.querySelector('.bilibili-player-video video').addEventListener('click', clickHandler);
|
||||
}
|
||||
}
|
||||
|
||||
(function addDanmakuListener()
|
||||
{
|
||||
SpinQuery.select(() => document.querySelector(".bilibili-player-video-danmaku"))
|
||||
.then(() => {
|
||||
Observer.childList('.bilibili-player-video-danmaku', (records) => {
|
||||
records.forEach((record) => {
|
||||
record.addedNodes.forEach((addedNode) => {
|
||||
if (isAirbornable(addedNode))
|
||||
{
|
||||
doAirborne(addedNode);
|
||||
}
|
||||
// 有可能会出现当前元素在视频里面走完了一次之后不删除更改内容再出现在视频里面的情况,这里保证所有弹幕都能被监听到
|
||||
Observer.childList(addedNode, (records) => {
|
||||
records.forEach((record) => {
|
||||
if (isAirbornable(record.target))
|
||||
{
|
||||
doAirborne(record.target);
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
})
|
||||
})()
|
||||
Loading…
Reference in New Issue
Block a user