Skip to content

Instantly share code, notes, and snippets.

Block YouTube Ads
  1. Download uBlock Origin for your browser.
    If you have an older browser try v1.26 for compatibility.
  2. add those to My Filters-section, it includes both blocking and hiding rules:
    //*youtube.com*adunit
    //*youtube.com/*event=
    //*youtube.com/*favicon
    //*youtube.com/*log_event
    //*youtube.com/*pagead-id.js
    //*youtube.com/api/stats
    //*youtube.com/ptracking
    //*youtube.com/*/feedback
    //*payments.youtube.com/
    /pagead
    doubleclick.net
    doubleclick.com
    /generate_204
    /error_204
    

    youtube.com##.ytp-ad-progress-list,#player-ads,#merch-shelf,[id*="button"][aria-label*="oin this channel"] youtube.com##+js(json-prune, playerResponse.adPlacements playerResponse.playerAds adPlacements playerAds)

  3. Optionally add this "allow override" rule too.
    It enables the player to keep the last-watch-point, if you'll come back to view the video later.
    @@youtube.com/api/stats/watchtime
    
  4. Optionally add those blocking and hiding rules too.
    It disables and hides the container the chat of live-streams, which is CPU-heavy with a lot of background-requests.
    //*youtube.com/live_chat
    youtube.com##ytd-live-chat-frame
    
  5. Optionally add this blocking rule too.
    Blocking 'Google anti-spam' that uses a lot of CPU-heavy 'EVAL'-operations. Can be safely blocked.
    //*google.*/js/bg/*.js
    
    or be more-specific for just youtube with:
    //*google.*/js/bg/*.js$domain=youtube.com
    
  6. Experimental.
    Optionally add those blocking rule too.
    204 requests are commonly use in all of Google services for online-status check,
    but they also carry a HUGE amount of data back to the server,
    since they carry back the entire set of cookies from the domain, plus some additional request arguments.
    I'm currently checking the effects of blocking those too (looks fine for now).
    //*youtube.com/*/heartbeat
    /generate_204
    /live_204
    


Additional Privacy Tips:

  1. Allow uBlock-Origin to work in Incognito-mode,
    in Chrome check the checkbox of 'Allow in incognito' in chrome://extensions),
    and use browser's Incognito-mode to avoid using your Google credentials.
  2. Use https://youtube-nocookie.com instead of https://youtube.com for reducing "some" amount of cookies.
  3. The rule above are set to use youtube.com,
    copy them, changing every youtube.com to youtube-nocookie.com,
    so you'll enjoy reduced-ads in that domain too.
  4. Use AdGuard-DNS In Your Router:
    Change your DNS-addresses to 176.103.130.130 and 176.103.130.131.
    You'll find the DNS entry in the ISP settings section.
    Don't set those in your PC or phone. You'll loose connectivity to devices on your network.
    This reduce a huge amount of ads (mostly banners, in YouTube too),
    but for video-ads you must use uBlock-origin and the rules above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.