diff --git a/423down-vip.js b/423down-vip.js index 63bff84..2674003 100644 --- a/423down-vip.js +++ b/423down-vip.js @@ -8,7 +8,7 @@ // @connect *.nite07.com // @grant GM_xmlhttpRequest // @run-at document-end -// @version 1.0.0 +// @version 1.1.0 // @license MIT // ==/UserScript== @@ -33,22 +33,25 @@ function replaceArticleHTML(articleID) { requestArticleHTML(articleID) .then((html) => { - const articleContainer = document.querySelector( - "div.content > div:first-child", - ); - if (!articleContainer) { + const contentDiv = document.querySelector("div.content"); + if (!contentDiv) { console.warn("[423down-proxy] 未找到正文容器,无法替换 HTML"); return; } - let newDiv = articleContainer.cloneNode(false); - let parentElem = articleContainer.parentElement; - articleContainer.remove(); + // 移除已有的 meta(标题)和 entry(正文),避免重复 + contentDiv + .querySelectorAll("div.meta, div.entry") + .forEach((el) => el.remove()); - newDiv.className = "entry"; - newDiv.style = ""; - newDiv.innerHTML = html; - parentElem.prepend(newDiv); + // 移除第一个子元素(付费墙占位 div,无 class) + const firstChild = contentDiv.firstElementChild; + if (firstChild && firstChild.tagName === "DIV" && !firstChild.className) { + firstChild.remove(); + } + + // 在 content 开头插入服务端返回的完整 HTML(含标题+正文) + contentDiv.insertAdjacentHTML("afterbegin", html); console.info(`[423down-proxy] 已替换文章 ${articleID} 的正文 HTML`); }) .catch((error) => {