YouTube is still on a mad rampage against adblockers on PC and has now moved to server-side ads to reduce the effectiveness of adblockers. Just like Twitch did semi-recently. However, everyone's friends over at Ublock have already started working on a fix for the upcoming problem. And thanks to them you can block these new server-side ads in YouTube.

Takeaways:

  1. What You'll Need to Start Blocking Server Side Ads on YouTube.
  2. What are Server-Side Ads on YouTube?

What are Server-Side Ads on YouTube?

Server-side ads are ads that are embedded into the video stream by YouTube’s servers, making them harder to block with standard ad blockers. These ads appear even when traditional ad-blocking extensions are active, as they bypass local ad-blocking mechanisms by integrating ads directly into the content delivery process.

If you’re still seeing ads, it’s likely that YouTube is running an A/B test on your account, experimenting with these server-side ads. The following steps are designed to help you effectively block these ads using advanced filtering techniques in uBlock Origin (uBO).

What You'll Need to Start Blocking Server Side Ads on YouTube.

First, you'll need to make sure you have Ublock Origin installed in your browser. Then you will need to use one of the following code lines. You'll know which ones once you start the steps further down.

Method 1 (Firefox + Chromium)

www.youtube.com##+js(trusted-rpnt, script, (function() {window.ytplayer=, (()=>{let t=document.location.href\,e=[]\,o=!1;const r=Array.prototype.push\,n={apply:(t\,n\,a)=>{a[0]!==window&&"number"==typeof a[0]?.start&&a[0]?.end&&"ssap"===a[0]?.namespace&&(o||0!==a[0]?.start||(e.length=0\,o=!0\,r.call(e\,a[0]))\,0!==a[0]?.start&&r.call(e\,a[0]));return Reflect.apply(t\,n\,a)}};window.Array.prototype.push=new Proxy(window.Array.prototype.push\,n)\,document.addEventListener("DOMContentLoaded"\,(function(){let r=!1;const n=()=>{const t=document.querySelector("video");t&&!r&&e.length>0&&(r=!0\,t.currentTime=Math.ceil(e.at(-1).start/1e3))};n()\,new MutationObserver((()=>{t!==document.location.href?(t=document.location.href\,e=[]\,r=!1\,o=!1\,n()):n()})).observe(document.body\,{childList:!0\,subtree:!0})}))})();(function() {window.ytplayer=, sedCount, 1)
www.youtube.com##+js(nano-stb, [native code], 17000, 0.001)

Method 2 (Firefox + Chromium, breakages: end screen cards are missing)

||www.youtube.com/watch?$doc,replace=/sabr=1(.+?ssapPrerollEnabled)/\$1/s
||www.youtube.com/playlist?$doc,replace=/sabr=1(.+?ssapPrerollEnabled)/\$1/s
www.youtube.com##+js(set, ytcfg.data_.INNERTUBE_CONTEXT.client.visitorData, undefined)

www.youtube.com##+js(trusted-replace-fetch-response, /(%23video%3D1.+muteOnStart"):true/, $1:false, /player?)
www.youtube.com##+js(json-prune-xhr-response, captions.playerCaptionsTracklistRenderer.audioTracks.[].captionsInitialState, , propsToMatch, &captions=0)
www.youtube.com##+js(json-prune-fetch-response, captions.playerCaptionsTracklistRenderer.audioTracks.[].captionsInitialState, , propsToMatch, &captions=0)

!#if cap_html_filtering
www.youtube.com##+js(trusted-rpnt, script, (function serverContract(), '/*start*/(function(){const e={apply:(e,t,o)=>{if(window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id&&window.localStorage?.getItem("yt-player-sticky-caption")?.includes?.("false")&&o&&o[1].includes?.("/youtubei/v1/player?")){o[1]+="&captions=0"}return Reflect.apply(e,t,o)}};window.XMLHttpRequest.prototype.open=new Proxy(window.XMLHttpRequest.prototype.open,e)})();(function(){const e={apply:(e,t,o)=>{if(!window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id||!o[0]||"X-Goog-Visitor-Id"!==o[0]||!o[1])return Reflect.apply(e,t,o)}};window.XMLHttpRequest.prototype.setRequestHeader=new Proxy(window.XMLHttpRequest.prototype.setRequestHeader,e)})();(function(){const e={apply:(e,t,o)=>{try{if(window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id&&o&&o[0].includes?.("videoId")){o[0]=o[0].replace("\"context\"","\"params\":\"YAHIAQE%3D\",\"context\"");o[0]=o[0].replace(/("context".+?"originalUrl":"[^"]+?[\?&]t=)(\d+)([^"]+")/,"\"startTimeSecs\":$2,$1$2$3");}}catch(e){}return Reflect.apply(e,t,o)}};window.XMLHttpRequest.prototype.send=new Proxy(window.XMLHttpRequest.prototype.send,e)})();(function(){const e={construct:(e,t,o)=>{if(window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id){const c=t[0],s=t[1];if("https://www.youtube.com/"!==location.href&&c&&c.includes?.("/youtubei/v1/player?"))try{delete s.headers["X-Goog-Visitor-Id"];if(s&&s.body?.includes("visitorData"))try{t[1].body=t[1].body.replace(/"visitorData":"[^"]+",/,"")}catch(e){};if(t[1].body.includes?.("\"params\":\"")){t[1].body=t[1].body.replace(/("params"):"[^"]+"/,"$1:\"YAHIAQE%3D\"");}else{t[1].body=t[1].body.replace("\"context\"","\"params\":\"YAHIAQE%3D\",\"context\"");}t[1].body=t[1].body.replace(/("referer":"[^"]+)"/,"$1#video=1\"");if(window.localStorage?.getItem("yt-player-sticky-caption")?.includes?.("false")){t[0]+="&captions=0"}}catch(e){}}return Reflect.construct(e,t,o)}};window.Request=new Proxy(window.Request,e)})();document.currentScript.textContent=document.currentScript.textContent.replace(/\/\*start\*\/(.*)\/\*end\*\//g,"");/*end*/(function serverContract()', sedCount, 1)
!#else
www.youtube.com##+js(trusted-rpnt, script, (function() {window.ytplayer=, '/*start*/(function(){const e={apply:(e,t,o)=>{if(window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id&&window.localStorage?.getItem("yt-player-sticky-caption")?.includes?.("false")&&o&&o[1].includes?.("/youtubei/v1/player?")){o[1]+="&captions=0"}return Reflect.apply(e,t,o)}};window.XMLHttpRequest.prototype.open=new Proxy(window.XMLHttpRequest.prototype.open,e)})();(function(){const e={apply:(e,t,o)=>{if(!window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id||!o[0]||"X-Goog-Visitor-Id"!==o[0]||!o[1])return Reflect.apply(e,t,o)}};window.XMLHttpRequest.prototype.setRequestHeader=new Proxy(window.XMLHttpRequest.prototype.setRequestHeader,e)})();(function(){const e={apply:(e,t,o)=>{try{if(window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id&&o&&o[0].includes?.("videoId")){o[0]=o[0].replace("\"context\"","\"params\":\"YAHIAQE%3D\",\"context\"");o[0]=o[0].replace(/("context".+?"originalUrl":"[^"]+?[\?&]t=)(\d+)([^"]+")/,"\"startTimeSecs\":$2,$1$2$3");}}catch(e){}return Reflect.apply(e,t,o)}};window.XMLHttpRequest.prototype.send=new Proxy(window.XMLHttpRequest.prototype.send,e)})();(function(){const e={construct:(e,t,o)=>{if(window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id){const c=t[0],s=t[1];if(c&&c.includes?.("&sabr=1"))try{t[0]=t[0].replace("&sabr=1","")}catch(e){};if("https://www.youtube.com/"!==location.href&&c&&c.includes?.("/youtubei/v1/player?"))try{if(s&&s.body?.includes("visitorData"))try{t[1].body=t[1].body.replace(/"visitorData":"[^"]+",/,"")}catch(e){};if(t[1].body.includes?.("\"params\":\"")){t[1].body=t[1].body.replace(/("params"):"[^"]+"/,"$1:\"YAHIAQE%3D\"");}else{t[1].body=t[1].body.replace("\"context\"","\"params\":\"YAHIAQE%3D\",\"context\"");}t[1].body=t[1].body.replace(/("referer":"[^"]+)"/,"$1#video=1\"");if(window.localStorage?.getItem("yt-player-sticky-caption")?.includes?.("false")){t[0]+="&captions=0"}}catch(e){}}return Reflect.construct(e,t,o)}};window.Request=new Proxy(window.Request,e)})();document.currentScript.textContent=document.currentScript.textContent.replace(/\/\*start\*\/(.*)\/\*end\*\//g,"");/*end*/(function() {window.ytplayer=', sedCount, 1)
!#endif

Method 3 (Firefox + Chromium, breakages: endscreen cards are missing but will appear when refreshing)

||www.youtube.com/watch?$doc,replace=/sabr=1(.+?ssapPrerollEnabled)/\$1/s
||www.youtube.com/playlist?$doc,replace=/sabr=1(.+?ssapPrerollEnabled)/\$1/s
www.youtube.com##+js(set, ytcfg.data_.INNERTUBE_CONTEXT.client.visitorData, undefined)

www.youtube.com##+js(trusted-replace-fetch-response, /(%23video%3D1.+muteOnStart"):true/, $1:false, /player?)
www.youtube.com##+js(json-prune-fetch-response, captions.playerCaptionsTracklistRenderer.audioTracks.[].captionsInitialState, , propsToMatch, &captions=0)

!#if cap_html_filtering
www.youtube.com##+js(trusted-rpnt, script, (function serverContract(), '/*start*/(function(){const e={apply:(e,t,o)=>{if(!window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id||!o[0]||"X-Goog-Visitor-Id"!==o[0]||!o[1])return Reflect.apply(e,t,o)}};window.XMLHttpRequest.prototype.setRequestHeader=new Proxy(window.XMLHttpRequest.prototype.setRequestHeader,e)})();(function(){const e={apply:(e,t,o)=>{try{if(window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id&&o&&o[0].includes?.("videoId")){o[0]=o[0].replace("\"clientName\":\"WEB\"","\"clientName\":\"MWEB\"");o[0]=o[0].replace(/("context".+?"originalUrl":"[^"]+?[\?&]t=)(\d+)([^"]+")/,"\"startTimeSecs\":$2,$1$2$3");}}catch(e){}return Reflect.apply(e,t,o)}};window.XMLHttpRequest.prototype.send=new Proxy(window.XMLHttpRequest.prototype.send,e)})();(function(){const e={construct:(e,t,o)=>{if(window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id){const c=t[0],s=t[1];if("https://www.youtube.com/"!==location.href&&c&&c.includes?.("/youtubei/v1/player?"))try{delete s.headers["X-Goog-Visitor-Id"];if(s&&s.body?.includes("visitorData"))try{t[1].body=t[1].body.replace(/"visitorData":"[^"]+",/,"")}catch(e){};if(t[1].body.includes?.("\"params\":\"")){t[1].body=t[1].body.replace(/("params"):"[^"]+"/,"$1:\"YAHIAQE%3D\"");}else{t[1].body=t[1].body.replace("\"context\"","\"params\":\"YAHIAQE%3D\",\"context\"");}t[1].body=t[1].body.replace(/("referer":"[^"]+)"/,"$1#video=1\"");if(window.localStorage?.getItem("yt-player-sticky-caption")?.includes?.("false")){t[0]+="&captions=0"}}catch(e){}}return Reflect.construct(e,t,o)}};window.Request=new Proxy(window.Request,e)})();document.currentScript.textContent=document.currentScript.textContent.replace(/\/\*start\*\/(.*)\/\*end\*\//g,"");/*end*/(function serverContract()', sedCount, 1)
!#else
www.youtube.com##+js(trusted-rpnt, script, (function() {window.ytplayer=, '/*start*/(function(){const e={apply:(e,t,o)=>{if(!window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id||!o[0]||"X-Goog-Visitor-Id"!==o[0]||!o[1])return Reflect.apply(e,t,o)}};window.XMLHttpRequest.prototype.setRequestHeader=new Proxy(window.XMLHttpRequest.prototype.setRequestHeader,e)})();(function(){const e={apply:(e,t,o)=>{try{if(window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id&&o&&o[0].includes?.("videoId")){o[0]=o[0].replace("\"clientName\":\"WEB\"","\"clientName\":\"MWEB\"");o[0]=o[0].replace(/("context".+?"originalUrl":"[^"]+?[\?&]t=)(\d+)([^"]+")/,"\"startTimeSecs\":$2,$1$2$3");}}catch(e){}return Reflect.apply(e,t,o)}};window.XMLHttpRequest.prototype.send=new Proxy(window.XMLHttpRequest.prototype.send,e)})();(function(){const e={construct:(e,t,o)=>{if(window.yt?.config_?.EXPERIMENT_FLAGS?.html5_enable_ssap_entity_id){const c=t[0],s=t[1];if(c&&c.includes?.("&sabr=1"))try{t[0]=t[0].replace("&sabr=1","")}catch(e){};if("https://www.youtube.com/"!==location.href&&c&&c.includes?.("/youtubei/v1/player?"))try{if(s&&s.body?.includes("visitorData"))try{t[1].body=t[1].body.replace(/"visitorData":"[^"]+",/,"")}catch(e){};if(t[1].body.includes?.("\"params\":\"")){t[1].body=t[1].body.replace(/("params"):"[^"]+"/,"$1:\"YAHIAQE%3D\"");}else{t[1].body=t[1].body.replace("\"context\"","\"params\":\"YAHIAQE%3D\",\"context\"");}t[1].body=t[1].body.replace(/("referer":"[^"]+)"/,"$1#video=1\"");if(window.localStorage?.getItem("yt-player-sticky-caption")?.includes?.("false")){t[0]+="&captions=0"}}catch(e){}}return Reflect.construct(e,t,o)}};window.Request=new Proxy(window.Request,e)})();document.currentScript.textContent=document.currentScript.textContent.replace(/\/\*start\*\/(.*)\/\*end\*\//g,"");/*end*/(function() {window.ytplayer=', sedCount, 1)
!#endif

Step-by-Step Guide to Blocking YouTube Server-Side Ads. DON'T STACK METHODS.

  • Open uBlock Origin and click on the uBlock Origin (uBO) extension icon in your browser. If you don’t see it, you might need to click on the "More" button to find it.
  • Click on the three gear icons (settings cogs) to enter uBO’s settings. This should open a new tab with uBO’s dashboard.
  • In the uBO dashboard, click on the “My filters” tab located at the top of the page. This tab allows you to add custom filter rules to block specific content.
  • Scroll down to the bottom of the page to the lowest line that is free of writing. Paste the code you copied from Method 1 listed above.
  • Check the box labelled “Allow custom filters requiring trust” to enable the use of custom filter rules. If you don't tick this box you'll get error messages.
  • Click on the “Apply Changes” button to save and activate the new filter.

How to Block YouTube Server Side Ads

  • Completely quit your Firefox browser and then re-launch it. This ensures that the new filter is properly applied and starts working immediately.
  • Open YouTube and play a video to test if the ads are now blocked.

If Ads Still Aren't Blocked Do the Following.

If you’re still getting ads after applying the filter from the earlier steps, you'll need to try an alternative method.

Option 1.

  • Go back to the “My filters” tab in uBO and delete the code from Method 1.
  • Return to the experimental filter code page, copy the code from Method 2, and paste it into the “My filters”.
  • Apply the changes, restart your browser, and test YouTube again.

Option 2

  • If Method 1 does not work, remove its code from the “My filters” tab.
  • Copy the code from Method 3, paste it into the “My filters” tab, apply changes, and restart your browser.

Future Updates and Maintenance.

The steps provided involve experimental code that may eventually be integrated into uBlock Origin. Once these features are officially incorporated you will have to manually remove these codes otherwise you will have conflicting issues. However, until that happens these should work to solve the problem of server-side ads on YouTube.