WorldBrain / Memex

Browser extension to curate, annotate, and discuss the most valuable content and ideas on the web. As individuals, teams and communities.
https://worldbrain.io
4.43k stars 339 forks source link

Memex in Safari via web extension API support #1134

Open Talor-A opened 3 years ago

Talor-A commented 3 years ago
Screen Shot 2020-12-10 at 12 30 59 AM

hi all,

love the hard work you've put in on Memex but I've fallen out of using it since I strongly prefer safari to other browsers on my Mac. However, given that MacOS 11 brought with it built in webextension API support in Safari, I figured I might take a shot at porting this extension. to my surprise, it (almost) worked on the first go! as you can see, the popup opens up straight away. ~However, content_script.js doesn't get loaded (yet)~ (see edit) so the extension can't really do much besides the popup and opening the settings page. however, this seems like a really exciting possibility and I'm happy to share what work I've done if it's going to be helpful. What's a good way to get in touch? the slack linked in the readme doesn't allow signups, unfortunately.

EDIT: content_script.js gets called! (verified with the log message below, placed in global.ts -> main()) now I'm seeing these errors. any help debugging the RPC issues is appreciated.

[Error] Failed to load resource: The operation couldn’t be completed. (Cocoa error -1008.)
[Log] main function called! (content_script.js, line 88594)
[Error] Failed to load resource: The operation couldn’t be completed. (Cocoa error -1008.)
[Error] Unhandled Promise Rejection: RpcError: No such function registered for RPC: setTabAsIndexable
    generatorResume (content_script.js:94360)
    fulfilled (content_script.js:80816)
    promiseReactionJob
[Error] Unhandled Promise Rejection: RpcError: No such function registered for RPC: listAnnotationsByPageUrl
    generatorResume (content_script.js:94360)
    rejected (content_script.js:80817)
    promiseReactionJob
cdharris commented 3 years ago

Hey @Talor-A That's an awesome initiative!

The Worldbrain slack is accessible here https://join.slack.com/t/worldbrain/shared_invite/zt-k4eaf035-xfnqjJ_Uq0sXvJcMha_5fA

At first thought it sounds like there might still be some differences in Safari's web extension implementations (to Chrome/Firefox) I'm curious as to whether it's all of the background functions that failed to register, or whether it's just a select few due to some implementation differences.

Are these errors you include from the content script or the background script?

Feel free to submit a draft PR if you've changed anything that might help investigations. Safari support isn't on the current Memex roadmap given capacity from the core team but it would be very welcome contribution if you can get close to making it work.

Talor-A commented 3 years ago

thanks Chris, I created a PR #1136. the errors appear to come from content_script.js due to the background script not being initiated (a call at the top of main in background.ts never executes), trying to debug why

Talor-A commented 3 years ago

actually here's what I'm seeing now in the logs from the background script! hitting some errors, though.

image

However, looking deeper, there may be more important issues:

unsupported APIs

per this issue https://github.com/honestbleeps/Reddit-Enhancement-Suite/issues/5238, it's clear there are several unsupported APIs in safari. namely:

I think Memex could still run on safari if someone's willing to try working around those limitations. however, it's a bit more of a challenge than I was hoping for 😅

thoughts?

poltak commented 3 years ago

This is really nice @Talor-A ! I love that you're looking into this!

RE those missing APIs, here's what Memex uses each for and some thoughts:

I feel it would be doable with not a huge amount of effort, but investigation into what limits and data eviction policies Safari might have for client side would be needed to determine how stable the experience would be.

Do you know if they intend on implementing these APIs in the near future?

ShishKabab commented 3 years ago

Just as a heads up, webNavigation will probably be used in upcoming sprint to view shared annotations directly in a page. This would require us to be able to detect a https://memex.social/p/* link and redirect to the actual page you're trying to view so we can show the annotations in the sidebar. The actual implementation is still to be decided upon though.

schneimo commented 3 years ago

Any news on this? :)

Talor-A commented 3 years ago

I'm not able to continue on this work but anyone interested can use this as a jumping off point to get safari support implemented :)

braco commented 2 years ago

Lack of Safari support has forced me to stop using memex. I had to switch back to Safari because Chrome was killing my battery. Wish I had the skills to help!