iorate / ublacklist

Blocks specific sites from appearing in Google search results
https://iorate.github.io/ublacklist/
MIT License
5.72k stars 300 forks source link

Add support for Safari on iOS #99

Closed iorate closed 3 years ago

iorate commented 3 years ago

Update (Sep 25, 2022)

uBlacklist is now available on iOS/iPadOS 15 thanks to @HoneyLuka ! https://apps.apple.com/us/app/ublacklist-for-safari/id1547912640

TODO:


Apple has announced that iOS 15 will support Safari Web Extensions. https://developer.apple.com/videos/play/wwdc2021/10104/

Thanks to @HoneyLuka, uBlacklist is already available as a Safari Web Extension on macOS. I'd like to add support for Safari on iOS because I'm an iPhone and iPad user.

HoneyLuka commented 3 years ago

Thanks for your contribution. Can't wait to use it. :)

HoneyLuka commented 3 years ago

And if you need to get control of the macOS app for some reason, please let me know and I will transfer it to you any time. 🙏

iorate commented 3 years ago

@HoneyLuka Thanks, but for now I don't need control of the macOS app.

I will contact you here when I implement support for Safari on iOS 15.

iorate commented 3 years ago

iOS/iPadOS 15 will be released on Sep 20! https://www.apple.com/ios/ios-15/

I pushed a commit (9299d4569f9ff789b5fd91844417288114ed976a) which added initial support for Safari 15 on iOS. Although it supports only simple results in the "All" search, it seems to work well on iOS simulator:

Google Search on iOS Simulator The options page on iOS Simulator

I will add support for more types of search results later.

@HoneyLuka Could you please publish "uBlacklist for Safari" for iOS/iPadOS after iOS/iPadOS 15 are released and you think this extension supports them sufficiently?

HoneyLuka commented 3 years ago

@iorate Thanks for your work🎉, I think it's fine for a first release on iOS. I am now starting to work on the iOS version release preparation

iorate commented 3 years ago

@HoneyLuka Thank you. I'm looking forward to it.

iorate commented 3 years ago

The build system was upgraded for faster builds using esbuild-loader. To generate a production build for Safari:

# Install dependencies
- yarn install --frozen-lockfile
+ yarn install --immutable

# Build
- yarn build:safari:production
+ yarn build safari production

cc: @HoneyLuka

HoneyLuka commented 3 years ago

@iorate Thank you for the tips. I will use it tomorrow.

iOS version almost done. When I finished, I will tell you here.

HoneyLuka commented 3 years ago

@iorate When I debug on iPad, I found an UI issue. bug

iorate commented 3 years ago

@HoneyLuka Thank you for reporting an issue. Does the latest commit (017bf78642bae9f3b0146fe29ef12822763ddaf3) fix the problem?

ipad-popup

HoneyLuka commented 3 years ago

@iorate I merged your master branch, It's OK👍

iorate commented 3 years ago

@HoneyLuka I'm glad to hear that.

I would appreciate if you could also check the sync feature that I added a bit before (3fb12571fd9aa7e3ed464b4b3408105922c852d1). Because Safari on iOS lacks some APIs, users need to copy authorization codes from iorate.github.io manually.

HoneyLuka commented 3 years ago

@iorate ok, I will try it later, if any questions I will report to you.

HoneyLuka commented 3 years ago

@iorate I create a test dropbox app, set it's callback url to iorate.github.io.

Most functions are working. Only a little problem:

After sync finished, Appearance, Subscription module do not refresh automatically. Rules textarea show a tips 'updated Reload'. Maybe reload the whole options page automatically after sync?

iorate commented 3 years ago

@HoneyLuka Thank you for your feedback.

Maybe reload the whole options page automatically after sync?

I don't like automatic reload so much, so added a manual-reload button. (The screenshot below is taken in Firefox on Windows)

reload

HoneyLuka commented 3 years ago

@iorate I have completed the development of the iOS version, and ready for app store review, the first version is reviewing for external test(TestFlight External Test).

screenshot

If you want to build yourself, you can get code from my branch.

Should I submit the current release to app store or waiting for your next tag and rebuild a new release ?

iorate commented 3 years ago

@HoneyLuka Great!

Would you please bulid the current master (just marked as v6.4.0) and submit it as v6.4.0?

(As a side note, v6.4.0 will not be released for Chrome & Firefox. v6.3.6 is still under review by Chrome Web Store...)

HoneyLuka commented 3 years ago

@iorate ok, I will rebuild as 6.4.0 later.

iorate commented 3 years ago

I added v6.4.1 (and perhaps will add more) because v6.3.6 is rejected by Chrome Web Store. This does not affect the Safari version.

cyshallchan commented 3 years ago

@HoneyLuka 🤣已经在等了。

HoneyLuka commented 3 years ago

@HoneyLuka 🤣已经在等了。

Welcome to be the first user of iOS version🎉

HoneyLuka commented 3 years ago

@iorate @CyshallChan iOS version is online🎉 Link

cyshallchan commented 3 years ago

@iorate @HoneyLuka Already used, thank you two very much.

iorate commented 3 years ago

@HoneyLuka I installed "uBlacklist for Safari" to iOS 15 (on iPhone 11 Pro) and iPadOS 15 (on iPad Pro 12.9-inch) and confirmed it worked well. Thank you for your excellent work!

iorate commented 3 years ago

We should add support for:

  • [ ] image search
  • [ ] news search
  • [ ] video search
iorate commented 3 years ago

Synchronization and subscription updates may not occur regularly. In such cases, the alarms are certainly set, but Safari does not fire them.

alarm

(18 hours behind!)

I'm not sure what the reproduction conditions are.

HoneyLuka commented 3 years ago

@iorate Does this bug appear when the Safari app is in the background? Usually in native app of iOS, when the app switches to the background, OS give app a short time to execute code. After that the app will become background/sleep state, can't execute code, and Timer also can't fire(suspend). When the app active again, the timer will be resume.

I think this bug is very similar to native app. Because Safari is also a native app, when it is in the background, the activity of the extension is suspended due to battery life considerations

iorate commented 3 years ago

@HoneyLuka I think it is reasonable that alarms are not fired when Safari is in background, but alarms should be resumed after Safari is back to foreground as you say.

However, I have met some different situations:

  • Sync (every 15 minutes) and subscription (every 2 hours) did not occur after moving Safari from background for several hours to foreground
  • Sync (every 15 minutes) and subscription (every 2 hours) occurred immediately after moving Safari from background for several hours to foreground
  • Sync (every 15 minutes) occurred but subscription (every 2 hours) did not occur after moving Safari from background for several hours to foreground
  • Sync (every 5 minites) and subscription (every 5 minutes) did not occur even when I kept Safari in foreground during the interval

I don't understand the behavior of Safari...

HoneyLuka commented 3 years ago

@iorate This may be a bug in Safari, which is not surprising.

If this is indeed a bug, I'm thinking of a solution. I'm not good at web development. I'm not sure if there is a way to let the extension know about Safari state changes. After a short search, I found an event windows.onFocusChanged. Maybe when Safari become active, this event will be callback. The document said this works after Safari 14 (maybe it's macOS Safari 14). If it is indeed, in unfocus event remove all alarms, and in focus event recreate them (More complex logic can also be added, for example fire an update immediately or based on last fire time).

Summary Steps:

  1. Check if windows.onFocusChanged is Working properly.
  2. Check recreated alarm is Working properly. (If this bug is more critical, the recreated alarm maybe also does not work properly)
  3. If both is ok, write code on event callback.
iorate commented 3 years ago

@HoneyLuka Sounds good. windows.onFocusChanged seems to work in iOS Simulator.

iorate commented 3 years ago

I've been trying the windows.onFocusChanged hack for half a day on my iPhone and iPad. So far, it seems to be working.

HoneyLuka commented 3 years ago

@iorate Glad it works. Thank your for your hard work.

iorate commented 3 years ago

I believe it works. @HoneyLuka Would you please publish v6.6.0 when it's convenient for you?

HoneyLuka commented 3 years ago

@iorate Thank you🎉, I will submit it to app store right now.

HoneyLuka commented 3 years ago

iOS 6.6.0 is online now.

iorate commented 3 years ago

@HoneyLuka It works well on my actual devices. Thanks!

love4taylor commented 3 years ago

Is it possible to use CloudKit to synchronize data?

HoneyLuka commented 3 years ago

Is it possible to use CloudKit to synchronize data?

I haven't look this part yet. Usually Apple's services are only available on Apple devices. Even it is possible, I don't think it's necessary to do this right now. There is a lot of work to do for this feature.

iorate commented 3 years ago

Image, news and video search support is available in v6.7.0. cc: @HoneyLuka

iorate commented 3 years ago

@HoneyLuka The screenshots and captions seem to mismatch in the iPad app.

ipad-screenshot

HoneyLuka commented 3 years ago

@HoneyLuka The screenshots and captions seem to mismatch in the iPad app.

ipad-screenshot

It seems a bug, I will fix it later and release 6.7.0

HoneyLuka commented 3 years ago

iOS 6.7.0 is online🎉

iorate commented 3 years ago

@HoneyLuka thanks!

iorate commented 3 years ago

I'm closing this issue because I think basic support for iOS is already done. For further problems on iOS, please create individual issues for each problem.