diff --git a/CHANGELOG.md b/CHANGELOG.md index ebcfea3c..05cd3c55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 3.7.3 + +- 优化:代码typo更正 + ## 3.7.2 - 新增:直播页 活动直播页自动跳转普通直播 diff --git a/src/filters/commentFilter/pages/dynamic.ts b/src/filters/commentFilter/pages/dynamic.ts index ce9c76cd..13f7f1b9 100644 --- a/src/filters/commentFilter/pages/dynamic.ts +++ b/src/filters/commentFilter/pages/dynamic.ts @@ -157,7 +157,7 @@ if (isPageDynamic()) { check(true) const commentObverser = new MutationObserver(() => { // 增量检测 - check(false) + check(false).then().catch() }) commentObverser.observe(commentListContainer, { childList: true, subtree: true }) } diff --git a/src/filters/commentFilter/pages/video.ts b/src/filters/commentFilter/pages/video.ts index 63123c44..662fd951 100644 --- a/src/filters/commentFilter/pages/video.ts +++ b/src/filters/commentFilter/pages/video.ts @@ -149,12 +149,12 @@ if (isPageVideo() || isPageBangumi() || isPagePlaylist()) { if (usernameAction.status || contentAction.status) { checkCommentList(true) } - const commentObverser = new MutationObserver(() => { + const commentObserver = new MutationObserver(() => { if (usernameAction.status || contentAction.status) { checkCommentList(false) } }) - commentObverser.observe(commentListContainer, { childList: true, subtree: true }) + commentObserver.observe(commentListContainer, { childList: true, subtree: true }) } } diff --git a/src/filters/videoFilter/pages/actions/action.ts b/src/filters/videoFilter/pages/actions/action.ts index 421eae41..da0f8f18 100644 --- a/src/filters/videoFilter/pages/actions/action.ts +++ b/src/filters/videoFilter/pages/actions/action.ts @@ -186,7 +186,6 @@ export class DimensionAction implements VideoFilterAction { /** * 视频横竖屏过滤操作 * @param statusKey 是否启用的GM key - * @param valueKey 存储数据的GM key * @param checkVideoList 检测视频列表函数 */ constructor(statusKey: string, checkVideoList: (fullSite: boolean) => void) { diff --git a/src/filters/videoFilter/pages/channel.ts b/src/filters/videoFilter/pages/channel.ts index bdb24ef1..46768be6 100644 --- a/src/filters/videoFilter/pages/channel.ts +++ b/src/filters/videoFilter/pages/channel.ts @@ -111,7 +111,7 @@ if (isPageChannel()) { 'global-uploader-whitelist-filter-value', checkVideoList, ) - const channelTitleKeyworldWhitelistAction = new TitleKeywordWhitelistAction( + const channelTitleKeywordWhitelistAction = new TitleKeywordWhitelistAction( 'channel-title-keyword-whitelist-filter-status', 'global-title-keyword-whitelist-filter-value', checkVideoList, @@ -132,12 +132,12 @@ if (isPageChannel()) { } if (videoListContainer) { // 初次全站检测 - check(true) - const videoObverser = new MutationObserver(() => { + check(true).then().catch() + const videoObserver = new MutationObserver(() => { // 增量检测 - check(false) + check(false).then().catch() }) - videoObverser.observe(videoListContainer, { childList: true, subtree: true }) + videoObserver.observe(videoListContainer, { childList: true, subtree: true }) debug('watchVideoListContainer OK') } } @@ -208,7 +208,7 @@ if (isPageChannel()) { channelBvidAction.add(bvid) }) menu.registerMenu(`◎ 复制视频链接`, () => { - navigator.clipboard.writeText(`https://www.bilibili.com/video/${bvid}`) + navigator.clipboard.writeText(`https://www.bilibili.com/video/${bvid}`).then().catch() }) menu.show(e.clientX, e.clientY) } @@ -400,13 +400,13 @@ if (isPageChannel()) { }), // 启用 频道页标题关键词白名单 new CheckboxItem({ - itemID: channelTitleKeyworldWhitelistAction.statusKey, + itemID: channelTitleKeywordWhitelistAction.statusKey, description: '启用 标题关键词白名单', itemFunc: () => { - channelTitleKeyworldWhitelistAction.enable() + channelTitleKeywordWhitelistAction.enable() }, callback: () => { - channelTitleKeyworldWhitelistAction.disable() + channelTitleKeywordWhitelistAction.disable() }, }), // 编辑 关键词白名单 @@ -416,7 +416,7 @@ if (isPageChannel()) { name: '编辑', // 按钮功能:显示白名单编辑器 itemFunc: () => { - channelTitleKeyworldWhitelistAction.whitelist.show() + channelTitleKeywordWhitelistAction.whitelist.show() }, }), ] diff --git a/src/filters/videoFilter/pages/homepage.ts b/src/filters/videoFilter/pages/homepage.ts index dbd611bf..d7b64c43 100644 --- a/src/filters/videoFilter/pages/homepage.ts +++ b/src/filters/videoFilter/pages/homepage.ts @@ -144,7 +144,7 @@ if (isPageHomepage()) { 'global-uploader-whitelist-filter-value', checkVideoList, ) - const homepageTitleKeyworldWhitelistAction = new TitleKeywordWhitelistAction( + const homepageTitleKeywordWhitelistAction = new TitleKeywordWhitelistAction( 'homepage-title-keyword-whitelist-filter-status', 'global-title-keyword-whitelist-filter-value', checkVideoList, @@ -165,12 +165,12 @@ if (isPageHomepage()) { } if (videoListContainer) { // 初次全站检测 - check(true) - const videoObverser = new MutationObserver(() => { + check(true).then().catch() + const videoObserver = new MutationObserver(() => { // 增量检测 - check(false) + check(false).then().catch() }) - videoObverser.observe(videoListContainer, { childList: true }) + videoObserver.observe(videoListContainer, { childList: true }) debug('watchVideoListContainer OK') } } @@ -242,7 +242,7 @@ if (isPageHomepage()) { homepageBvidAction.add(bvid) }) menu.registerMenu(`◎ 复制视频链接`, () => { - navigator.clipboard.writeText(`https://www.bilibili.com/video/${bvid}`) + navigator.clipboard.writeText(`https://www.bilibili.com/video/${bvid}`).then().catch() }) menu.show(e.clientX, e.clientY) } @@ -447,13 +447,13 @@ if (isPageHomepage()) { }), // 启用 首页标题关键词白名单 new CheckboxItem({ - itemID: homepageTitleKeyworldWhitelistAction.statusKey, + itemID: homepageTitleKeywordWhitelistAction.statusKey, description: '启用 标题关键词白名单', itemFunc: () => { - homepageTitleKeyworldWhitelistAction.enable() + homepageTitleKeywordWhitelistAction.enable() }, callback: () => { - homepageTitleKeyworldWhitelistAction.disable() + homepageTitleKeywordWhitelistAction.disable() }, }), // 编辑 关键词白名单 @@ -463,7 +463,7 @@ if (isPageHomepage()) { name: '编辑', // 按钮功能:显示白名单编辑器 itemFunc: () => { - homepageTitleKeyworldWhitelistAction.whitelist.show() + homepageTitleKeywordWhitelistAction.whitelist.show() }, }), ] diff --git a/src/filters/videoFilter/pages/popular.ts b/src/filters/videoFilter/pages/popular.ts index 5536c692..978a9572 100644 --- a/src/filters/videoFilter/pages/popular.ts +++ b/src/filters/videoFilter/pages/popular.ts @@ -39,13 +39,12 @@ if (isPagePopular()) { // hook fetch let apiResp: Response | undefined = undefined const origFetch = unsafeWindow.fetch - unsafeWindow.fetch = (input, init?) => { + unsafeWindow.fetch = async (input, init?) => { if (typeof input === 'string' && input.includes('api.bilibili.com') && init?.method?.toUpperCase() === 'GET') { if (input.match(/web-interface\/(ranking|popular\/series\/one|popular\?ps)/)) { - return origFetch(input, init).then((resp: Response) => { - apiResp = resp.clone() - return resp - }) + const resp = await origFetch(input, init) + apiResp = resp.clone() + return resp } } return origFetch(input, init) @@ -242,18 +241,18 @@ if (isPagePopular()) { if (location.pathname.match(/\/v\/popular\/(?:all|rank|weekly)/)) { popularDurationAction.status || popularQualityAction.status || popularDimensionAction.status ? await parseResp() - : parseResp() + : parseResp().then().catch() } checkVideoList(fullSite) } } if (videoListContainer) { - check(true) - const videoObverser = new MutationObserver(async () => { - check(true) + check(true).then().catch() + const videoObserver = new MutationObserver(async () => { + check(true).then().catch() }) - videoObverser.observe(videoListContainer, { childList: true, subtree: true }) + videoObserver.observe(videoListContainer, { childList: true, subtree: true }) debug('watchVideoListContainer OK') } } @@ -265,7 +264,7 @@ if (isPagePopular()) { }).then((ele) => { if (ele) { videoListContainer = ele - watchVideoListContainer() + watchVideoListContainer().then().catch() } }) } catch (err) { diff --git a/src/filters/videoFilter/pages/search.ts b/src/filters/videoFilter/pages/search.ts index 58e49992..ace55f44 100644 --- a/src/filters/videoFilter/pages/search.ts +++ b/src/filters/videoFilter/pages/search.ts @@ -115,7 +115,7 @@ if (isPageSearch()) { 'global-uploader-whitelist-filter-value', checkVideoList, ) - const searchTitleKeyworldWhitelistAction = new TitleKeywordWhitelistAction( + const searchTitleKeywordWhitelistAction = new TitleKeywordWhitelistAction( 'search-title-keyword-whitelist-filter-status', 'global-title-keyword-whitelist-filter-value', checkVideoList, @@ -135,11 +135,11 @@ if (isPageSearch()) { } } if (videoListContainer) { - check(true) - const videoObverser = new MutationObserver(() => { - check(true) + check(true).then().catch() + const videoObserver = new MutationObserver(() => { + check(true).then().catch() }) - videoObverser.observe(videoListContainer, { childList: true, subtree: true }) + videoObserver.observe(videoListContainer, { childList: true, subtree: true }) debug('watchVideoListContainer OK') } } @@ -210,7 +210,7 @@ if (isPageSearch()) { searchBvidAction.add(bvid) }) menu.registerMenu(`◎ 复制视频链接`, () => { - navigator.clipboard.writeText(`https://www.bilibili.com/video/${bvid}`) + navigator.clipboard.writeText(`https://www.bilibili.com/video/${bvid}`).then().catch() }) menu.show(e.clientX, e.clientY) } @@ -397,13 +397,13 @@ if (isPageSearch()) { }, }), new CheckboxItem({ - itemID: searchTitleKeyworldWhitelistAction.statusKey, + itemID: searchTitleKeywordWhitelistAction.statusKey, description: '启用 标题关键词白名单', itemFunc: () => { - searchTitleKeyworldWhitelistAction.enable() + searchTitleKeywordWhitelistAction.enable() }, callback: () => { - searchTitleKeyworldWhitelistAction.disable() + searchTitleKeywordWhitelistAction.disable() }, }), new ButtonItem({ @@ -412,7 +412,7 @@ if (isPageSearch()) { name: '编辑', // 按钮功能:显示白名单编辑器 itemFunc: () => { - searchTitleKeyworldWhitelistAction.whitelist.show() + searchTitleKeywordWhitelistAction.whitelist.show() }, }), ] diff --git a/src/filters/videoFilter/pages/space.ts b/src/filters/videoFilter/pages/space.ts index 52787c60..f5d47ef6 100644 --- a/src/filters/videoFilter/pages/space.ts +++ b/src/filters/videoFilter/pages/space.ts @@ -82,7 +82,7 @@ if (isPageSpace()) { 'global-title-keyword-filter-value', checkVideoList, ) - const spaceTitleKeyworldWhitelistAction = new TitleKeywordWhitelistAction( + const spaceTitleKeywordWhitelistAction = new TitleKeywordWhitelistAction( 'space-title-keyword-whitelist-filter-status', 'global-title-keyword-whitelist-filter-value', checkVideoList, @@ -96,12 +96,12 @@ if (isPageSpace()) { } } if (videoListContainer) { - check(true) - const videoObverser = new MutationObserver(() => { + check(true).then().catch() + const videoObserver = new MutationObserver(() => { // 全量检测 - check(true) + check(true).then().catch() }) - videoObverser.observe(videoListContainer, { childList: true, subtree: true }) + videoObserver.observe(videoListContainer, { childList: true, subtree: true }) debug('watchVideoListContainer OK') } } @@ -147,7 +147,7 @@ if (isPageSpace()) { spaceBvidAction.add(bvid) }) menu.registerMenu(`◎ 复制视频链接`, () => { - navigator.clipboard.writeText(`https://www.bilibili.com/video/${bvid}`) + navigator.clipboard.writeText(`https://www.bilibili.com/video/${bvid}`).then().catch() }) menu.show(e.clientX, e.clientY) } @@ -273,13 +273,13 @@ if (isPageSpace()) { const whitelistItems = [ // 启用 空间页标题关键词白名单 new CheckboxItem({ - itemID: spaceTitleKeyworldWhitelistAction.statusKey, + itemID: spaceTitleKeywordWhitelistAction.statusKey, description: '启用 标题关键词白名单', itemFunc: () => { - spaceTitleKeyworldWhitelistAction.enable() + spaceTitleKeywordWhitelistAction.enable() }, callback: () => { - spaceTitleKeyworldWhitelistAction.disable() + spaceTitleKeywordWhitelistAction.disable() }, }), // 编辑 标题关键词白名单 @@ -288,7 +288,7 @@ if (isPageSpace()) { description: '编辑 标题关键词白名单(支持正则)', name: '编辑', itemFunc: () => { - spaceTitleKeyworldWhitelistAction.whitelist.show() + spaceTitleKeywordWhitelistAction.whitelist.show() }, }), ] diff --git a/src/filters/videoFilter/pages/video.ts b/src/filters/videoFilter/pages/video.ts index 26c1dbe9..99a3113f 100644 --- a/src/filters/videoFilter/pages/video.ts +++ b/src/filters/videoFilter/pages/video.ts @@ -134,12 +134,12 @@ if (isPageVideo() || isPagePlaylist()) { } } if (videoListContainer) { - check(true) - const videoObverser = new MutationObserver(() => { + check(true).then().catch() + const videoObserver = new MutationObserver(() => { // 播放页右栏载入慢, 始终做全站检测 - check(true) + check(true).then().catch() }) - videoObverser.observe(videoListContainer, { childList: true, subtree: true }) + videoObserver.observe(videoListContainer, { childList: true, subtree: true }) debug('watchVideoListContainer OK') } } @@ -249,7 +249,7 @@ if (isPageVideo() || isPagePlaylist()) { const matches = url.match(/space\.bilibili\.com\/\d+/g) matches && menu.registerMenu(`◎ 复制主页链接`, () => { - navigator.clipboard.writeText(`https://${matches[0]}`) + navigator.clipboard.writeText(`https://${matches[0]}`).then().catch() }) } menu.show(e.clientX, e.clientY) @@ -265,7 +265,7 @@ if (isPageVideo() || isPagePlaylist()) { videoBvidAction.add(bvid) }) menu.registerMenu(`◎ 复制视频链接`, () => { - navigator.clipboard.writeText(`https://www.bilibili.com/video/${bvid}`) + navigator.clipboard.writeText(`https://www.bilibili.com/video/${bvid}`).then().catch() }) menu.show(e.clientX, e.clientY) } diff --git a/src/rules/bangumi.ts b/src/rules/bangumi.ts index ea585f61..15397953 100644 --- a/src/rules/bangumi.ts +++ b/src/rules/bangumi.ts @@ -42,7 +42,7 @@ if (isPageBangumi()) { const mainTitle = document.querySelector("[class^='mediainfo_mediaTitle']")?.textContent const subTitle = document.getElementById('player-title')?.textContent const shareText = `《${mainTitle}》${subTitle} \nhttps://www.bilibili.com${location.pathname}` - navigator.clipboard.writeText(shareText) + navigator.clipboard.writeText(shareText).then().catch() }) } else if (counter > 50) { clearInterval(id) diff --git a/src/rules/video.ts b/src/rules/video.ts index 536d5f13..4b8eb69d 100644 --- a/src/rules/video.ts +++ b/src/rules/video.ts @@ -137,7 +137,7 @@ if (isPageVideo() || isPagePlaylist()) { if (params.has('p')) { shareText += `?p=${params.get('p')}` } - navigator.clipboard.writeText(shareText) + navigator.clipboard.writeText(shareText).then().catch() }) clearInterval(id) } else if (counter > 50) { diff --git a/src/utils/tool.ts b/src/utils/tool.ts index e08a8745..6216d3e8 100644 --- a/src/utils/tool.ts +++ b/src/utils/tool.ts @@ -53,12 +53,12 @@ export const waitForEle = async ( return ele } return await new Promise((resolve) => { - const obverser = new MutationObserver((mutationList) => { + const observer = new MutationObserver((mutationList) => { mutationList.forEach((mutation) => { if (mutation.addedNodes) { mutation.addedNodes.forEach((node) => { if (node instanceof HTMLElement && isTargetNode(node)) { - obverser.disconnect() + observer.disconnect() ele = watchEle.querySelector(selector) as HTMLElement | null resolve(ele) } @@ -66,6 +66,6 @@ export const waitForEle = async ( } }) }) - obverser.observe(watchEle, { childList: true, subtree: true }) + observer.observe(watchEle, { childList: true, subtree: true }) }) }