|
31 | 31 | // @name:da Pagetual |
32 | 32 | // @name:fr-CA Pagetual |
33 | 33 | // @namespace hoothin |
34 | | -// @version 1.9.37.126 |
| 34 | +// @version 1.9.37.127 |
35 | 35 | // @description Perpetual pages - powerful auto-pager script. Auto fetching next paginated web pages and inserting into current page for infinite scroll. Support thousands of web sites without any rule. |
36 | 36 | // @description:zh-CN 终极自动翻页 - 加载并拼接下一分页内容至当前页尾,智能适配任意网页 |
37 | 37 | // @description:zh-TW 終極自動翻頁 - 加載並拼接下一分頁內容至當前頁尾,智能適配任意網頁 |
|
153 | 153 | } |
154 | 154 |
|
155 | 155 | const noRuleTest = false; |
156 | | - const lang = navigator.appName === "Netscape" ? navigator.language : navigator.userLanguage; |
| 156 | + var langName = navigator.appName === "Netscape" ? navigator.language : navigator.userLanguage; |
157 | 157 | const langData = [ |
158 | 158 | { |
159 | 159 | // English translation update by github.com/https433, [email protected]. |
|
4135 | 4135 | }); |
4136 | 4136 | var i18nData = langData[0].lang; |
4137 | 4137 | function setLang(la) { |
| 4138 | + langName = la; |
4138 | 4139 | for (let i = 0; i < langData.length; i++) { |
4139 | 4140 | let lang = langData[i]; |
4140 | 4141 | if (lang && lang.match.indexOf(la) !== -1) { |
|
4148 | 4149 | } |
4149 | 4150 | } |
4150 | 4151 | } |
4151 | | - setLang(lang); |
| 4152 | + setLang(langName); |
4152 | 4153 | var enableDebug = true; |
4153 | 4154 | var _GM_xmlhttpRequest, _GM_registerMenuCommand, _GM_notification, _GM_addStyle, _GM_openInTab, _GM_info, _GM_setClipboard; |
4154 | 4155 | function i18n(name, param) { |
|
4314 | 4315 | }); |
4315 | 4316 | } |
4316 | 4317 | const isMobile = ('ontouchstart' in document.documentElement && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)); |
4317 | | - const configPage = [`https://pagetual.hoothin.com/${lang === 'zh-CN' ? 'cn/' : ''}rule.html`, |
| 4318 | + const cnConfigPage = "https://pagetual.hoothin.com/cn/rule.html"; |
| 4319 | + const configPage = ["https://pagetual.hoothin.com/rule.html", |
4318 | 4320 | "https://github.com/hoothin/UserScripts/tree/master/Pagetual", |
4319 | 4321 | "https://hoothin.github.io/UserScripts/Pagetual/"]; |
4320 | 4322 | const firstRunPage = "https://pagetual.hoothin.com/firstRun"; |
|
7969 | 7971 | e.stopPropagation(); |
7970 | 7972 | }, true); |
7971 | 7973 |
|
7972 | | - let initX, initY, moving = false; |
| 7974 | + let initX, initY, perX, perY, moving = false; |
7973 | 7975 | let removeTimer; |
7974 | 7976 | move.addEventListener("click", e => { |
7975 | 7977 | if (!moving) { |
|
8013 | 8015 | if (moving) { |
8014 | 8016 | let windowHeight = window.innerHeight || document.documentElement.clientHeight; |
8015 | 8017 | let windowWidth = window.innerWidth || document.documentElement.clientWidth; |
8016 | | - initX = (clientX(e) - 10 + 40) / windowWidth * 100; |
8017 | | - initY = (clientY(e) - 83 + 83) / windowHeight * 100; |
8018 | | - this.frame.style.top = `calc(${initY}% - 83px)`; |
8019 | | - this.frame.style.left = `calc(${initX}% - 40px)`; |
| 8018 | + perX = (clientX(e) - 10 + 40) / windowWidth * 100; |
| 8019 | + perY = (clientY(e) - 83 + 83) / windowHeight * 100; |
| 8020 | + this.frame.style.top = `calc(${perY}% - 83px)`; |
| 8021 | + this.frame.style.left = `calc(${perX}% - 40px)`; |
8020 | 8022 | } else if (Math.abs(clientX(e) - initX) + Math.abs(clientY(e) - initY) > 5) { |
8021 | 8023 | moving = true; |
8022 | 8024 | clearTimeout(removeTimer); |
|
8028 | 8030 | document.removeEventListener("mouseup", mouseUpHandler, true); |
8029 | 8031 | document.removeEventListener("touchmove", mouseMoveHandler, true); |
8030 | 8032 | document.removeEventListener("touchend", mouseUpHandler, true); |
8031 | | - if (moving) { |
8032 | | - rulesData.sideControllerPos = {x: parseInt(initX), y: parseInt(initY)}; |
| 8033 | + if (moving && perX && perY && perX > 0 && perX < 100 && perY > 0 && perY < 100) { |
| 8034 | + rulesData.sideControllerPos = {x: parseInt(perX), y: parseInt(perY)}; |
8033 | 8035 | storage.setItem("rulesData", rulesData); |
8034 | 8036 | } |
8035 | 8037 | }; |
|
9565 | 9567 | let rulesExample = document.querySelector("#user-content-rules-example+a,#rules-example>a"); |
9566 | 9568 | if (rulesExample) { |
9567 | 9569 | rulesExample.innerText = i18n("rulesExample"); |
9568 | | - if (lang == "zh-CN") { |
| 9570 | + if (langName == "zh-CN") { |
9569 | 9571 | rulesExample.href = rulesExample.href.replace("en", "cn"); |
9570 | | - } else if (lang == "zh-TW" || lang == "zh-HK") { |
| 9572 | + } else if (langName == "zh-TW" || langName == "zh-HK") { |
9571 | 9573 | rulesExample.href = rulesExample.href.replace("/en", ""); |
9572 | 9574 | } |
9573 | 9575 | } |
|
10463 | 10465 | } |
10464 | 10466 | if (rulesData.lang) { |
10465 | 10467 | setLang(rulesData.lang); |
| 10468 | + if (langName === 'zh-CN') { |
| 10469 | + configPage.unshift(cnConfigPage); |
| 10470 | + } |
10466 | 10471 | } |
10467 | 10472 | if (rulesData.firstRun && storage.supportCrossSave()) { |
10468 | 10473 | rulesData.firstRun = false; |
|
0 commit comments