|
4 | 4 | // @name:zh-TW 怠惰小説下載器 |
5 | 5 | // @name:ja 怠惰者小説ダウンロードツール |
6 | 6 | // @namespace hoothin |
7 | | -// @version 2.8.3.11 |
| 7 | +// @version 2.8.3.12 |
8 | 8 | // @description Lightweight web scraping script. Fetch and download main textual content from the current page, provide special support for novels |
9 | 9 | // @description:zh-CN 通用网站内容爬虫抓取工具,可批量抓取任意站点的小说、论坛内容等并保存为TXT文档 |
10 | 10 | // @description:zh-TW 通用網站內容爬蟲抓取工具,可批量抓取任意站點的小說、論壇內容等並保存為TXT文檔 |
@@ -246,6 +246,7 @@ if (window.top != window.self) { |
246 | 246 | save:"保存当前", |
247 | 247 | saveAsMd:"存为 Markdown", |
248 | 248 | downThreadNum:"设置同时下载的线程数,负数为单线程下载间隔", |
| 249 | + enableTouch:"在移动端按→↓←↑的方向滑动屏幕画正方形立即开始下载", |
249 | 250 | customTitle:"自定义章节标题,输入内页文字对应选择器", |
250 | 251 | maxDlPerMin:"每分钟最大下载数", |
251 | 252 | reSortDefault:"默认按页面中位置排序章节", |
@@ -293,6 +294,7 @@ if (window.top != window.self) { |
293 | 294 | save:"保存當前", |
294 | 295 | saveAsMd:"存爲 Markdown", |
295 | 296 | downThreadNum:"設置同時下載的綫程數,負數為單線程下載間隔", |
| 297 | + enableTouch:"在行動端按→↓←↑的方向滑動螢幕畫方立即開始下載", |
296 | 298 | customTitle:"自訂章節標題,輸入內頁文字對應選擇器", |
297 | 299 | maxDlPerMin:"每分鐘最大下載數", |
298 | 300 | reSortDefault:"預設依頁面中位置排序章節", |
@@ -354,6 +356,7 @@ if (window.top != window.self) { |
354 | 356 | save: "حفظ", |
355 | 357 | saveAsMd: "Markdown حفظ كـ", |
356 | 358 | downThreadNum: "تعيين عدد الخيوط للتحميل", |
| 359 | + enableTouch:"On the mobile device, slide the screen in the direction of →↓←↑ to draw a square will start downloading immediately", |
357 | 360 | customTitle: "تخصيص عنوان الفصل، إدخال المحدد في الصفحة الداخلية", |
358 | 361 | maxDlPerMin:"الحد الأقصى لعدد التنزيلات في الدقيقة", |
359 | 362 | reSortDefault: "الترتيب الافتراضي حسب الموقع في الصفحة", |
@@ -399,6 +402,7 @@ if (window.top != window.self) { |
399 | 402 | save:"Save", |
400 | 403 | saveAsMd:"Save as Markdown", |
401 | 404 | 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", |
402 | 406 | customTitle: "Customize the chapter title, enter the selector on inner page", |
403 | 407 | maxDlPerMin:"Maximum number of downloads per minute", |
404 | 408 | reSortDefault: "Default sort by position in the page", |
@@ -1859,6 +1863,54 @@ if (window.top != window.self) { |
1859 | 1863 | var downloadSingleShortcut = GM_getValue("downloadSingleShortcut") || {ctrlKey: true, shiftKey: true, altKey: false, metaKey: false, key: 'F9'}; |
1860 | 1864 | var downloadCustomShortcut = GM_getValue("downloadCustomShortcut") || {ctrlKey: true, shiftKey: false, altKey: true, metaKey: false, key: 'F9'}; |
1861 | 1865 |
|
| 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 | + |
1862 | 1914 | if (location.origin + location.pathname == configPage) { |
1863 | 1915 | let exampleNode = document.getElementById("example"); |
1864 | 1916 | if (!exampleNode) return; |
@@ -2033,6 +2085,7 @@ if (window.top != window.self) { |
2033 | 2085 | downloadShortcutInput.addEventListener("keydown", keydonwHandler); |
2034 | 2086 | downloadSingleShortcutInput.addEventListener("keydown", keydonwHandler); |
2035 | 2087 | downloadCustomShortcutInput.addEventListener("keydown", keydonwHandler); |
| 2088 | + let enableTouchInput = createOption(i18n.enableTouch, !!enableTouch, "checkbox"); |
2036 | 2089 |
|
2037 | 2090 | let delSelector = createOption(i18n.del, GM_getValue("selectors") || ""); |
2038 | 2091 | delSelector.setAttribute("placeHolder", ".mask,.ksam"); |
@@ -2082,6 +2135,7 @@ if (window.top != window.self) { |
2082 | 2135 | GM_setValue("contentSort", false); |
2083 | 2136 | } |
2084 | 2137 | GM_setValue("reverse", reverse.checked); |
| 2138 | + GM_setValue("enableTouch", enableTouchInput.checked); |
2085 | 2139 | GM_setValue("retainImage", retainImage.checked); |
2086 | 2140 | GM_setValue("showFilterList", showFilterList.checked); |
2087 | 2141 | GM_setValue("disableNextPage", !nextPage.checked); |
|
0 commit comments