SkipTime

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

Advertisement:

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

Advertisement:

// ==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;
      }
    };
  });
})();