From a006bdaef2173126befc2af8fcf6e04da812d8ba Mon Sep 17 00:00:00 2001 From: Alan Ye Date: Sun, 27 Apr 2025 22:37:57 +0800 Subject: [PATCH] style(active-video-links): obey eslint format --- .../utils/active-video-links/index.ts | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/registry/lib/components/utils/active-video-links/index.ts b/registry/lib/components/utils/active-video-links/index.ts index 5d8bf3cbc..c72cf5f5c 100644 --- a/registry/lib/components/utils/active-video-links/index.ts +++ b/registry/lib/components/utils/active-video-links/index.ts @@ -36,9 +36,13 @@ const processDescLinks = () => { } const walker = document.createTreeWalker(descContainer, NodeFilter.SHOW_TEXT, { acceptNode: node => { - if (node.parentElement?.closest('a')) return NodeFilter.FILTER_REJECT - return webRegex.test(node.textContent || '') ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT - } + if (node.parentElement?.closest('a')) { + return NodeFilter.FILTER_REJECT + } + return webRegex.test(node.textContent || '') + ? NodeFilter.FILTER_ACCEPT + : NodeFilter.FILTER_REJECT + }, }) const textNodes: Text[] = [] let currentNode: Node | null @@ -74,7 +78,9 @@ const processDescLinks = () => { const normalizeNicoDescLinks = () => { const descContainer = document.querySelector('.desc-info-text') - if (!descContainer) return + if (!descContainer) { + return + } const anchors = Array.from(descContainer.querySelectorAll('a')) for (let i = 0; i < anchors.length - 1; i++) { const a1 = anchors[i] @@ -83,9 +89,11 @@ const normalizeNicoDescLinks = () => { const text2 = a2.textContent?.trim() || '' const href2 = a2.getAttribute('href') || '' // first link is base watch URL, second has sm ID text - if (/^(https?:)?\/\/(www\.)?nicovideo\.jp\/watch\/?$/.test(href1) - && /^sm\d+$/.test(text2) - && href2.includes(`/watch/${text2}`)) { + if ( + /^(https?:)?\/\/(www\.)?nicovideo\.jp\/watch\/?$/.test(href1) && + /^sm\d+$/.test(text2) && + href2.includes(`/watch/${text2}`) + ) { const newHref = href2.replace(/^(https?:)?/, '//') const newA = document.createElement('a') newA.href = newHref