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.

  1. // ==UserScript==
  2. // @name Disable Page UpDown Animation
  3. // @namespace https://gf.qytechs.cn/users/1111205-geekfox
  4. // @version 1.4
  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.
  6. // @author GeekFox
  7. // @match *://*/*
  8. // @grant none
  9. // @run-at document-body
  10. // @license MIT
  11. // ==/UserScript==
  12. (function () {
  13. 'use strict';
  14.  
  15. // 定义不需要执行脚本的网站列表
  16. const blacklistedSites = ['bilibili.com', 'youtube.com', 'douyin.com'];
  17.  
  18. // 获取当前网站的域名
  19. const hostname = window.location.hostname;
  20.  
  21. // 检查当前网站是否在黑名单中
  22. if (blacklistedSites.some(site => hostname.includes(site))) {
  23. return; // 如果在黑名单中,则终止脚本
  24. }
  25.  
  26. const scrollRatio = 0.7;
  27.  
  28. // 添加全局键盘事件监听器
  29. document.addEventListener('keydown', function (e) {
  30. // 检查是否在输入元素中
  31. const inInput = (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' || e.target.isContentEditable);
  32.  
  33. if (!inInput) {
  34. if (e.code === 'Space') {
  35. // 如果按住Shift键,向上滚动
  36. // 否则,向下滚动
  37. window.scrollBy(0, (e.shiftKey ? -1 : 1) * scrollRatio * window.innerHeight);
  38. e.preventDefault();
  39. } else if (e.code === 'PageDown') {
  40. window.scrollBy(0, scrollRatio * window.innerHeight);
  41. e.preventDefault();
  42. } else if (e.code === 'PageUp') {
  43. window.scrollBy(0, -scrollRatio * window.innerHeight);
  44. e.preventDefault();
  45. }
  46. }
  47. }, false);
  48. })();

QingJ © 2025

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