Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 兼容新版为可用状态 #60

Open
wants to merge 78 commits into
base: develop
Choose a base branch
from
Open
Changes from 2 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
2eaa327
fix: 改用embyCustomEvent提升性能
chen3861229 May 17, 2024
6a54701
fix: 兼容特殊情况的依赖加载
chen3861229 May 24, 2024
dc5888f
refactor: 抽取dandanplayApi
chen3861229 May 29, 2024
1b9d750
refactor: 提取fontSize计算至循环外
chen3861229 May 29, 2024
3133349
refactor: 细微还原
chen3861229 May 29, 2024
83ac08e
fix: 还原版本判断
chen3861229 Jun 11, 2024
bf401be
feat: 兼容JellyfinWeb
chen3861229 Jun 12, 2024
2c794da
fix: 还原getEmbyItemInfo
chen3861229 Jun 12, 2024
684046a
feat: 兼容JellyfinWeb
chen3861229 Jun 12, 2024
48d445d
fix: 升级内置依赖解决弹幕行高bug
chen3861229 Jun 24, 2024
ab17598
feat: 支持魔改版NativePlayer
chen3861229 Jul 20, 2024
8f278e0
refactor: 规范命名
chen3861229 Jul 20, 2024
ea75168
feat: Emby弹窗界面
ykchenc Jul 23, 2024
7e9e47a
Merge pull request #1 from ykchenc/develop
ykchenc Jul 23, 2024
c1122fd
feat: 新增部分调整项
chen3861229 Jul 24, 2024
a357c76
fix: 修复返回再播放的弹幕按钮消失问题
chen3861229 Jul 29, 2024
e6ce17d
fix: 自动匹配failback一次原标题
chen3861229 Aug 3, 2024
5c29388
feat: 使用emby组件
ykchenc Aug 3, 2024
d2c0fb5
feat: 弹幕设置转移到弹框
ykchenc Aug 4, 2024
3cac64c
Merge branch 'develop' of https://github.com/chen3861229/dd-danmaku i…
ykchenc Aug 4, 2024
c3b1b6b
Merge
ykchenc Aug 4, 2024
fc89438
fix :修正手动匹配弹幕中,媒体名与分集名过长而下拉框溢出问题;加载弹幕按钮改为图标
ykchenc Aug 4, 2024
bb7b027
Merge pull request #2 from ykchenc/develop
ykchenc Aug 4, 2024
4c075e5
fix: 修复弹幕类型过滤
chen3861229 Aug 5, 2024
356c4f8
feat : 弹幕样式偏移秒将滑块改为按钮操作;其他优化
ykchenc Aug 5, 2024
2ec15d1
Merge branch 'develop' of https://github.com/chen3861229/dd-danmaku i…
ykchenc Aug 5, 2024
8011be2
feat: 添加弹幕高度比例
chen3861229 Aug 5, 2024
ff357e3
feat: 添加屏蔽关键词过滤弹幕
ykchenc Aug 5, 2024
d2d509e
Merge branch 'develop' of https://github.com/chen3861229/dd-danmaku i…
ykchenc Aug 5, 2024
8b60935
merge
ykchenc Aug 5, 2024
7ff25cb
feat:弹幕屏蔽关键字适配正则表达式;部分设置位置调整
ykchenc Aug 5, 2024
9f11499
fix: 弹幕屏蔽关键字‘启用’按钮默认值错误问题
ykchenc Aug 5, 2024
3342f4b
feat :添加暂停播放时暂停弹幕。
ykchenc Aug 6, 2024
775341d
feat: 添加弹幕来源显示和过滤
chen3861229 Aug 6, 2024
384a1c4
feat: 添加作品图片信息
chen3861229 Aug 7, 2024
6f22e12
feat: 优化代码
ykchenc Aug 7, 2024
1f38564
refator: 移除过时的Jellyfin兼容实现
chen3861229 Aug 8, 2024
8d49872
feat: 屏蔽关键字“启用”按钮问题修正
ykchenc Aug 8, 2024
a8e639b
refator: 修复一处失误
chen3861229 Aug 8, 2024
cd003d4
Merge branch 'develop' of https://github.com/chen3861229/dd-danmaku i…
ykchenc Aug 8, 2024
70b02ed
refator: 修复几处错误
ykchenc Aug 8, 2024
ec98767
feat: 添屏蔽关键词添加来源信息支持
chen3861229 Aug 8, 2024
778b54c
feat: 屏蔽关键词添加一个特定单行注释的兼容
chen3861229 Aug 8, 2024
3774f73
feat: 添加图标列表tab
ykchenc Aug 8, 2024
85a71cf
Merge branch 'develop' of https://github.com/chen3861229/dd-danmaku i…
ykchenc Aug 8, 2024
1b6893b
refator: icon列表tab优化
ykchenc Aug 8, 2024
b5c7b09
refator: 少量重构
chen3861229 Aug 8, 2024
684e69c
refator: icon列表tab优化
ykchenc Aug 8, 2024
0b5c0d4
feat: 弹窗菜单移至header,调低footer高度
ykchenc Aug 8, 2024
2772847
feat: 添加简单弹幕列表
chen3861229 Aug 8, 2024
1a20f27
fix: 降低一处es语法
chen3861229 Aug 8, 2024
823bc6f
feat: 所有图标使用md icon key,去除btns菜单tab
ykchenc Aug 9, 2024
0ea5ba2
Merge branch 'develop' of https://github.com/chen3861229/dd-danmaku i…
ykchenc Aug 9, 2024
cf3dadc
fix: electron中forward_media图标不存在问题解决
ykchenc Aug 9, 2024
38f2bb2
feat: 添加简版设置手动备份
chen3861229 Aug 9, 2024
baa986e
feat: 添加关闭弹窗方法,优化样式
ykchenc Aug 9, 2024
dbb88b9
fix: 修复弹幕列表隐藏状态
chen3861229 Aug 10, 2024
d343198
fix: 修正按原标题重试
chen3861229 Aug 10, 2024
549aeb6
feat: 新UI添加AppLogAspect展示日志
chen3861229 Aug 11, 2024
525f439
feat: 手动匹配添加一个原标题切换
chen3861229 Aug 11, 2024
d350007
refator: 调整样式
ykchenc Aug 12, 2024
c008cf2
fix: 控制台日志添加开关
chen3861229 Aug 12, 2024
cd3bdbc
feat: 控制器在input框文本边界再输入左右越界时切换元素
ykchenc Aug 13, 2024
5a5e2f1
fix: 修复火狐下CustomCssJS的bug
chen3861229 Aug 22, 2024
c48b368
fix: 适配最新安卓客户端
chen3861229 Aug 24, 2024
5a91482
docs: 更新文档
chen3861229 Aug 24, 2024
999fe9d
fix: 合并跨域OPTIONS预检修复
chen3861229 Aug 24, 2024
b508e1e
docs: 更新文档
chen3861229 Aug 24, 2024
ac7c9a7
fix: 延迟ApiClient使用
chen3861229 Aug 25, 2024
0499b9b
fix: 延迟ApiClient使用
chen3861229 Aug 25, 2024
6754bcf
docs: 更新文档
chen3861229 Aug 25, 2024
1370528
refator: 优化等待元素渲染,避免无限循环获取元素
ykchenc Aug 26, 2024
ce8bf62
fix: 精确适配器同步间隔
chen3861229 Aug 26, 2024
88e0abf
fix: 精确适配器同步间隔
chen3861229 Aug 26, 2024
b88abbd
refator: 优化滑块组件控制器操作事件
ykchenc Aug 26, 2024
d129d65
fix: 添加一个来源平台枚举
chen3861229 Aug 26, 2024
dfe7ba1
fix: 添加一个来源平台枚举
chen3861229 Aug 26, 2024
af4c9e8
Merge pull request #3 from chen3861229/develop
ykchenc Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
227 changes: 223 additions & 4 deletions ede.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @description Emby弹幕插件
// @namespace https://github.com/RyoLee
// @author RyoLee
// @version 1.16
// @version 1.17
// @copyright 2022, RyoLee (https://github.com/RyoLee)
// @license MIT; https://raw.githubusercontent.com/RyoLee/emby-danmaku/master/LICENSE
// @icon https://github.githubassets.com/pinned-octocat.svg
Expand Down Expand Up @@ -83,7 +83,8 @@
return;
}
console.log('手动匹配弹幕');
loadDanmaku(LOAD_TYPE.SEARCH);
// loadDanmaku(LOAD_TYPE.SEARCH);
searchEpisodeInfo();
},
};
const translateButtonOpts = {
Expand Down Expand Up @@ -133,6 +134,9 @@
document.querySelector('#filteringDanmaku').children[0].innerText = filter_icons[level];
},
};

// 手动搜索变量
let searchDanmakuOpts = {}
// ------ inner configs end ------

// ------ require start ------
Expand Down Expand Up @@ -328,6 +332,14 @@
// CSS
var x = event.clientX - 36 > 0 ? event.clientX - 36 : 0;
var y = event.clientY - 160 > 0 ? event.clientY - 160 : 0;
// 假如超出屏幕宽度,则将 popDiv 向左移动自身的宽度
// alert(x + ",修复前");
// alert(window.screen.width);
// alert(window.screen.availWidth);
// if (x + 86 > window.screen.availWidth) {
// x -= 86; // 86 is current width of popDiv
// alert(x + ",修复后");
// }

popDiv.startSetter = '1';
popDiv.style.left = x + 'px';
Expand Down Expand Up @@ -817,10 +829,217 @@
return ep_lists_str;
}

function embyAlert({text = "", title = "", timeout = 1000}) {
window.require(['alert']).then((items) => items[0]?.({text, title, timeout}));
async function searchEpisodeInfo() {

let item;
if (isJellyfin) {
item = await fatchEmbyItemInfo(embyItemId);
} else {
item = await getEmbyItemInfo();
if (!item) {
// getEmbyItemInfo from playbackManager null, will next called
return null;
}
}
let _id;
let animeName;
let anime_id = -1;
let episode;
if (item.Type == 'Episode') {
_id = item.SeasonId;
animeName = item.SeriesName;
episode = item.IndexNumber;
let session = item.ParentIndexNumber;
if (session != 1) {
animeName += ' ' + session;
}
} else {
_id = item.Id;
animeName = item.Name;
episode = 'movie';
}
let _id_key = '_anime_id_rel_' + _id;
let _name_key = '_anime_name_rel_' + _id;
let _episode_key = '_episode_id_rel_' + _id + '_' + episode;
if (window.localStorage.getItem(_id_key)) {
anime_id = window.localStorage.getItem(_id_key);
}
if (window.localStorage.getItem(_name_key)) {
animeName = window.localStorage.getItem(_name_key);
}

searchDanmakuOpts = {
_id_key: _id_key,
_name_key: _name_key,
_episode_key: _episode_key,
anime_id: anime_id,
episode: episode,
animes: []
}

let html = `
<div style="text-align: left;">
<label class="inputLabel">标题:</label>
<div style="display: flex;">
<input is="emby-input" id="danmakuSearchName"
class="txtName txtInput-withlockedfield emby-input emby-input-largerfont emby-input-smaller"
value="${animeName}">
<button type="button" class="itemAction paper-icon-button-light" title="搜索" aria-label="搜索" id="danmakuSearchEpisode"><i
class="md-icon autortl">search</i></button>
</div>
<div id="danmakuEpisodeFlag" hidden>
<label class="inputLabel">剧集:</label>
<div class="emby-select-wrapper emby-select-wrapper-smaller" id="danmakuEpisodeDiv"></div>
<label class="inputLabel">集:</label>
<div class="emby-select-wrapper emby-select-wrapper-smaller" id="danmakuEpisodeNumDiv"></div>
</div>
<div>
<label class="inputLabel" id="danmakuRemark"></label>
</div>
</div>
`;
embyAlert("", "搜索弹幕", 0, html);
// setTimeout(() => {
// document.querySelector("#danmakuSearchEpisode").addEventListener("click", doDanmakuSearchEpisode);
// }, 3000);
setButtonEvent();
}


async function doDanmakuSearchEpisode() {
let embySearch = document.querySelector("#danmakuSearchName");
if (!embySearch) {
return;
}
let searchName = embySearch.value
if (searchName == null) {
document.querySelector("#danmakuRemark").innerText = "请填写标题";
} else {
document.querySelector("#danmakuRemark").innerText = "";
}

document.querySelector(".mdl-spinner").classList.remove('hide');
let anime_id = searchDanmakuOpts.anime_id;
let episode = searchDanmakuOpts.episode;

let searchUrl = dandanplayApi + '/search/episodes?anime=' + searchName + '&withRelated=true';

let animaInfo = await fetch(searchUrl, {
method: 'GET',
headers: {
'Accept-Encoding': 'gzip',
Accept: 'application/json',
'User-Agent': navigator.userAgent,
},
})
.then((response) => response.json())
.catch((error) => {
console.log('查询失败:', error);
return null;
});
console.log('查询成功', animaInfo);
document.querySelector(".mdl-spinner").classList.add('hide');
if (!animaInfo || animaInfo.animes.length < 1) {
document.querySelector("#danmakuRemark").innerText = "搜索结果为空";
document.querySelector('[data-id="ok"]').disabled = true;
document.querySelector("#danmakuEpisodeFlag").hidden = true;
return;
} else {
document.querySelector("#danmakuRemark").innerText = "";

}
let danmakuEpisodeDiv = document.querySelector("#danmakuEpisodeDiv")
let danmakuEpisodeNumDiv = document.querySelector("#danmakuEpisodeNumDiv");
danmakuEpisodeDiv.innerHTML = "";
danmakuEpisodeNumDiv.innerHTML = "";
let animes = animaInfo.animes
searchDanmakuOpts.animes = animes

let episodeHtml = `
<select is="emby-select" class="selectSyncTarget emby-select"
style="font-size: inherit;font-family: inherit;font-weight: inherit;padding-top: 0;padding-bottom: 0;box-sizing: border-box;outline: 0 !important;-webkit-tap-highlight-color: transparent;width: auto;border-radius: .3em;letter-spacing: inherit;padding-inline-start: 1ch;padding-inline-end: 3.6ch;height: 2.4em;"
label="剧集:" id="danmakuEpisodeSelect">
`;
let selecAnimeIdx = 0;
for (let index = 0; index < animes.length; index++) {
if (animes[index].animeId == anime_id) {
selecAnimeIdx = index;
episodeHtml += `<option value="${animes[index].animeId}" selected>${animes[index].animeTitle} 类型:${animes[index].typeDescription}</option>`;
} else {
episodeHtml += `<option value="${animes[index].animeId}">${animes[index].animeTitle} 类型:${animes[index].typeDescription}</option>`;
}
}
episodeHtml +=`</select>`;
danmakuEpisodeDiv.innerHTML = episodeHtml;


danmakuEpisodeNumDiv.innerHTML = makeNumHtml(animes[selecAnimeIdx].episodes, episode);
document.querySelector("#danmakuEpisodeFlag").hidden = false
document.querySelector("#danmakuEpisodeSelect").addEventListener("click", onChangeDanmakuEpisode);
document.querySelector('[data-id="ok"]').disabled = false;
}

function makeNumHtml(animesApisodes, episode) {
let numHtml = `
<select is="emby-select" class="selectSyncTarget emby-select"
style="font-size: inherit;font-family: inherit;font-weight: inherit;padding-top: 0;padding-bottom: 0;box-sizing: border-box;outline: 0 !important;-webkit-tap-highlight-color: transparent;width: auto;border-radius: .3em;letter-spacing: inherit;padding-inline-start: 1ch;padding-inline-end: 3.6ch;height: 2.4em;"
label="集数:" id="danmakuEpisodeNumSelect">
`;
for (let index = 0; index < animesApisodes.length; index++) {
if (index == episode) {
numHtml += `<option value="${animesApisodes[index].episodeId}" selected>${animesApisodes[index].episodeTitle}</option>`;
} else {
numHtml += `<option value="${animesApisodes[index].episodeId}">${animesApisodes[index].episodeTitle}</option>`;
}
}
numHtml +=`</select>`;
return numHtml;
}

function onChangeDanmakuEpisode() {
let episodeSelect = document.querySelector("#danmakuEpisodeSelect");
let animes = searchDanmakuOpts.animes;
let idx = episodeSelect.selectedIndex;
let danmakuEpisodeNumDiv = document.querySelector("#danmakuEpisodeNumDiv");
danmakuEpisodeNumDiv.innerHTML = makeNumHtml(animes[idx].episodes, episodeSelect.selectedIndex);
}

function doClickComplete() {
let episodeSelect = document.querySelector("#danmakuEpisodeSelect")
let episodeNumSelect = document.querySelector("#danmakuEpisodeNumSelect")

let episodeInfo = {
episodeId: episodeNumSelect.value,
animeTitle: searchDanmakuOpts.animes[episodeSelect.selectedIndex].animeTitle,
episodeTitle: searchDanmakuOpts.animes[episodeSelect.selectedIndex].type == 'tvseries' ? episodeNumSelect.options[episodeNumSelect.selectedIndex].text: null,
}
window.localStorage.setItem(searchDanmakuOpts._episode_key, JSON.stringify(episodeInfo));

}

function embyAlert(text = "", title = "", timeout = 1000, html = "") {
window.require(['alert']).then((items) => items[0]?.({text, title, timeout, html})).then(() => {
doClickComplete();
});
}

function setButtonEvent() {
const btnElement = document.querySelector("#danmakuSearchEpisode");
const btn2 = document.querySelector('[data-id="ok"]');
if (btnElement && btn2) {
btnElement.addEventListener("click", doDanmakuSearchEpisode);
btn2.innerText = "确定";
btn2.disabled = true;
// console.log('设置事件');
} else {
// console.log('定时事件');
setTimeout(() => {
setButtonEvent();
}, 200);
}
}


function initH5VideoAdapter() {
let _media = document.querySelector(mediaQueryStr);
if (_media) {
Expand Down