Greasy Fork

Greasy Fork is available in English.

Kick.com Mouse audio controls

Kick.com Mouse audio controls (middle click: mute | scroll: adjust volume)

当前为 2024-11-14 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Kick.com Mouse audio controls
// @namespace    Sky3
// @version      1.0
// @description  Kick.com Mouse audio controls (middle click: mute | scroll: adjust volume)
// @author       Sky3
// @match        https://kick.com/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let prevScrollDate = 0;

    function addHandlers() {
        const videoElement = document.getElementById('video-player');
        videoElement.addEventListener('mousedown', (event) => {
          if (event.button == 1) {
              videoElement.muted = !videoElement.muted;
              event.preventDefault();
              event.stopPropagation();
          }
        });

        videoElement.addEventListener('wheel', (event) => {
            if (videoElement.muted) return;

            event.preventDefault();
            event.stopPropagation();

            const shouldIncrease = event.deltaY < 0;
            const volume = videoElement.volume;

            if ((volume == 0 && !shouldIncrease) || (volume == 1 && shouldIncrease)) return;

            const now = Date.now(), since = now - prevScrollDate
            const step = (shouldIncrease ? 1 : -1) * (since < 50 ? 4 : 1) * .01

            videoElement.volume += step;

            prevScrollDate = now
        });
    }

    setTimeout(() => {
        addHandlers();
    }, 2000);
})();