Skip to content

Commit

Permalink
fix: 插件相关
Browse files Browse the repository at this point in the history
修正追番状态总是“未追番”
部分逻辑加载异常
  • Loading branch information
msojocs committed Dec 29, 2023
1 parent 25a1745 commit eb7de7a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## 🐞 修复
- 番剧出差:动态的信息拦截失效
- 港澳台番剧:修复港澳台无法播放
- 番剧:修正追番状态总是“未追番”
- 插件:部分逻辑加载异常

# 🌈 v1.13.0-1 / 2023-12-24

Expand Down
4 changes: 2 additions & 2 deletions extensions/area_unlimit/hook/biliapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ window.log = window.log ||{
targetOnload(window)
}
else {
console.error('页面似乎没有加载完成')
window.onload = targetOnload
log.warn('页面似乎没有加载完成')
window.onload = () => targetOnload(window)
}
})();

Expand Down
5 changes: 3 additions & 2 deletions extensions/area_unlimit/hook/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ class BiliBiliApi {
return HTTP.get(`//${this.server}/pgc/view/web/season?season_id=${season_id}`);
}


getSeasonInfoByEpSsIdOnBangumi(epId, seasonId) {
log.info('get season info: ', epId, seasonId)
const sId = window.epId2seasonId[epId]
Expand Down Expand Up @@ -736,7 +737,7 @@ const uposMap = {
akamai: 'upos-hz-mirrorakam.akamaized.net',
};
const AREA_MARK_CACHE = {}
window.epId2seasonId = window.epId2seasonId || {}

// HOOK
const URL_HOOK = {

Expand Down Expand Up @@ -894,7 +895,7 @@ const URL_HOOK = {
"https://api.bilibili.com/pgc/view/web/season/user/status": async (req) => {
// log.log("解除区域限制")
const resp = JSON.parse(req.responseText)
resp.result && (resp.result.area_limit = 0,resp.result.follow = 0)
resp.result && (resp.result.area_limit = 0)
req.responseText = JSON.stringify(resp)
},
"https://api.bilibili.com/pgc/season/episode/web/info": async (req) => {
Expand Down
21 changes: 7 additions & 14 deletions extensions/area_unlimit/hook/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
// Do something, for example:
console.log('player ROAMING_sendURL: ', e.detail);
document.removeEventListener('ROAMING_sendURL', this)
if (e.detail)
if (e.detail) {
resolve(e.detail)
else
}
else {
reject(e)
}
});
document.dispatchEvent(new CustomEvent('ROAMING_getURL', {
detail: name // Some variable from Gmail.
Expand Down Expand Up @@ -67,16 +69,7 @@
}
}
}
let interval = setInterval(() => {
if (document.readyState === 'complete' || document.readyState === 'interactive') {
// 渲染完成
console.log('[hook]: 渲染完成,直接执行')
// loadAction().then(_ => {})
loadAction().then(_ => {})
clearInterval(interval)
}
else {
console.log('[hook]: 渲染未完成,监听执行', performance, performance.now(), performance.timing.domComplete, new Date(performance.timing.domComplete))
}
}, 500)
// load.js应该直接执行,而不是等待页面加载完成在执行
// 是否在页面加载后执行逻辑,由具体脚本自行决定
loadAction().then(_ => {})
})()
10 changes: 5 additions & 5 deletions extensions/area_unlimit/hook/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let result = ""
if(pacLink.length > 0)
result = biliBridgePc.callNativeSync('config/roamingPAC', pacLink);
if(result === 'error')localStorage.pacLink = ""
console.log("[hook]: player");
log.info("[hook]: player.js");

const sleep = (ms) => {
return new Promise((resolve, reject) => {
Expand All @@ -28,12 +28,12 @@ const sleep = (ms) => {
const BilibiliAPI = {
getEpDetails: (seasonId, epId)=>{
const api = new BiliBiliApi()
return api.getSeasonInfoByEpSsIdOnBangumi(epId || "", seasonId || "")
return api.getSeasonInfoPgcByEpId(seasonId || "", epId || "", UTILS.getAccessToken())
.then(seasonInfo=>{
console.log('seasonInfo: ', seasonInfo)
if(seasonInfo.code !==0)return Promise.reject(seasonInfo)

const ep = seasonInfo.result.main_section.episodes.filter(ep=>ep.ep_id === parseInt(epId))
const ep = seasonInfo.data.modules[0].data.episodes.filter(ep=>ep.ep_id === parseInt(epId))
if(ep.length === 0)return Promise.reject("剧集查找失败, target:", epId)
return Promise.resolve(ep[0])
})
Expand Down Expand Up @@ -360,13 +360,13 @@ const sleep = (ms) => {
})()

window.onload = async ()=>{
console.log("====onload====")
log.info("====plarer===onload====")
let headerLeft = null

for (let i = 0; true; i++) {
headerLeft = document.querySelector("#app > div > div.app_player--header.flex_between.draggable.db_click_max > div.app_player--header-left")
if (headerLeft !== null) break
console.error('头部元素未找到!', i)
log.info('头部元素未找到!', i)
await sleep(1000)
if (i > 20) {
return
Expand Down

0 comments on commit eb7de7a

Please sign in to comment.