Greasy Fork is available in English.
优化b站视频音量调节在触控板上的体验,触控板上的上下滑动是与鼠标滚轮翻转的,使用此脚本后当你在b站视频全屏时向下滑动将减少音量(默认为增大)
当前为
// ==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 });
})();