Skip to content

Commit

Permalink
调整部分代码书写
Browse files Browse the repository at this point in the history
  • Loading branch information
maboloshi committed Feb 14, 2025
1 parent c7d1493 commit 5eb9d4e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions main.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@
const treeWalker = document.createTreeWalker(
rootNode,
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,
{
acceptNode: node =>
node =>
// 跳过忽略的节点
node.matches?.(pageConfig.ignoreSelectors) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
}
node.matches?.(pageConfig.ignoreSelectors)
? NodeFilter.FILTER_REJECT
: NodeFilter.FILTER_ACCEPT,
);

const handleElement = node => {
Expand Down Expand Up @@ -482,7 +482,7 @@
const translatedText = await requestRemoteTranslation(descText);

// 安全创建结果元素
const { name, url } = CONFIG.TRANS_ENGINES[CONFIG.transEngine]
const { name, url } = CONFIG.TRANS_ENGINES[CONFIG.transEngine];
const resultContainer = document.createElement('div');
resultContainer.innerHTML = `
<span style='font-size: small'>
Expand Down Expand Up @@ -643,9 +643,7 @@
if (document.documentElement.lang === "en") {
document.documentElement.lang = CONFIG.LANG;
}
}).observe(document.documentElement, {
attributeFilter: ['lang']
});
}).observe(document.documentElement, { attributeFilter: ['lang'] });

// 监听 Turbo 获取响应之前事件
document.addEventListener('turbo:before-fetch-response', () => {
Expand Down

0 comments on commit 5eb9d4e

Please sign in to comment.