Greasy Fork is available in English.
山寨自神奇浏览器
当前为
// ==UserScript==
// ==UserScript==
// @name 边缘下滑刷新
// @namespace http://greasyfork.icu/zh-CN/users/954189
// @version 1.0
// @description 山寨自神奇浏览器
// @author angao
// @license MIT
// @match https://*/*
// ==/UserScript==
let startY = null;
let endY = null;
let mark = 0;
//记录触摸点的纵坐标
document.addEventListener('touchstart', function(e) {
if (e.touches[0].clientX < 30 || e.touches[0].clientX > window.innerWidth - 30) {
startY = e.touches[0].clientY;
mark = 1;
}
});
//阻止屏幕滑动
document.addEventListener('touchmove', function(e) {
if (mark) {
e.preventDefault();
if (e.touches[0].clientY - startY > 120) {
window.plugins.toast.showShortBottom('松手刷新');
}
}
}, { passive: false });
//记录离开点的纵坐标
document.addEventListener('touchend', function(e) {
if (startY !== null ) {
endY = e.changedTouches[0].clientY;
// 向下滑动超过120像素则刷新
if (endY - startY > 120) {
location.reload();
}
}
// 重置
startY = null;
endY = null;
mark = 0;
});