kofigumbs / multi

Create custom, lightweight macOS apps from websites
GNU General Public License v3.0
1.3k stars 40 forks source link

Adblockers #132

Open pkrayzy opened 11 months ago

pkrayzy commented 11 months ago

Is there any appetite to reimplement the content blocking framework? I know the commit to remove it referenced Better.FYI no longer existing, but Ghostery still maintains and publishes blocklists in the requisite format (https://github.com/ghostery/user-agent-ios/tree/c4d123e1937ffd01728374afd9bf546483c79389/content-blocker-lib-ios/Lists).

Alternatively, is there a way to embed the Ghostery javascript content blocker using the customJs functionality (https://github.com/ghostery/adblocker)?

kofigumbs commented 11 months ago

Oh, I hadn't heard of Ghostery, thanks for the links! I don't think that library is designed for use with client-side JS since your second link only describes use in worker JS (like Node, Electron, browser extensions). So I think Multi would need to implement support for the blocklist as opposed to using customJs.

I'm open to adding blocklist support, and I can implement it next time I spend some time on Multi. I can't guarantee when that would be though. If you're interested in contributing it yourself, you should be able to reuse most of the implementation from V2: https://github.com/kofigumbs/multi/blob/559451157c956de0d15578047c680b8669586d98/Sources/Runtime/Tab.swift#L46-L50

The only implementation change is that I think blocklists should be a config value (under tabs) instead of distributing it with Multi itself. That way users can supply their own if needed. We can add Examples/ghostery.json as a recommended solution. For consistency, the blocklists config field should accept [URL] just like custom CSS/JS do: https://github.com/kofigumbs/multi/blob/fcb8cc2bdcde23e83227564a9fe8921eb57edda3/Sources/MultiRuntime/TabView.swift#L38

retorquere commented 4 months ago

I don't think that library is designed for use with client-side JS since your second link only describes use in worker JS

I don't know how hard it would be to implement in multi, but client-side JS can create and control workers.