uBlockOrigin / uBOL-home

uBO Lite home (MV3)
GNU General Public License v3.0
485 stars 24 forks source link

feature: maybe it's time to rethink the possibility of porting to Safari #52

Open dminca opened 3 years ago

dminca commented 3 years ago

Just asking if it's possible to make this wonderful extension available for Safari now, given the following article published by Apple Developers in regards to converting web extensions for Safari

https://developer.apple.com/news/?id=qiz0arxc

Prerequisites

Description

[Description of the bug or feature]

A specific URL where the issue occurs

[A specific URL is MANDATORY for issue happening on a web page, even if it happens "everywhere"]

Steps to Reproduce

  1. [First Step]
  2. [Second Step]
  3. [and so on...]

Expected behavior:

[What you expected to happen]

Actual behavior:

[What actually happened]

Your environment

uBlock-user commented 3 years ago

https://www.reddit.com/r/uBlockOrigin/comments/hdz0bo/will_ublock_origin_back_to_macos_big_sur/fvoc7wk/

emikaadeo-git commented 1 year ago

Hi, maybe we can reconsider this with new experimental uBOLite MV3 API-based content blocker ? Safari have support for MV3 extensions since version 15.4 https://webkit.org/blog/12445/new-webkit-features-in-safari-15-4/#safari-web-extensions

gorhill commented 1 year ago

I don't have MacOS, this would have to be undertaken by a another volunteer developer.

Anyways, the implementation of declarativeNetRequest API on Safari is missing key capabilities for the current state of uBOL, it does not support conditions such as initiatorDomains, excludedInitiatorDomains, requestDomains, excludedRequestDomains. It also does not support action types redirect which will be needed once uBOL starts to use this capability.

Additionally, the Safari scripting API is also missing key capabilities, namely registeredContentScript, getRegisteredContentScript, unregisterContentScripts, updateContentScripts.

emikaadeo-git commented 1 year ago

@gorhill Hi, thanks for clarification.

henryhchchc commented 1 year ago

Just noticed that Apple added support for redirect 10 months ago as mentioned in https://webkit.org/blog/12193/release-notes-for-safari-technology-preview-139/

Added support for the redirect rule type in declarativeNetRequest, which requires host permissions to be granted for the host of the URL being redirected

I think this feature is available in Safari 16 but Apple haven't updated their documentation.

abarisain commented 1 year ago

It looks like safari 16.4, in beta, adds support for a lot of what is missing

image

That said, there is still this ridiculous requirement for it to be wrapped in an app, so someone will have to do that.

wavded commented 1 year ago

Safari 16.4 is out of beta now, not sure how close this gets us.

dminca commented 1 year ago

I’ve posted on Mastodon to Jen and Jon from the WebKit team, let’s see if they’re considering the missing capabilities mentioned by Raymond https://mastodontech.de/@dminca/110135906549832299

helvetiica commented 1 year ago

Any updates for Safari 17 (macOS Sonoma)?

gorhill commented 1 year ago

Transferring the issue to uBO Lite issues repo because if ever there is a port to Safari, that will be MV3 uBO Lite, not uBO, which requires MV2.

Knaledge commented 1 year ago

Are there currently any other barriers to entry for restarting development of the Safari Extension for uBOL? Perhaps there is an opportunity to engage the broader community to alleviate some of those impediments (if there are any)

stephenhawk8054 commented 1 year ago

Are there currently any other barriers to entry for restarting development of the Safari Extension for uBOL?

Maybe the only barrier is someone willing to fork and develop it for Safari?

hadig commented 11 months ago

Converting the firefox variant with the safari-web-extension-converter seems to work somehow out of the box on macOS Sonoma. The dashboard is blank, but extension badge is updating blocked ads count. Ad blocking seems to work, except youtube video ads.

arjpar commented 10 months ago

@hadig I'm also willing to work on porting UBO Lite with whatever code you have. Since UBO is such a highly used extension I'm sure there are others (even if few) that may be willing to work on porting it (UBO Lite) to Safari.

khesed commented 10 months ago

Made a PR: https://github.com/uBlockOrigin/uBOL-home/pull/71

aayushbhatia06 commented 6 months ago

I know uBlock team is famous for not taking donations (for all the right reasons I might add) but just wanted to say if another interested developer would like to develop but has monetary hurdles myself and a LOT of other Safari users would be happy to contribute.

Webtapper commented 4 months ago

Is there any update on this issue/suggestion? And also want to re-iterate I would also gladly donate just for starting uBlock Origin for Safari development again :)

arjpar commented 4 months ago

@Webtapper There's no update that I know of. A PR was made and rejected because Safari's implementation of DNR (declarativeNetRequest) lacks some specific features that uBO-Lite on Chrome/(Firefox?) requires to function properly. There was no minimal viable product in the PR. I'd be more than happy to develop a port, without donations, but I need to check how much support for DNR the Safari team has added. The WebKit devs have moved the project to GitHub, and they're willing to engage with the developer community. I'm sure I/someone else can look at Safari's documentation for DNR and see what is missing/implemented for an MVP for Safari to come to fruition.

In the PR I mentioned above, @gorhill stated that specific APIs weren't supported by Safari's DNR implementation, and an investigation was/is needed to figure out which APIs are and are not supported.

Like I said above, I'd be more than happy to port uBO-Lite to safari, I just haven't had the time. The requirement for a Safari extension to also be published on the app store and fulfilling the requirements for that ($100 for a dev license) is also one thing that may put a strain on a port.

Hopefully this answered your question!

stephenhawk8054 commented 4 months ago

Just FYI that any volunteers who want to take a look can check the table comparison of Safari's MV3 ability here: https://github.com/uBlockOrigin/uBOL-home/wiki/Availability-of-MV3-APIs-used-by-uBOL

I think it's better to PR and complete the table with clear sources first to have a better picture of Safari's compatibility with uBOL.

arjpar commented 4 months ago

For/to all those concerned, I'll be starting work on a port here, and then eventually pushing upstream.

arjpar commented 4 months ago

so update: it will need work to get it to work on safari. i have the extension running, but its very buggy and actually breaks safari haha. it doesn't support "storage" or "type" keys in the manifest, which may prevent a mvp until apple adds those keys.

gorhill commented 4 months ago

it doesn't support "storage" or "type" keys in the manifest

There is a manifest.json version for each platform, so having a specific one for Safari is fine:

For Edge, it's a patched version of Chromium manifest.json because the web-accessible-resources had to reside at the root of the extension directory (patcher).

Once you have a proper Safari-compliant manifest.json, then it will be a matter of finding out which APIs are missing or behave differently in Safari.

Webtapper commented 4 months ago

Thanks @arjpar. I do not have the knowledge to help with any technical challenges here - but if we are at the stage of needing to raise $100 for the developer license I’d love to contribute as well. I’ll follow it here and appreciate your updates so far!!

arjpar commented 3 months ago

For those wondering, I'll be posting updates here

arjpar commented 3 months ago

Due to the issues explained here which explains the problems I've run into, a port of uBlock Origin Lite to Safari is currently not possible. It is, however, possible to make an excellent free & open source wide spectrum (ad blocker) content blocker for Safari using the relevant Safari-specific APIs and technologies for content blocking. But that is beyond the scope of my port, and it would not be a port of uBlock Origin Lite, it would be either a fork or a new project altogether. I don't have the time, effort, or knowledge of Apple ecosystem development to create such an extension. I welcome anyone who has those things to consider creating it if they want to. For the aforementioned reasons my Safari port of uBlock Origin Lite will cease development. (All the work I've been doing so far was locally) I doubt Apple will release the needed MV3 DNR APIs soon given that they have their own Safari specific ways of doing things. If they do eventually release those APIs and don't neuter them, I probably won't be working on a port, due to the previous reasons of not creating a new Safari ad block project - time, effort, and knowledge.

MisutaaAsriel commented 3 months ago

Fair enough. You are correct in that Safari has its own APIs which serve similar purposes (and in some ways, I would argue have benefits over DNR APIs, but at the expense of cross-compatibility), so a Safari port would likely be its own thing at this point, which hybridizes compatible uBlock methods with Safari specific Content Blocking methods.

Likewise, whilst App Store distribution isn't necessary, the extension being unsigned or otherwise signed by an unrecognized signing authority would make distribution more cumbersome.

Thank you for at least trying and/or looking into it. As a Safari user looking to move away from AdGuard, the attempt was appreciated.

fanckush commented 1 month ago

does Safari 18 in the new macOS Sequoia have any effect on the this issue?

arjpar commented 1 month ago

@fanckush I don't believe so. I looked at WebKit's changes for WWDC, and it didn't mention any major changes to content blocking. I only browsed their blog page though, and didn't see the specific videos on it, so maybe there are changes.

With that said, I have thought about learning about Apple ecosystem app development and creating a free open-source ad blocker for Safari as an extension. It's just a thought. If there's sufficient user desire for one, I'd really start to consider creating one. Currently there's Wipr (paid), and AdGuard (but different apps for macOS (free) and iOS (paid version for all the goodies)). Given that all the ad blocking solutions for Safari out there don't fit my desires entirely, I might actually start creating one out of interest - but it wouldn't be a port of uBO Lite, since that's not possible.

Handwork5615 commented 1 month ago

@arjpar Yes please 🙏🏻 other options are available as you mentioned above but uBlock is best in class. ublock origin is the only reason many people use other browsers. Please create one for safari.

fanckush commented 1 month ago

btw, if you like Safari but can't use it because UBO isn't available, you can give Orion a try

it's still in beta I think, so it can be a bit buggy here and there

JulianKahnert commented 1 month ago

@arjpar I really would love to have a Safari Extension! Ican help with questions regarding the Apple ecosystem and deploying an extension! But I have no experience with the development of an ad blocker.

arjpar commented 1 month ago

@Handwork5615 @JulianKahnert To all those concerned: I've started work on the extension. I'm still learning Swift though. I'll be writing up a design document to detail the architecture soon, it will be in Markdown format in the project's repository. Speaking of a repository, would you all like the project to be in a GitHub organization instead of my main profile? I would like it to be a joint effort, and build a community of collaborators. This means that if I eventually move on to something else, the project will still be sustained.

JulianKahnert commented 1 month ago

@arjpar What about a project in the uBlockOrigin org? If you have a PR and want a Code Review, just let me know 😊

arjpar commented 1 month ago

@JulianKahnert Like I said before, this project wouldn't be a port of uBlock Origin, because it doesn't share the same codebase as uBlock Origin. I would want to make it as close as uBlock Origin as I can, if I can. Also @fanckush I'm a Orion Contributor, and have access to private Orion RC builds. uBlock Origin doesn't apply cosmetic filtering on Orion until you manually reload the page. The Orion dev team is working on fixing smaller issues rather than bigs ones to improve the stability of the product. Eventually, it will work. As I mentioned above (if I did), I think it might be possible to make an ad blocker for Safari that's even more powerful than uBlock Origin Lite, using the relevant Safari-unique APIs. I'll have to see if I can make it work.

Handwork5615 commented 1 month ago

@Handwork5615 @JulianKahnert To all those concerned: I've started work on the extension. I'm still learning Swift though. I'll be writing up a design document to detail the architecture soon, it will be in Markdown format in the project's repository. Speaking of a repository, would you all like the project to be in a GitHub organization instead of my main profile? I would like it to be a joint effort, and build a community of collaborators. This means that if I eventually move on to something else, the project will still be sustained.

Please read this, posted 17 hours ago on reddit by someone, just look at the upvote of uBlock origin comment. You'll get lot of support from community for sure. https://www.reddit.com/r/mac/s/hCxASUFhpN

arjpar commented 1 month ago

@Handwork5615 I read it, and I'm happy many people would support the project. I was thinking about writing my own Network Filtering Engine, thats on par or even better than uBlock Origin's, but I'm not sure if it would be allowed by Apple's App Store policies or if the APIs allow it (I don't believe so). Regardless I want to try to support the following:

It will also be written entirely in Swift, SwiftUI, be a Catalyst & Universal App. Since it will use the latest technologies provided, it will only be available on recent versions of iOS, iPadOS, macOS & visionOS. These are just my aspirational goals. I think the Apple Documentation page for Content Blocking might be out of date, or maybe I'm just not looking in the right place. Again, these are just my idealistic/aspirational goals, I need to do further investigating to see if its feasible. I'm also still learning Swift, SwiftUI, & Apple Development, but I want to implement features in the most optimal way possible.

abarisain commented 1 month ago

I am very, very sorry to be the party pooper but it may be time to move this discussion elsewhere, please. I for one am satisfied with wipr and only interested in ublock.

arjpar commented 1 month ago

@dminca @gorhill This issue should be closed, since it's not possible to port uBlock Origin Lite to Safari currently. I have created an organization & repository to try to "re-create" uBlock Origin as much as we can in Safari using the Safari-relevant APIs. Further discussion can take place there. I'm currently in the design phase of the app, rather than just moving fast & breaking things.

dminca commented 1 month ago

@dminca @gorhill This issue should be closed, since it's not possible to port uBlock Origin Lite to Safari currently. I have created an organization & repository to try to "re-create" uBlock Origin as much as we can in Safari using the Safari-relevant API. Further discussion can take place there. I'm currently in the design phase of the app, rather than just moving fast & breaking things.

fair enough. Appreciate te effort of trying to integrate it.

Unfortunately the Safari team from Apple was not so communicative 😔