Advertisement
yy981

YouTube強制早送り(tampermonkey)

Jun 30th, 2024 (edited)
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         YouTube Video Skipper
  3. // @namespace    YouTube_K
  4. // @version      0.1
  5. // @description  Skip a specific number of minutes in a YouTube video when pressing the "s" key
  6. // @author       _
  7. // @match        https://www.youtube.com/watch?v=*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.     'use strict';
  13.  
  14.     // Set the number of minutes to skip when pressing "s" key
  15.     const minutesToSkip = 5; // Change this to your desired number of minutes
  16.  
  17.     // Listen for key press events
  18.     document.addEventListener("keydown", function(event) {
  19.         // Check if the pressed key is "s" key
  20.         if (event.key === "s") {
  21.             // Find the video element
  22.             const videoElement = document.querySelector("video");
  23.  
  24.             if (videoElement) {
  25.                 // Calculate the target time to skip to
  26.                 const targetTime = videoElement.currentTime + (minutesToSkip * 60);
  27.  
  28.                 // Set the current time of the video to the target time
  29.                 videoElement.currentTime = targetTime;
  30.  
  31.                 // Prevent the default action of the "s" key (e.g., scrolling)
  32.                 event.preventDefault();
  33.             }
  34.         }
  35.     });
  36. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement