Safari 上 uBlock Origin 的情況

uBlock Origin 在 2016 的時候 porting 到 Safari 上,但在 2018 後就沒有再更新了,維護者在「Explanation of the state of uBlock Origin (and other blockers) for Safari #158」這邊說明了目前的情況。

主要就是蘋果要廢掉本來的 Extension API,而替代的框架裡沒有對應的 content filtering 能力,所以在新的框架內無法實做 uBlock Origin 的功能...

維護者的建議是換瀏覽器,但其實可以選擇的瀏覽器愈來愈少了 (因為 Google Chrome 這邊也在搞),所以維護者的建議就是換成 Firefox

另外我自己會建議用看看 Brave,因為 Brave 已經決定,如果 Google Chrome 修改 webRequest 的阻擋能力 (也就是這次的 Manifest V3),他們會繼續維持本來的相容性,所以可以預期 uBlock Origin 應該還是會動 (參考之前寫的「Brave 試用」這篇)。

Brave 試用

目前主力的瀏覽器還是 Google Chrome,會試著用其他的瀏覽器基本上就是「所以 Google 要對 ad blocker 全面宣戰了...」這篇文章提到的事情,然後找看看有什麼方案可以用...

先前測過 Firefox,但目前光是只開著三個 Slack 就會當掉 (三個 tab 都吃滿 100% CPU,所以可以在 top 上看到 300% 的使用率),另外整理的順暢度還是差了很大一截,實在是找不到什麼好理由換過去...

而這次測的 Brave 是從 Chromium 改出來的,看起來沒有改動太多東西,連 extension 站台都直接吃 Google Chrome 的,基本上都會動。

測了兩天有一些問題:

目前來看轉換成本不算太高,之後 Google Chrome 真的動手搞 ad blocker 時可以考慮換過來...

所以 Google 要對 ad blocker 全面宣戰了...

一月的時候 Google 就提出了「Manifest V3」,打算閹掉 extension 透過 webRequest 攔截連線的能力,而這個功能就是 uBlock Origin 這類 ad blocker 的基礎。

當時 Google 宣稱 webRequest 嚴重影響瀏覽器效能,但 Ghostery 的團隊則做了實驗證明影響極小:「Ad blocker performance study in response to Manifest V3 finds that Ghostery's ad blocker beats the competition」、「Google遭證據打臉,廣告封鎖程式幾乎不影響Chrome效能」。

All content-blockers except DuckDuckGo have sub-millisecond median decision time per request.

另外在 Alphabet (Google 母公司) 遞交給美國證管會的資料 (FORM 10-K) 可以看到他們把 ad blocker 視為威脅:「goog10-kq42018.htm」。

New and existing technologies could affect our ability to customize ads and/or could block ads online, which would harm our business.

Technologies have been developed to make customizable ads more difficult or to block the display of ads altogether and some providers of online services have integrated technologies that could potentially impair the core functionality of third-party digital advertising. Most of our Google revenues are derived from fees paid to us in connection with the display of ads online. As a result, such technologies and tools could adversely affect our operating results.

所以後續的行為就很清楚了,他們決定 Manifest V3 還是會閹掉 webRequest (以有效抑制 ad blocker 的能力,反正繼續堅持效能問題,當作沒聽到),只開放企業版本使用:「Google to restrict modern ad blocking Chrome extensions to enterprise users」。

Mozilla 愈來愈不成氣候的情況下,現在要看的戲應該是 Google 是否會因此受到 anti-trust 的挑戰呢...

擋 Facebook 廣告的 Userscript

Facebook 為了反制各種「擋廣告軟體」,用了各種奇怪的 DOM 在擋:

目前看起來 ublock origin 這類擋廣告軟體支援的格式已經擋不住了,得靠其他工具來擋... 用到現在一直有在更新的「Facebook unsponsored」算是還行... 看 source code 可以看到他是直接抓有顯示的字串來分析,所以不會受到 DOM 的干擾,不過最近看起來又開始被搞了... XD

Mozilla 在 iOS 上也出了自己的 Content Blocker

MozillaiOS 上也出了自己的 Content Blocker,叫做 Focus by Firefox:「Announcing Focus by Firefox, a Content Blocker for iOS」:

Today we’re pleased to announce the launch of Focus by Firefox, a free content blocker for Safari users on iOS 9 that gives users greater control of their mobile Web experience.

沒搞懂 Mozilla 跑出來弄這個的目的...

Google Chrome 與 Firefox 上擋廣告軟體的效能比較

在「10 Ad Blocking Extensions Tested for Best Performance」這篇看到各個 Ad Blocker 軟體的比較。

對各網站測試了載入速度、記憶體使用量、CPU 使用率,重點應該是最後的圖:

其中最知名的 AdBlock Plus (ABP) 會最慢的原因也很簡單,因為他預設值會放行廣告,這導致了效能掉很多:

If you’re wondering why the popular AdBlock Plus got low scores in some Chrome tests, the answer is simple and it’s purely down to the acceptable ads check box. Disable “Allow some non-intrusive advertising” and AdBlock Plus will performance wise, sit in the middle of the pack.

在 ABP 把 acceptable ads 擋掉後速度就比較接近了。不過,如果你願意接受 acceptable ads,也不應該選擇 ABP,因為其他也有支援 acceptable ads 的軟體效能比較好:

Whatever your opinion on acceptable ads, using the option in ABP is not recommended and if you wish to support showing specific ads while browsing, use something else. AdBlock, Adguard, AdRemover and SuperBlock all have an acceptable ads option of some sort, but none suffer a performance drop like ABP.

最後的結論,不論是 Google Chrome 或是 Firefox,贏家都是 uBlock Origin

The overall winner in Firefox is simply the quickest, and that was µBlock origin. µ AdBlock is a fair choice if you want an easy to use but fast blocker, the rest are almost identical so it’s down to personal preference and the options available as to which one you use.

The winner in Chrome is a closer call when you consider the results from all three tests. But as it got a couple of firsts and a second, we would say µBlock Origin is the definite winner, it truly is fast and efficient as the author claims. Both Ghostery and Adguard are still excellent choices and are viable alternatives to µBlock Origin providing good performance in all 3 categories.

Ghostery 雖然也會因為少讀很多東西進來而加快速度,不過拿來一起比好像怪怪的...

網路廣告愈來愈誇張,阻擋的功能變成趨勢了,在桌機上支援的軟體愈來愈完善,而在行動裝置上,iOS 9 也開始支援了:「Content blocking in iOS 9 is going to screw up way more than just ads」。

關於 iOS 9 的 Content Blocker

在「An hour with Safari Content Blocker in iOS 9」這邊提到了「An hour with Safari Content Blocker in iOS 9」這篇文章。

文章裡提到:

They have super tiny 'close' buttons that are near impossible to hit, they follow you as you scroll and there is a slow loading full page interstitial that loads on every page refresh. Urgh! Anyway...

在這兩張圖 (Before & After) 說明了很多效果:

而網頁讀取速度從 11 秒變成 2 秒...

蘋果在 WWDC 2015 上的說明則可以在「Safari Extensibility: Content Blocking and Shared Links」這邊看影片。