Skip to content

Commit

Permalink
Update DownloadAllContent.user.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hoothin committed Feb 26, 2025
1 parent 9ef50ee commit c26e1c5
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions DownloadAllContent/DownloadAllContent.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// @name:zh-TW 怠惰小説下載器
// @name:ja 怠惰者小説ダウンロードツール
// @namespace hoothin
// @version 2.8.3.15
// @version 2.8.3.16
// @description Lightweight web scraping script. Fetch and download main textual content from the current page, provide special support for novels
// @description:zh-CN 通用网站内容爬虫抓取工具,可批量抓取任意站点的小说、论坛内容等并保存为TXT文档
// @description:zh-TW 通用網站內容爬蟲抓取工具,可批量抓取任意站點的小說、論壇內容等並保存為TXT文檔
Expand Down Expand Up @@ -1019,8 +1019,7 @@ if (window.top != window.self) {
console.warn(e);
}
}
var linkIndex = 1;
function packLink(doc, item) {
function packLink(doc, item, curIndex) {
if (customTitle) {
try {
let title = doc.querySelector(customTitle);
Expand All @@ -1032,8 +1031,7 @@ if (window.top != window.self) {
}
}
if (prefix) {
item.innerText = prefix.replace(/\$i/g, linkIndex) + item.innerText;
linkIndex++;
item.innerText = prefix.replace(/\$i/g, ++curIndex) + item.innerText;
}
}
var insertSigns=[];
Expand Down Expand Up @@ -1137,7 +1135,7 @@ if (window.top != window.self) {
} else {
console.log(result.status);
}
packLink(doc, aTag);
packLink(doc, aTag, curIndex);
let validData = processDoc(curIndex, aTag, doc, (result.status>=400?` status: ${result.status} from: ${aTag.href} `:""), validTimes < 5);
if (!validData && validTimes++ < 5) {
downIndex--;
Expand Down Expand Up @@ -1264,7 +1262,7 @@ if (window.top != window.self) {
}
});
}
packLink(doc, aTag);
packLink(doc, aTag, curIndex);
downIndex++;
downNum++;
let validData = processDoc(curIndex, aTag, doc, "", failedTimes < 2);
Expand Down Expand Up @@ -1612,7 +1610,7 @@ if (window.top != window.self) {
}
getContentByLargest();
if (rStr.length < 100) {
let articles = pageData.querySelectorAll("article");
let articles = pageData.querySelectorAll("article,.content,#content");
if (articles && articles.length == 1) {
largestContent = articles[0];
largestNum = largestContent.innerText.length;
Expand Down

0 comments on commit c26e1c5

Please sign in to comment.