边缘下滑刷新

山寨自神奇浏览器

目前为 2023-03-31 提交的版本,查看 最新版本

// ==UserScript==
// ==UserScript==
// @name         边缘下滑刷新
// @namespace    https://gf.qytechs.cn/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;
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址