TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

YouTube ads in Safari: you see them now, will you see them in the future?

212 pointsby taxyovioabout 4 years ago

21 comments

yliuabout 4 years ago
Despite the title being about YouTube, this is fundamentally about Safari&#x27;s declarative Content Blocker API being totally inadequate in the face of modern ad delivery technologies. Yes, it&#x27;s fast and relatively more secure compared to old ad blocking techniques (which requires granting full access to effectively arbitrary JS), but ad tech has evolved since 2015 and Safari&#x27;s Content Blocking API has not evolved with it.<p>With other browsers showing varying degrees of interest in declarative content blocking, it&#x27;s worth looking at Safari as a warning of what declarative content blocking, if unmaintained, will do to cripple ad blocking for users.
评论 #27214413 未加载
评论 #27213550 未加载
评论 #27215659 未加载
评论 #27216134 未加载
viktorcodeabout 4 years ago
There&#x27;s some misconceptions being put forth in the article which I, as a developer of a Safari ad blocker, would like to address.<p>Content blockers are limited by design to ensure privacy and speed, but they may work together with other kinds of Safari extension. So, when AdGuard guys say that the only debugging tool you can use is Console, know that this isn’t true. There’s SFSafariExtensionHandler API which you can use with blockers as another extension with higher privileges to track who blocked what. Very handy in debugging (and informative for the user).<p>Should I say that converting something like EasyList to Safari content blocker json is trivial? It is. Granted, ABP has more capabilities in its extended syntax, so you won’t be able to convert everything. There&#x27;s also some rules that don’t match 1 to 1, but it isn’t something that can’t be solved.<p>Compiling speed, for the process that happens once the blocker rules json is changed, is irrelevant for the users, unlike battery life. Thanks to the compilation, content blockers have less overhead.<p>The number of rules limit is a non-issue. As explained in the original, EasyList has lot of mergeable rules. I may add that it has some overlapping rules too. And if for whatever reason you hit 50k limit, you can add another content blocker extension to your app.<p>And the most important thing. It seems that AdGuard guys don’t get why content blockers in Safari don’t run scripts. It’s privacy. But Safari itself doesn’t prevent you from doing that, only not as a part of content blocker extension that is privacy-safe.<p>Speaking of YouTube ads, yeah, it’s a pain point. By blocking resources you can get to the point where an ad will be a white screen or a video loading delay. To get around those you have to get beyond what content blockers are offering. I’m thinking about adding that capability into my blocker, but it isn’t a priority.
评论 #27214503 未加载
评论 #27215179 未加载
评论 #27214000 未加载
评论 #27215611 未加载
评论 #27216377 未加载
评论 #27215749 未加载
Labo333about 4 years ago
Unfortunately, the web gets everyday closer to some kind of &quot;interactive TV&quot;. Computations are moving to the server side and clients are merely there to get input and display information. An illustration is the very controversial Mighty browser. As a result, programs will shortly become dependent on having an internet connection. Today, people use more Google Docs than Notepad. This removes a lot of freedom because computing now comes at the price of a subscription (for internet but also for other services be it SaaS, data monetization or server costs for self hosting).
评论 #27217890 未加载
评论 #27215886 未加载
评论 #27216225 未加载
whywhywhywhyabout 4 years ago
Removing whatever Ublock Origin needed to exist in Safari is one of the dumbest moves Apple has made.<p>To get most of the battery advantages of Macs you&#x27;re forced to use Safari. But when it comes down to having to see YouTube ads I&#x27;m willing to make the tradeoff and switch to Chrome.
评论 #27216211 未加载
评论 #27216417 未加载
评论 #27215552 未加载
happybuyabout 4 years ago
Part of the problem – as AdGuard concedes in the post – is that Easy List (which AdGuard and many other ad blockers use) is a woefully inefficient rule list with over 50,000 entries. Many of which are out of date, redundant and not optimised for performance.<p>This leads to excessive memory use and performance slowdowns and is one of the reasons why there is a 50,000 rule limit in the Safari Content Blocking API.<p>As a developer of an alternate ad blocker[1] for the iPhone, iPad and Mac you can deliver a full featured, quality ad blocker with less than 5,000 core rules. This provides a faster and more efficient ad blocking experience.<p>As they note however, YouTube ad blocking is a more difficult problem to solve, but can be done cleanly on macOS. At least at the moment it can&#x27;t be done 100% on iOS without Apple rolling out some additional features to Safari on that platform.<p>[1] <a href="https:&#x2F;&#x2F;www.magiclasso.co&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.magiclasso.co&#x2F;</a>
评论 #27216466 未加载
评论 #27216201 未加载
评论 #27218577 未加载
DoingIsLearningabout 4 years ago
On side note on this topic, I am pretty sure I am being A&#x2F;B tested on youtube with some form of dynamic ad inclusion.<p>A friend sent me a youtube link, I opened it on Firefox for Android (with the latest ublock lists), it immediately served me an ad.<p>This had never happened to me before, I actually assumed I opened it by mistake on Android&#x27;s youtube app.<p>The only way I found that I could block it was using the older embedded videos url (www.youtube.com&#x2F;embed&#x2F;&lt;video-id&gt;)<p>Anyone has more info on what are they doing exactly? I found a reddit post with similar complaints but everyone was equally clueless. Seems like they decided to point artillery at ublock.
评论 #27216191 未加载
dcdc123about 4 years ago
I have Brave on my iPhone for the sole purpose of watching YouTube ad-free. It works flawlessly.
teekertabout 4 years ago
I just switched from Android and I love iOS (iPhone 12 mini). But man do I miss Firefox (the real one, not the Safari skin) and man do I miss f-droid (specifically gems like GadgetBridge). If only I could have those 2 things.
评论 #27215070 未加载
评论 #27219347 未加载
cgb223about 4 years ago
Has anyone used iOS browsers with adblocking built in?<p>How do Firefox and Brave compare to Adguard or 1BlockerX?<p>Any other browsers out there that do a better job?
评论 #27214796 未加载
评论 #27216772 未加载
ec109685about 4 years ago
At some point, YouTube is just going to stich these into the main video.
评论 #27215710 未加载
评论 #27215414 未加载
评论 #27215993 未加载
评论 #27215044 未加载
twobitshifterabout 4 years ago
The battle between ad platforms and users is going to be never ending. For YouTube, the _right_ thing to do is to pay for the premium option which removes ads. Otherwise as difficult as it is to say, you are getting something for nothing and people do make a living from YouTube videos.<p>Ok, maybe you can contribute to a patreon outside of YouTube, but you’re not going to do that for everyone and those videos are not served for free (even if Google is not short on cash)
评论 #27213686 未加载
评论 #27213632 未加载
评论 #27213701 未加载
评论 #27213627 未加载
评论 #27213305 未加载
评论 #27215331 未加载
评论 #27214961 未加载
评论 #27215771 未加载
评论 #27219424 未加载
评论 #27213717 未加载
评论 #27213387 未加载
评论 #27213226 未加载
评论 #27213188 未加载
tipoftheicebergabout 4 years ago
For iOS YT users: hit refresh when the ad starts playing. Watch the ad go away. Voila.
google234123about 4 years ago
If you don&#x27;t want ads get Youtube Premium.
评论 #27219111 未加载
评论 #27215253 未加载
评论 #27215733 未加载
评论 #27219269 未加载
评论 #27215667 未加载
jb1991about 4 years ago
This one single problem is why I switched to Firefox. Even the FF mobile app does a much better job.
评论 #27217651 未加载
perryizgr8about 4 years ago
If you are using Android, be sure to check out Youtube Vanced. It cuts out all the ads very effectively, allows you to set a preferred video quality, and recently it has started blocking even in-video ads and product placement! Truly some next gen ad blocking tech.
floatingatollabout 4 years ago
Would migrating to the modern Safari extension API, which permits JavaScript injection into pages, be a better path forward here for this website modification tool?
评论 #27213697 未加载
tambebabout 4 years ago
It&#x27;s because of things like this—not to mention the added overhead&#x2F;middleman—that I think ad blocking at the DNS level is the best way to go. With both Android and iOS supporting encrypted DNS system-wide, blocking at the DNS level is more convenient than ever (mobile &amp; wifi are covered, no need to set DNS for each wifi network, etc.).<p>I realize of course, though, that DNS level blocking is mostly a non-starter with regards to YouTube since the ads are served up from the same domains as the videos (mostly? generally? not certain here).
评论 #27214320 未加载
评论 #27213602 未加载
gigaftpabout 4 years ago
Brave on iOS still blocks YouTube ads.
asimpletuneabout 4 years ago
If anyone wants to join my YouTube premium family plan, send me an email! It’s ~$4&#x2F;mo.
评论 #27216319 未加载
exikyutabout 4 years ago
Maybe slightly tangential since this is about Safari - but have 𝗬𝗼𝘂𝗧𝘂𝗯𝗲 𝗮𝗱𝘀 𝗿𝗲𝗰𝗲𝗻𝘁𝗹𝘆 𝗿𝗲𝗮𝗽𝗽𝗲𝗮𝗿𝗲𝗱 𝗶𝗻 𝗖𝗵𝗿𝗼𝗺𝗲?<p>The declarativeWebRequest YouTube adblocker I threw together in half an hour a few months ago recently stopped working on my end too.<p>Opting out of targeted ads serves you the bottom of the barrel, which was enough motivation to waste a day of JS spelunking (YouTube&#x27;s changes &quot;conveniently&quot; make declarative blocking nonviable).<p>Here&#x27;s what works for me... and here&#x27;s hoping it still works tomorrow :)<p><pre><code> ▶ manifest.json: { &quot;name&quot;: &quot;ytadblock&quot;, &quot;description&quot;: &quot;(license: CC0)&quot;, &quot;version&quot;: &quot;2.0&quot;, &quot;manifest_version&quot;: 2, &quot;declarative_net_request&quot;: { &quot;rule_resources&quot;: [{ &quot;id&quot;: &quot;1&quot;, &quot;enabled&quot;: true, &quot;path&quot;: &quot;ytadblock.json&quot; }] }, &quot;permissions&quot;: [ &quot;declarativeNetRequest&quot;, &quot;*:&#x2F;&#x2F;youtube.com&#x2F;*&quot;, &quot;*:&#x2F;&#x2F;www.youtube.com&#x2F;*&quot; ], &quot;content_scripts&quot;: [ { &quot;matches&quot;: [&quot;https:&#x2F;&#x2F;*.youtube.com&#x2F;*&quot;], &quot;js&quot;: [&quot;contentscript.js&quot;], &quot;run_at&quot;: &quot;document_start&quot; } ], &quot;web_accessible_resources&quot;: [&quot;inject.js&quot;] } ▶ ytadblock.json: [{ &quot;id&quot;: 1, &quot;priority&quot;: 1, &quot;action&quot;: { &quot;type&quot;: &quot;block&quot; }, &quot;condition&quot;: { &quot;regexFilter&quot;: &quot;.*\\.googlevideo\\.com&#x2F;.*ctier=&quot;, &quot;resourceTypes&quot;: [ &quot;main_frame&quot;, &quot;sub_frame&quot;, &quot;script&quot;, &quot;image&quot;, &quot;xmlhttprequest&quot;, &quot;media&quot;, &quot;other&quot; ] } }] ▶ contentscript.js: console.log(&#x27;hi from contentscript&#x27;); var s = document.createElement(&#x27;script&#x27;); s.src = chrome.runtime.getURL(&#x27;inject.js&#x27;); s.onload = function() { this.remove(); } document.documentElement.prepend(s); ▶ inject.js: &#x27;use strict&#x27;; (function() { var parse = JSON.parse; JSON.parse = function(input) { var data = parse(input); if (typeof data[&#x27;playerResponse&#x27;] !== &#x27;undefined&#x27;) { data.playerResponse.adPlacements = []; data.playerResponse.playerAds = []; } return data; } var fetch_ = fetch; fetch = async function(...args) { let response = await fetch_(...args); let text = await response.text(); if (response.url.match(&#x2F;\&#x2F;player\?&#x2F;)) { try { var json = JSON.parse(text); if (typeof json[&#x27;playerAds&#x27;] !== &#x27;undefined&#x27;) { json.adPlacements = []; json.playerAds = []; } text = JSON.stringify(json); } catch (e) {} } return new Response(text, { status: response.status, statusText: response.statusText, headers: response.headers }); }; var trap = { get(target, key) { if (key == &#x27;create&#x27; || key == &#x27;createAlternate&#x27;) { return function(...args) { args[1].args.raw_player_response.adPlacements = []; args[1].args.raw_player_response.playerAds = []; return target[key](...args); } } else if (typeof target[key] === &#x27;object&#x27; &amp;&amp; (key == &#x27;player&#x27; || key == &#x27;Application&#x27;)) { return new Proxy(target[key], trap); } else { return target[key]; } } }; var yt = new Proxy({}, trap); })(); </code></pre> Notes:<p>- Ad video requests can actually be distinguished by the &quot;ctier&quot; parameter in the xxx.googlevideo.com URL. (I presume &quot;c&quot; is related to the &quot;CSI&quot; that seems to be everywhere on Google properties.) The sole declarative block is intended as a fallback in case the JavaScript hooks fail; you&#x27;ll know if you hit these, because ad videos will spin for 5 seconds before they fail - and there might be MoRe ThAn OnE - and this may drive you very, very crazy. :)<p>- Initial page loads now contain a JavaScript blob with content and ad video info. After a lot of stumbling around I got the idea to turn the `yt` object into a Proxy and intercept the yt.player.Application.createAlternate() function, which said blob is passed into as an argument.<p>- YouTube seems to be using a mixture of requests to &quot;...&#x2F;player?&quot; via Fetch and XHR POSTed requests to &quot;...&#x2F;watch?.*pbj=1&quot; to fetch next-video-info when you click video links. Hooking XHR proved... depressingly tricky (...wow...), so I got the idea from <a href="https:&#x2F;&#x2F;greasyfork.org&#x2F;en&#x2F;scripts&#x2F;32626-disable-youtube-video-ads&#x2F;code" rel="nofollow">https:&#x2F;&#x2F;greasyfork.org&#x2F;en&#x2F;scripts&#x2F;32626-disable-youtube-vide...</a> to hook JSON.parse instead (koooool). Hooking Fetch, or at least YouTube&#x27;s use of Fetch, was thankfully not that hard.<p>The above is quite brittle, depends on how YouTube works <i>now</i>, and may get caught in the crossfire of unrelated site changes. ¯\_(ツ)_&#x2F;¯*
评论 #27261630 未加载
villgaxabout 4 years ago
I just fast forward them lol