Bye Bye YouTube Ads

Lightest + Fastest YouTube AdBlocker which actually works

ของเมื่อวันที่ 09-05-2025 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey to install this script.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Bye Bye YouTube Ads 
// @version     2.0
// @description Lightest + Fastest YouTube AdBlocker which actually works
// @author      DishantX
// @match       *://www.youtube.com/*
// @exclude     *://www.youtube.com/*/music*
// @exclude     *://music.youtube.com/*
// @exclude     *://m.youtube.com/*
// @icon        https://tenor.com/view/manifest-meditate-pepe-gif-12464108004541162266
// @icon64      https://tenor.com/view/manifest-meditate-pepe-gif-12464108004541162266
// @license            MIT
// @namespace https://greasyfork.org/users/1467023
// ==/UserScript==

(() => {
  'use strict';

  // 1. Inject only ad-overlay CSS (no panel removals).
  const style = document.createElement('style');
  style.textContent = [
    '.ytp-ad-overlay.ytp-overlay-loading',  // in-video overlays
    '.ytp-featured-product'                  // featured product promos
  ].join(',') + ' { display: none !important; }';
  document.head.appendChild(style);

  // 2. Click “Skip Ad” when it appears
  function clickSkip() {
    const btn = document.querySelector('button.ytp-ad-skip-button, button.ytp-ad-skip-button-modern');
    if (btn) btn.click();
    return !!btn;
  }

  // 3. Jump past unskippable ads
  function jumpAd() {
    const v = document.querySelector('video');
    if (v && isFinite(v.duration)) v.currentTime = v.duration;
  }

  // 4. Observe only the player’s 'ad-showing' class
  const player = document.getElementById('movie_player');
  if (player) {
    const obs = new MutationObserver(muts => {
      if (player.classList.contains('ad-showing')) {
        if (!clickSkip()) jumpAd();
      }
    });
    obs.observe(player, { attributes: true, attributeFilter: ['class'] });
  }
})();