// ==UserScript== // @name 边缘下滑刷新 // @namespace https://greasyfork.org/zh-CN/users/954189 // @version 2.6 // @description 山寨自神奇浏览器,效果一般,将就用。 // @author angao // @run-at document-end // @license MIT // @match *://*/* // @downloadURL none // ==/UserScript== (function EdgeSlideRefresh() { let startY = null; let endY = null; const Icon = document.createElement("div"); Icon.className = "Refresh_Icon"; Icon.innerHTML = ` `; Icon.style.display = "none"; Icon.style.width = "42px"; Icon.style.height = "42px"; Icon.style.borderRadius = "50%"; Icon.style.position = "fixed"; Icon.style.left = "50%"; Icon.style.transform = "translate(-50%,0) translateZ(0)"; Icon.style.boxShadow = "0 0 10px rgba(0, 0, 0, 0.1)"; Icon.style.top = "-42px"; Icon.style.alignItems = "center"; Icon.style.justifyContent = "center"; Icon.style.zIndex = "99999999"; Icon.style.backgroundColor = "white"; const svg = Icon.querySelector("svg"); svg.style.width = "28px"; svg.style.height = "28px"; svg.style.margin = "0"; document.body.appendChild(Icon); document.addEventListener("touchstart", (e) => { if (e.touches[0].clientX < window.innerWidth / 15 || e.touches[0].clientX > window.innerWidth / 15 * 14) { startY = e.touches[0].clientY; Icon.style.display = "flex"; } }); document.addEventListener( "touchmove", (e) => { if (startY !== null) { e.preventDefault(); let distance = e.touches[0].clientY - startY; const maxDistance = 110; const slowDownStart = 80; const slowDownRate = 0.2; svg.style.fill = distance < 140 ? "black" : "darkred"; if (distance > slowDownStart) { distance = slowDownStart + (distance - slowDownStart) * slowDownRate; } distance = Math.min(distance, maxDistance); Icon.style.transform = `translate(-50%, ${distance / 1.35}px) rotate(${distance * 2}deg)`; } }, { passive: false } ); document.addEventListener("touchend", (e) => { if (startY !== null) { endY = e.changedTouches[0].clientY; if (endY - startY > 140) { setTimeout(() => location.reload(), 250); } Icon.style.transition = "all 0.5s"; Icon.style.transform = "translate(-50%, -42px)"; setTimeout(() => { Icon.style.transition = ""; svg.style.fill = "black"; Icon.style.display = "none"; }, 200); startY = null; endY = null; } }); })();