79731384

Date: 2025-08-10 17:04:58
Score: 0.5
Natty:
Report link

I didn’t end up getting this to work reliably via a Chrome extension content script — YouTube seems to check isTrusted on clicks, which makes synthetic extension clicks unreliable.

Instead, I switched to a Tampermonkey userscript, which can run directly in the page context and works fine for automatically skipping ads.

Here’s the script I’m using now:

// ==UserScript==
// @name         AutoSkipYT
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Skips YouTube ads automatically
// @author       jagwired
// @match        *://*.youtube.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const CHECK_INTERVAL = 500; // ms between checks

    function skipAd() {
        const skipButtons = [
            '.ytp-ad-skip-button-modern',
            '.ytp-skip-ad-button',
            'button[aria-label^="Skip ad"]'
        ];

        for (const selector of skipButtons) {
            const button = document.querySelector(selector);
            if (button && button.offsetParent !== null) {
                button.click();
                return;
            }
        }

        // Seek through unskippable ads
        const video = document.querySelector('video');
        if (video && document.querySelector('.ad-showing, .ad-interrupting')) {
            video.currentTime = video.duration - 0.1;
        }
    }

    setInterval(skipAd, CHECK_INTERVAL);
    document.addEventListener('yt-navigate-finish', skipAd);
})();

Notes:

If you still want a Chrome extension version, you’d likely need to inject the script into the page so that clicks are isTrusted. But if you just want it to work, this userscript gets the job done.

Reasons:
  • Blacklisted phrase (1): youtube.com
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: jagwired