TikTok Video Seek Control

right arrow key (→) to forward the video 3 seconds and left arrow key (←) to rewind the video 3 seconds

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        TikTok Video Seek Control
// @namespace   Violentmonkey Scripts
// @match       https://www.tiktok.com/*/video/*
// @match       https://www.tiktok.com/
// @grant       none
// @version     1.1
// @author      3xploiton3
// @description right arrow key (→) to forward the video 3 seconds and left arrow key (←) to rewind the video 3 seconds
// @license      MPL-2.0
// ==/UserScript==

(function () {
    'use strict';

    // Fungsi untuk mencari video yang sedang diputar
    function getActiveVideo() {
        // TikTok biasanya hanya menampilkan satu video pada satu waktu
        const videos = document.querySelectorAll('video');
        for (const video of videos) {
            if (!video.paused || video.readyState > 2) {
                return video;
            }
        }
        return null;
    }

    // Tambahkan event listener untuk tombol keyboard
    document.addEventListener('keydown', function (e) {
        const video = getActiveVideo();
        if (!video) return;

        // Panah kanan → untuk maju 3 detik
        if (e.key === 'ArrowRight') {
            video.currentTime += 3;
            e.preventDefault(); // Hindari scroll horizontal
        }

        // Panah kiri ← untuk mundur 3 detik
        else if (e.key === 'ArrowLeft') {
            video.currentTime -= 3;
            e.preventDefault();
        }
    }, true);
})();