Disable Page UpDown Animation

Based on Eink-UpDown by Sonny Zhao. Disable page-turning animations for Chrome globally (applies to (Shift+) Spacebar and PgDown/PgUp keys). Note: If the "Allow access to file URLs" option is enabled in Tampermonkey's Manage Extension settings, it will also work for local PDF reading. However, this script does not affect frames within the browser.

当前为 2025-07-17 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Disable Page UpDown Animation
// @namespace    https://greasyfork.org/users/1111205-geekfox
// @version      1.5
// @description  Based on Eink-UpDown by Sonny Zhao. Disable page-turning animations for Chrome globally (applies to (Shift+) Spacebar and PgDown/PgUp keys). Note: If the "Allow access to file URLs" option is enabled in Tampermonkey's Manage Extension settings, it will also work for local PDF reading. However, this script does not affect frames within the browser.
// @author       GeekFox
// @match        *://*/*
// @grant        none
// @run-at       document-body
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    // 定义不需要执行脚本的网站列表
    const blacklistedSites = ['bilibili.com', 'youtube.com', 'douyin.com'];

    // 获取当前网站的域名
    const hostname = window.location.hostname;

    // 检查当前网站是否在黑名单中
    if (blacklistedSites.some(site => hostname.includes(site))) {
        return; // 如果在黑名单中,则终止脚本
    }

    const scrollRatio = 0.7;

    // 添加全局键盘事件监听器
    document.addEventListener('keydown', function (e) {
        // 检查是否在输入元素中
        const inInput = (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' || e.target.isContentEditable);

        if (!inInput) {
            if (e.code === 'Space') {
                // 使用无动画滚动覆盖CSS平滑设置
                window.scrollBy({
                    top: (e.shiftKey ? -1 : 1) * scrollRatio * window.innerHeight,
                    behavior: 'auto' // 强制无动画滚动
                });
                e.preventDefault();
            } else if (e.code === 'PageDown') {
                window.scrollBy({
                    top: scrollRatio * window.innerHeight,
                    behavior: 'auto'
                });
                e.preventDefault();
            } else if (e.code === 'PageUp') {
                window.scrollBy({
                    top: -scrollRatio * window.innerHeight,
                    behavior: 'auto'
                });
                e.preventDefault();
            }
        }
    }, false);
})();