SkipTime

Adds a shortcut (CTRL + Arrow Left / Right) with which you can skip time in a video by a custom amount.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         SkipTime
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds a shortcut (CTRL + Arrow Left / Right) with which you can skip time in a video by a custom amount.
// @author       idjawoo
// @match        *://*/*
// @icon         https://cdn.discordapp.com/attachments/816751871896453120/1023498342329757786/unknown.png
// @grant        none
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function () {
  "use strict";

  // Amount of seconds to skip forward- adjust to your liking.
  const skipValue = 88;

  function waitForElm(selector) {
    return new Promise((resolve) => {
      if (document.querySelector(selector)) {
        return resolve(document.querySelector(selector));
      }

      const observer = new MutationObserver((mutations) => {
        if (document.querySelector(selector)) {
          resolve(document.querySelector(selector));
          observer.disconnect();
        }
      });

      observer.observe(document.body, {
        childList: true,
        subtree: true,
      });
    });
  }

  let video = undefined;
  waitForElm("video").then((elm) => {
    video = elm;
    document.onkeydown = function (e) {
      if (e.ctrlKey) {
        if (e.key == "ArrowRight")
          elm.currentTime = elm.currentTime + skipValue;
        if (e.key == "ArrowLeft") elm.currentTime = elm.currentTime - skipValue;
      }
    };
  });
})();