Greasy Fork

Greasy Fork is available in English.

哔哩哔哩反转触控板

优化b站视频音量调节在触控板上的体验,触控板上的上下滑动是与鼠标滚轮翻转的,使用此脚本后当你在b站视频全屏时向下滑动将减少音量(默认为增大)

当前为 2023-03-10 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name       哔哩哔哩反转触控板
// @namespace  http://zhangmaimai.com/
// @version    2.0.1
// @author     MaxChang3
// @license    MIT
// @icon       https://www.bilibili.com/favicon.ico
// @match      https://www.bilibili.com/bangumi/play/*
// @match      https://www.bilibili.com/video/*
// @run-at     document-start
// @description 优化b站视频音量调节在触控板上的体验,触控板上的上下滑动是与鼠标滚轮翻转的,使用此脚本后当你在b站视频全屏时向下滑动将减少音量(默认为增大)
// ==/UserScript==

(function() {
  "use strict";
  const isFullScreen = () => !!document.fullscreenElement;
  const isTrackpad = (wheelEvent) => wheelEvent.deltaY && Math.abs(wheelEvent.deltaY) < 100;
  const player = document.querySelector("#playerWrap");
  if (player === null)
    throw new Error("Can not detect player");
  const orgin = EventTarget.prototype.addEventListener;
  const applyHandler = (target, thisArg, args) => {
    const [type, evt, ...rest] = args;
    if (thisArg instanceof HTMLElement || !(evt instanceof Function) || type !== "mousewheel" && type !== "wheel")
      return Reflect.apply(target, thisArg, args);
    const evtWrapper = (e) => {
      if (!isFullScreen() || !isTrackpad(e))
        return Reflect.apply(evt, thisArg, [e]);
      const proxy = new Proxy(e, {
        get: (obj, prop) => typeof prop === "symbol" || prop !== "wheelDelta" ? Reflect.get(obj, prop) : Reflect.get(obj, "deltaY") * 10
        // Considering that `wheelDelta` is deprecated
      });
      return Reflect.apply(evt, thisArg, [proxy]);
    };
    return Reflect.apply(target, thisArg, [type, evtWrapper, ...rest]);
  };
  EventTarget.prototype.addEventListener = new Proxy(orgin, { apply: applyHandler });
})();