Skip to content

Instantly share code, notes, and snippets.

@KebabLord
Last active July 13, 2025 15:07
Show Gist options
  • Save KebabLord/0cd4b0391fba147869fbdac10fc31621 to your computer and use it in GitHub Desktop.
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();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment