Skip to content

Instantly share code, notes, and snippets.

@KebabLord
Last active April 18, 2026 18:18
Show Gist options
  • Select an option

  • Save KebabLord/0cd4b0391fba147869fbdac10fc31621 to your computer and use it in GitHub Desktop.

Select an option

Save KebabLord/0cd4b0391fba147869fbdac10fc31621 to your computer and use it in GitHub Desktop.
Fast forward youtube ads to skip them in 0.5 second
// ==UserScript==
// @name YouTube Ads Accelerator
// @namespace https://youtube.com/
// @version 1.1
// @author Kebablord
// @description Speed up YouTube ads by 200x when they appear
// @match https://www.youtube.com/*
// @grant none
// @run-at document-end
// @updateURL https://gist.githubusercontent.com/KebabLord/0cd4b0391fba147869fbdac10fc31621/raw/youtube-ad-accelerator.user.js
// @downloadURL https://gist.githubusercontent.com/KebabLord/0cd4b0391fba147869fbdac10fc31621/raw/youtube-ad-accelerator.user.js
// ==/UserScript==
// Firefox supports unlimited video playback speed while Chromium based browsers support maximum 16
const isFirefox = /firefox/i.test(navigator.userAgent);
const maxRate = isFirefox ? 200 : 16;
(function() {
'use strict';
async function accelerateAdPlayback() {
const isAdVisible = () => {
const el = document.querySelector('div.ytp-ad-player-overlay-layout__ad-info-container');
return el && el.offsetParent !== null;
};
const wait = (ms) => new Promise(resolve => setTimeout(resolve, ms));
const trySpeedUpAd = async () => {
if (!isAdVisible()) return;
const ad = document.querySelectorAll('video.video-stream.html5-main-video')[0];
if (!ad || ad.paused) return;
ad.playbackRate = maxRate;
while (!ad.paused) {
await wait(100);
}
};
setInterval(() => {
trySpeedUpAd();
}, 500);
}
accelerateAdPlayback();
})();
@LuisTorresGonzalez
Copy link
Copy Markdown

LuisTorresGonzalez commented Apr 2, 2026

Hi, Id like to propose a change to autoclick the skip ad button
near line 37 we can do something like

            const skipButtons = [
                '.ytp-ad-skip-button-modern',
                '.ytp-skip-ad-button',
                'button[aria-label^="Skip ad"]'
            ];
            while (!ad.paused) {
                await wait(100);
                for(const selector of skipButtons){
                    const skipAdButton = document.querySelector(selector);
                    if(skipAdButton && skipAdButton.offsetParent !== null){
                        skipAdButton.click();
                    }
                }
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment