Skip to content

Instantly share code, notes, and snippets.

@sacgov
Created February 3, 2026 20:35
Show Gist options
  • Select an option

  • Save sacgov/810d82b88d34379ec23dff66680ad344 to your computer and use it in GitHub Desktop.

Select an option

Save sacgov/810d82b88d34379ec23dff66680ad344 to your computer and use it in GitHub Desktop.
Skip youtube first 20 seconds of every video
// ==UserScript==
// @name YouTube - Skip 20 Seconds at Start
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Automatically skips the first 20 seconds of any YouTube video
// @author You
// @match https://www.youtube.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
let skipped = false;
let interval;
const SECONDS = 20;
function skipIntro() {
// const video = document.querySelector('video.html5-main-video');
const video = document.querySelector("video");
console.log(video);
const moviePlayer = document.getElementById('movie_player');
// Check if video is loaded, not an ad, and not already skipped
if (video && moviePlayer && !skipped) {
// Check if the video is actually playing and not just a buffer
video.currentTime = SECONDS;
skipped = true;
console.log(`Skipped ${SECONDS} seconds of YouTube intro.`);
clearInterval(interval);
}
}
// Reset skip status on new video navigation
window.addEventListener('yt-navigate-finish', () => {
skipped = false;
interval = setInterval(skipIntro, 50);
});
// Check frequently in case of slow loading
interval = setInterval(skipIntro, 50);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment