Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name YouTube Video Skipper
- // @namespace YouTube_K
- // @version 0.1
- // @description Skip a specific number of minutes in a YouTube video when pressing the "s" key
- // @author _
- // @match https://www.youtube.com/watch?v=*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // Set the number of minutes to skip when pressing "s" key
- const minutesToSkip = 5; // Change this to your desired number of minutes
- // Listen for key press events
- document.addEventListener("keydown", function(event) {
- // Check if the pressed key is "s" key
- if (event.key === "s") {
- // Find the video element
- const videoElement = document.querySelector("video");
- if (videoElement) {
- // Calculate the target time to skip to
- const targetTime = videoElement.currentTime + (minutesToSkip * 60);
- // Set the current time of the video to the target time
- videoElement.currentTime = targetTime;
- // Prevent the default action of the "s" key (e.g., scrolling)
- event.preventDefault();
- }
- }
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement