Greasy Fork

Greasy Fork is available in English.

Kick Hotkey Video Control

Userscript that enables pause, forward and backwards movement using the keyboard for kick.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Kick Hotkey Video Control
// @description Userscript that enables pause, forward and backwards movement using the keyboard for kick.
// @version     1
// @grant       none
// @author      elttil(Anton Kling)
// @license     WTFPL
// @include     https://kick.com/*
// @namespace http://greasyfork.icu/users/1039232
// ==/UserScript==

(function() {
    KeyEvent = (typeof KeyEvent === "object") ? KeyEvent : [];
    const LEFT_KEY = KeyEvent.DOM_VK_LEFT || 37;
    const RIGHT_KEY = KeyEvent.DOM_VK_RIGHT || 39;

    window.addEventListener("keydown", keyboardHandler, false);

    function keyboardHandler(zEvent) {
        if (zEvent.altKey || zEvent.ctrlKey || zEvent.shiftKey)
            return;

        // Make sure that the chat is not in focus
        if (document.activeElement.id === "message-input")
            return;

        live_display = document.getElementsByClassName("vjs-live-display");
        if (live_display.length == 0)
            return;

        var is_live = false;
        if (live_display[0].innerText == "LIVE") {
            is_live = true;
        }

        var possible_video = document.getElementsByClassName("vjs-tech");
        if (possible_video.length == 0)
            return;
        if (possible_video[0].nodeName != "VIDEO")
            return;
        video = possible_video[0];

        switch (zEvent.which) {
            case LEFT_KEY:
                if (is_live)
                    return;
                video.currentTime -= 5;
                break;
            case RIGHT_KEY:
                if (is_live)
                    return;
                video.currentTime += 5;
                break;
            case 32:
                if (video.paused)
                    video.play();
                else
                    video.pause();
                break;
            default:
                return;
        }

        zEvent.preventDefault();
        zEvent.stopPropagation();
    }
})();