Skip to content

Commit bfaf086

Browse files
committed
sideControllerPos
1 parent c80ed60 commit bfaf086

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

Pagetual/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[☯️](https://greasyfork.org/scripts/438684 "Install from greasyfork")東方永頁機 [v.1.9.37.125](https://hoothin.github.io/UserScripts/Pagetual/pagetual.user.js "Latest version")
1+
[☯️](https://greasyfork.org/scripts/438684 "Install from greasyfork")東方永頁機 [v.1.9.37.127](https://hoothin.github.io/UserScripts/Pagetual/pagetual.user.js "Latest version")
22
==
33
*Pagetual - Perpetual pages. Auto loading paginated web pages for 90% of all web sites !*
44

Pagetual/pagetual.user.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// @name:da Pagetual
3232
// @name:fr-CA Pagetual
3333
// @namespace hoothin
34-
// @version 1.9.37.126
34+
// @version 1.9.37.127
3535
// @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.
3636
// @description:zh-CN 终极自动翻页 - 加载并拼接下一分页内容至当前页尾,智能适配任意网页
3737
// @description:zh-TW 終極自動翻頁 - 加載並拼接下一分頁內容至當前頁尾,智能適配任意網頁
@@ -153,7 +153,7 @@
153153
}
154154

155155
const noRuleTest = false;
156-
const lang = navigator.appName === "Netscape" ? navigator.language : navigator.userLanguage;
156+
var langName = navigator.appName === "Netscape" ? navigator.language : navigator.userLanguage;
157157
const langData = [
158158
{
159159
// English translation update by github.com/https433, [email protected].
@@ -4135,6 +4135,7 @@
41354135
});
41364136
var i18nData = langData[0].lang;
41374137
function setLang(la) {
4138+
langName = la;
41384139
for (let i = 0; i < langData.length; i++) {
41394140
let lang = langData[i];
41404141
if (lang && lang.match.indexOf(la) !== -1) {
@@ -4148,7 +4149,7 @@
41484149
}
41494150
}
41504151
}
4151-
setLang(lang);
4152+
setLang(langName);
41524153
var enableDebug = true;
41534154
var _GM_xmlhttpRequest, _GM_registerMenuCommand, _GM_notification, _GM_addStyle, _GM_openInTab, _GM_info, _GM_setClipboard;
41544155
function i18n(name, param) {
@@ -4314,7 +4315,8 @@
43144315
});
43154316
}
43164317
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",
43184320
"https://github.com/hoothin/UserScripts/tree/master/Pagetual",
43194321
"https://hoothin.github.io/UserScripts/Pagetual/"];
43204322
const firstRunPage = "https://pagetual.hoothin.com/firstRun";
@@ -7969,7 +7971,7 @@
79697971
e.stopPropagation();
79707972
}, true);
79717973

7972-
let initX, initY, moving = false;
7974+
let initX, initY, perX, perY, moving = false;
79737975
let removeTimer;
79747976
move.addEventListener("click", e => {
79757977
if (!moving) {
@@ -8013,10 +8015,10 @@
80138015
if (moving) {
80148016
let windowHeight = window.innerHeight || document.documentElement.clientHeight;
80158017
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)`;
80208022
} else if (Math.abs(clientX(e) - initX) + Math.abs(clientY(e) - initY) > 5) {
80218023
moving = true;
80228024
clearTimeout(removeTimer);
@@ -8028,8 +8030,8 @@
80288030
document.removeEventListener("mouseup", mouseUpHandler, true);
80298031
document.removeEventListener("touchmove", mouseMoveHandler, true);
80308032
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)};
80338035
storage.setItem("rulesData", rulesData);
80348036
}
80358037
};
@@ -9565,9 +9567,9 @@
95659567
let rulesExample = document.querySelector("#user-content-rules-example+a,#rules-example>a");
95669568
if (rulesExample) {
95679569
rulesExample.innerText = i18n("rulesExample");
9568-
if (lang == "zh-CN") {
9570+
if (langName == "zh-CN") {
95699571
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") {
95719573
rulesExample.href = rulesExample.href.replace("/en", "");
95729574
}
95739575
}
@@ -10463,6 +10465,9 @@
1046310465
}
1046410466
if (rulesData.lang) {
1046510467
setLang(rulesData.lang);
10468+
if (langName === 'zh-CN') {
10469+
configPage.unshift(cnConfigPage);
10470+
}
1046610471
}
1046710472
if (rulesData.firstRun && storage.supportCrossSave()) {
1046810473
rulesData.firstRun = false;

0 commit comments

Comments
 (0)