Tap to Scroll (Ignore Links)

Tap the top or bottom of the screen to scroll the page up or down, while ignoring taps on links and interactive elements.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Tap to Scroll (Ignore Links)
// @namespace    http://tampermonkey.net/
// @version      2.3
// @description  Tap the top or bottom of the screen to scroll the page up or down, while ignoring taps on links and interactive elements.
// @author       Your Name
// @homepage     https://greasyfork.org/en/scripts/525817
// @match        *://*/*
// @grant        none
// ==/UserScript==
 
(function() {
    'use strict';
 
    // Define the threshold for tap zones (e.g., top 20% and bottom 20% of the screen)
    const tapZoneThreshold = 0.2; // 20% of the screen height
 
    document.addEventListener('click', function(event) {
        // Check if the tap is on an interactive element (e.g., link, button, input)
        // li in freshrss
        const interactiveElements = ['A', 'BUTTON', 'INPUT', 'TEXTAREA', 'SELECT', 'LABEL', 'AUDIO', 'VIDEO', 'LI'];
        if (interactiveElements.includes(event.target.tagName)) {
            return; // Ignore taps on interactive elements
        }
 
        const screenHeight = window.innerHeight;
        const tapY = event.clientY; // Y-coordinate of the tap
 
        // Determine if the tap is in the top or bottom zone
        if (tapY < screenHeight * tapZoneThreshold) {
            // Tap in the top zone: scroll up
            window.scrollBy({ top: -window.innerHeight * 0.8, behavior: 'smooth' });
        } else if (tapY > screenHeight * (1 - tapZoneThreshold)) {
            // Tap in the bottom zone: scroll down
            window.scrollBy({ top: window.innerHeight * 0.8, behavior: 'smooth' });
        }
    });
})();