Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adblockers #132

Open
pkrayzy opened this issue Dec 14, 2023 · 2 comments
Open

Adblockers #132

pkrayzy opened this issue Dec 14, 2023 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@pkrayzy
Copy link

pkrayzy commented Dec 14, 2023

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
Copy link
Owner

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:

WKContentRuleListStore.default().compileContentRuleList(forIdentifier: "blocklist", encodedContentRuleList: Browser.blocklist) { (rules, error) in
rules.map { configuration.userContentController.add($0) }
self.webView.load(URLRequest(url: url))
}
}

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:

delegate.tab.customJs.compactMap({ try? String(contentsOf: $0) }).map { js in

@kofigumbs kofigumbs added enhancement New feature or request help wanted Extra attention is needed labels Dec 17, 2023
@retorquere
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants