Skip to content

Commit cb74825

Browse files
committed
Update DownloadAllContent.user.js
1 parent 380c256 commit cb74825

1 file changed

Lines changed: 55 additions & 1 deletion

File tree

DownloadAllContent/DownloadAllContent.user.js

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// @name:zh-TW 怠惰小説下載器
55
// @name:ja 怠惰者小説ダウンロードツール
66
// @namespace hoothin
7-
// @version 2.8.3.11
7+
// @version 2.8.3.12
88
// @description Lightweight web scraping script. Fetch and download main textual content from the current page, provide special support for novels
99
// @description:zh-CN 通用网站内容爬虫抓取工具,可批量抓取任意站点的小说、论坛内容等并保存为TXT文档
1010
// @description:zh-TW 通用網站內容爬蟲抓取工具,可批量抓取任意站點的小說、論壇內容等並保存為TXT文檔
@@ -246,6 +246,7 @@ if (window.top != window.self) {
246246
save:"保存当前",
247247
saveAsMd:"存为 Markdown",
248248
downThreadNum:"设置同时下载的线程数,负数为单线程下载间隔",
249+
enableTouch:"在移动端按→↓←↑的方向滑动屏幕画正方形立即开始下载",
249250
customTitle:"自定义章节标题,输入内页文字对应选择器",
250251
maxDlPerMin:"每分钟最大下载数",
251252
reSortDefault:"默认按页面中位置排序章节",
@@ -293,6 +294,7 @@ if (window.top != window.self) {
293294
save:"保存當前",
294295
saveAsMd:"存爲 Markdown",
295296
downThreadNum:"設置同時下載的綫程數,負數為單線程下載間隔",
297+
enableTouch:"在行動端按→↓←↑的方向滑動螢幕畫方立即開始下載",
296298
customTitle:"自訂章節標題,輸入內頁文字對應選擇器",
297299
maxDlPerMin:"每分鐘最大下載數",
298300
reSortDefault:"預設依頁面中位置排序章節",
@@ -354,6 +356,7 @@ if (window.top != window.self) {
354356
save: "حفظ",
355357
saveAsMd: "Markdown حفظ كـ",
356358
downThreadNum: "تعيين عدد الخيوط للتحميل",
359+
enableTouch:"On the mobile device, slide the screen in the direction of →↓←↑ to draw a square will start downloading immediately",
357360
customTitle: "تخصيص عنوان الفصل، إدخال المحدد في الصفحة الداخلية",
358361
maxDlPerMin:"الحد الأقصى لعدد التنزيلات في الدقيقة",
359362
reSortDefault: "الترتيب الافتراضي حسب الموقع في الصفحة",
@@ -399,6 +402,7 @@ if (window.top != window.self) {
399402
save:"Save",
400403
saveAsMd:"Save as Markdown",
401404
downThreadNum:"Set threadNum for download, negative means interval of single thread",
405+
enableTouch:"On the mobile device, slide the screen in the direction of →↓←↑ to draw a square will start downloading immediately",
402406
customTitle: "Customize the chapter title, enter the selector on inner page",
403407
maxDlPerMin:"Maximum number of downloads per minute",
404408
reSortDefault: "Default sort by position in the page",
@@ -1859,6 +1863,54 @@ if (window.top != window.self) {
18591863
var downloadSingleShortcut = GM_getValue("downloadSingleShortcut") || {ctrlKey: true, shiftKey: true, altKey: false, metaKey: false, key: 'F9'};
18601864
var downloadCustomShortcut = GM_getValue("downloadCustomShortcut") || {ctrlKey: true, shiftKey: false, altKey: true, metaKey: false, key: 'F9'};
18611865

1866+
var enableTouch = GM_getValue("enableTouch");
1867+
if (enableTouch) {
1868+
const minLength = 256, tg = 0.5, atg = 2;
1869+
var lastX, lastY, signs, lastSign;
1870+
function tracer(e) {
1871+
let curX = e.changedTouches[0].clientX, curY = e.changedTouches[0].clientY;
1872+
let distanceX = curX - lastX, distanceY = curY - lastY;
1873+
let distance = distanceX * distanceX + distanceY * distanceY;
1874+
if (distance > minLength) {
1875+
lastX = curX;
1876+
lastY = curY;
1877+
let direction = "";
1878+
let slope = Math.abs(distanceY / distanceX);
1879+
if (slope > atg) {
1880+
if (distanceY > 0) {
1881+
direction = "↓";
1882+
} else {
1883+
direction = "↑";
1884+
}
1885+
} else if (slope < tg) {
1886+
if (distanceX > 0) {
1887+
direction = "→";
1888+
} else {
1889+
direction = "←";
1890+
}
1891+
}
1892+
if (direction && lastSign != direction) {
1893+
signs += direction;
1894+
lastSign = direction;
1895+
}
1896+
}
1897+
}
1898+
document.addEventListener("touchstart", function(e) {
1899+
lastX = e.changedTouches[0].clientX;
1900+
lastY = e.changedTouches[0].clientY;
1901+
lastSign = signs = "";
1902+
document.addEventListener("touchmove", tracer, false);
1903+
}, false);
1904+
document.addEventListener("touchend", function(e) {
1905+
document.removeEventListener("touchmove", tracer, false);
1906+
if (signs == "→↓←↑") {
1907+
e.stopPropagation();
1908+
e.preventDefault();
1909+
fetch(false);
1910+
}
1911+
}, false);
1912+
}
1913+
18621914
if (location.origin + location.pathname == configPage) {
18631915
let exampleNode = document.getElementById("example");
18641916
if (!exampleNode) return;
@@ -2033,6 +2085,7 @@ if (window.top != window.self) {
20332085
downloadShortcutInput.addEventListener("keydown", keydonwHandler);
20342086
downloadSingleShortcutInput.addEventListener("keydown", keydonwHandler);
20352087
downloadCustomShortcutInput.addEventListener("keydown", keydonwHandler);
2088+
let enableTouchInput = createOption(i18n.enableTouch, !!enableTouch, "checkbox");
20362089

20372090
let delSelector = createOption(i18n.del, GM_getValue("selectors") || "");
20382091
delSelector.setAttribute("placeHolder", ".mask,.ksam");
@@ -2082,6 +2135,7 @@ if (window.top != window.self) {
20822135
GM_setValue("contentSort", false);
20832136
}
20842137
GM_setValue("reverse", reverse.checked);
2138+
GM_setValue("enableTouch", enableTouchInput.checked);
20852139
GM_setValue("retainImage", retainImage.checked);
20862140
GM_setValue("showFilterList", showFilterList.checked);
20872141
GM_setValue("disableNextPage", !nextPage.checked);

0 commit comments

Comments
 (0)