Open rjbiii opened 4 years ago
I don't have plans for it currently, but that's not to say it can't be done; I don't really have a testing environment for it currently. It may still be up to @FooSoft to decide if he wants to do anything with that.
Has Safari switched to the same Web Extension model as Chrome and Firefox? Last time I looked at it several years ago, it was very different, and would require many changes to the code.
I don't really see anything happening for Safari, honestly. It would be an additional development burden, and would steal @toasted-nutbread away from doing all his amazing work for Chrome and Firefox (which together cover the vast majority of the user base) 🙂
Hi, just passing through to say I recently discovered Yomichan (had used rikaichan/kun for decades) and would love to see Safari support. Safari (especially on M1 macs) is seeming to be the best choice for browser for Mac users. Searching around (especially reddit) I found several other users like myself wanting to stick with Safari but looking for some Yomichan alternative. Of course, I have no idea what the complexity is to do so (now I'm curious myself). Of course one consideration is MacOS/iOS has the native dictionary/Lookup feature which some compromise for (I myself use it constantly on iOS apps for readings).
Love the app and the incredible work you've all done to expand and support it! Cheers!
edit: Well, I tried the Apple-provided Web Extension converter and it did not "Just Work" sadly. It did mostly look correct but couldn't get the popup to display. There were several warnings running the tool, probably one of these really is crucial I suppose (or something else, who knows...)
Warning: The following keys in your manifest.json are not supported by your current version of Safari. If these are critical to your extension, you should review your code to see if you need to make changes to support Safari:
clipboardRead
persistent
webRequestBlocking
match_about_blank
sandbox
Noted, I'll try to look into seeing how compatible Yomichan is with Safari's web extension implementation.
I've done some initial investigation into supporting Safari, and my current take-away is that their implementation of Web Extensions has some bugs which cause Yomichan to not work correctly. This is not to say it is entirely impossible, but it would take some reworking of Yomichan's internals for it to work properly, which is unfortunate, since it's an issue only for Safari.
https://stackoverflow.com/questions/65058757/sendmessage-not-received-by-options-page-onmessage-in-safari https://developer.apple.com/forums/thread/668098
@toasted-nutbread I've roughly tested a speculation of the bug on sending/listening messages in Safari.
At least, chrome.runtime.sendMessage
seems to work fine and can be received by chrome.runtime.onMessage.addListener
in Yomichan.
The search function seems to be perfectly fine either as I can log the dictionary entries. The problem occurred when creating a popup. Promise
from https://github.com/FooSoft/yomichan/blob/0556c503195fb274069817514ceaad9ed2f1c998/ext/js/app/popup.js#L286 seems to be unresolvable and stuck on await
. Thus, the popup can't be displayed.
Edit: I'm using Xcode 13 Beta to convert and build the extension. Not sure if that makes difference.
It's been a few months since I tested, but I was definitely having issues with sendMessage actually being received in certain contexts. I believe the messages weren't being received by extension pages, but were being received by content scripts. For example, opening the settings page would usually not be respond since the initial await yomichan.prepare();
would not finish.
I believe that is part of what was causing frameClient.connect
to not resolve; its implementation is relatively complex, so that could be one of multiple problems as well.
I was testing in a VM, so maybe that's part of the issue, I'm not sure.
@toasted-nutbread Ah, yeah, it really stuck at await yomichan.prepare()
. Therefore, yomichan.api.broadcastTab('frameEndpointReady', {secret: this._secret});
cannot be reached. That's why frameEndpointReady
action never executed, so does frameEndpointConnected
. Thus, the promise is never resolved.
I'm not sure what is the problem in async prepare(isBackground=false)
, but it somehow seems to stuck at https://github.com/FooSoft/yomichan/blob/0556c503195fb274069817514ceaad9ed2f1c998/ext/js/yomichan.js#L104 despite that the Promise
should already resolved by https://github.com/FooSoft/yomichan/blob/0556c503195fb274069817514ceaad9ed2f1c998/ext/js/yomichan.js#L174
I'm only guessing, but the existing problem is deemed to be the top of the iceberg? Not really sure how many problems actually exists.
I know that Yomichan is much more complex, but Safarikai might be a similar example that's working well in Safari. With html injection method is somehow similar? One of the difference is that they use safari.extension.dispatchMessage
to communicate with Swift backend.
The problem isn't so much that the issue can't be worked around; it could be addressed with some effort to replace chrome.runtime.sendMessage
with messaging ports, although that comes with its own set of problems.
However, the issue still seems to ultimately reside on Safari's end, where it just doesn't send the messages properly. Clicking the extension button would usually result in messages getting through (e.g. the search page would sometimes start responding after clicking that button). This seems similar to the activeTab
permission, but realistically that should not be affecting the extension the way that it is.
it would be nice to get safari support. one perk would be that it would make it available on iphone and ipad as well.
would you guys be willing to accept paid sponsorship to implement safari, but more specifically ios/ipad os support? @FooSoft @toasted-nutbread
The comments below are solely my own and I do not speak on behalf of any other Yomichan contributors:
This gets into the sponsorship question raised in #2123, so I have a brief response in there. Specifically for this issue, the issues are more of the following:
Who would maintain the Safari extension? FooSoft does not very frequently contribute to the project currently, my own contribution rate is not as high as it used to be, and I technically have no affiliation with FooSoft outside of this project.
Last time I checked into supporting a Safari extension (~1 year ago), there were numerous technical issues with their implementation of extensions which did not work well with Yomichan's current code. This is likely worth revisiting.
Test hardware and/or Apple developer account support. While this does directly relate to paid sponsorship, I have no comment at this time with regards to the financials of this, other than what I mentioned in #2123.
I understand your hesitation and won't push any further than this comment. The long term maintenance burden was something I hadn't considered. It also makes sense not wanting to turn something that is a fun open source side project that you are working on into being something you become obligated to work on. Also logistics complicating things is problematic for sure.
It's definitely not my goal to earn any particular special priority or favor in general outside of what I would be directly sponsoring. I could pay for an ipad mini, the developer account and would be willing to pay for your time as well depending on how long you would think it would take and what you would think a fair hourly wage would be. If your privacy is important I could pay in bitcoin.
if for some reason you change your mind then you can reach out, assuming its something I'm still needing. totally no pressure at all though.
@xrishox, I've taken a back seat on Yomichan development; the number of projects I maintain has increased but the amount of time I have overall has decreased... @toasted-nutbread has been doing an amazing job running things; support from other contributors has also been invaluable in keeping this project alive.
OSS development is really a labor of love, and I strongly believe that the primary purpose of any project is to meet the developer's needs. The moment that you start implementing features or supporting a project that you no longer actively rely on, it becomes a job. Sponsorship can help act as a way of saying "thanks for what you do", but at the same time it can contribute to a feeling of obligation. As pointed out it, things become even weirder when you consider that there exist many contributors who helped make the project be what it is today. It's complicated enough just to think about what happens with licensing, without bringing financials into it.
Hardware, accounts, and ongoing technical burden of validating that the extension does not break due to browser changes is a whole other issue. The last one is especially big; even if someone were to do a drive by PR with all of the Safari stuff implemented you could end up at a net loss if you don't personally have any skin in the Apple ecosystem but still have to keep it alive.
This is all very similar to the reason that Yomichan would never support any language outside of Japanese. If someone were to add Chinese support, does it mean that toasted or myself would have to learn Chinese just to maintain the project?
totally fair points. thanks for all that you guys have done and i totally understand!
Some more testing on Safari reveals that its support for extensions is still not on par with Firefox or Chrome. It doesn't seem to be able to embed <iframe>
elements using an extension URL.
Blocked a frame with origin "https://jisho.org" from accessing a frame with origin "safari-web-extension://aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa". The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "safari-web-extension". Protocols must match.
And the other issue that I previously encountered of the settings page not loading properly still exists.
Here's a Rikaikun fork for Safari if you'd like a reference for working around Safari's quirks: https://github.com/birchill/10ten-ja-reader (It's a great extension in its own right, but there's no epwing support.)
And thanks for all your work trying to get this ported to Safari!
I've messed around with some of these extensions before, and the Rikai* extensions probably have an easier time since they don't deal with <iframe>
shenanigans in the same way that Yomichan does, and that is the current issue which prevents Yomichan from working on Safari unfortunately.
With recent updates to Safari, it's easier to port extensions to the browser. Are there any plans on porting yomichan to Safari?