repub icon indicating copy to clipboard operation
repub copied to clipboard

Port to Safari

Open erikbrinkman opened this issue 1 year ago • 2 comments

There exists a converter, but I haven't had time to try

erikbrinkman avatar Nov 25 '24 02:11 erikbrinkman

It would be great to have a port for Safari.

PepikVaio avatar Nov 25 '24 10:11 PepikVaio

Just tried it to build it for Safari and this is where I got to.

Install the extension in your Chrome browser.

Figure out the path to the extension on your filesystem.

Then run (NOTE: make sure that you escape any whitespaces in the path below):

xcrun safari-web-extension-converter --project-location \
~/dev/remarkable2/safari-repub2 $HOME/Library/ApplicationSupport/Google/Chrome/Profile\ 1/Extensions/blkjpagbjaekkpojgcgdapmikoaolpbl/4.1.0_0

Xcode opened & I built the project for macOS, which installed the extension to Safari.

I had to enable it in Safari's Extensions.

But when I tried to use the extension, I'd get just this showing up on the icon:

image

And it would be just stuck there.

I thought that it might be down to the particular site I was on, so I tried it on a few others. But they all behaved the same as above. Stuck at 25%.

When you run the browser extension in Chrome, the very first step is that it prompts you to allow it to upload to reMarkable cloud. But in Safari, nothing like that happened. The steps listed above are exactly what happened.

Hope this provides some context and inspiration for you to port it to macOS. Thanks for your work 🙏

dotemacs avatar Nov 25 '24 12:11 dotemacs

Sorry for taking so long to look into this. I just tried the creation script and got this set of warnings:

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:
	offscreen
	downloads
	pageCapture
	notifications

Unfortunately, two of these are structural to how the extension works, another is fairly important.

Right now the extension is structured by first using pageCapture to get an anonymous rendering of the page you're on. This way it avoids needing to actually run js on any page, which I view as a pretty important security feature. Then it uses the offscreen API to parse the dom of the captured page for rendering. It's possible that safari extensions don't need this level of indirection, but it means that the project would essentially need to be forked to account for this difference.

Additionally, it allows downloading as a fallback in case you're not hooked up to reMarkable, and there are a number of people who seem to use this extension with other readers. At some point it might be worthwhile adding support for those readers apis.

I'm certain safari has a notifications api, but the fact that it can't convert from chome's means that this logic would also need to be forked.

Indeed, when I took my cloned copy and tried to run it, I received the same error at 25%. Looking at the logs, it first errors trying to call the page capture api, that fails, and then it tries to notify of the failure, which also fails because of the notifications api.

Given all of this difficulty, and the fact that I don't use safari, I don't really plan to invest the effort to support an extension. However, if someone did want to put in the effort to build a version from scratch, I'd be willing to both help, and potentially pull out some of the common components, so it'd be easy to have a core library supporting both extensions. For now though, I'm going to close this as unplanned. If anyone does want to take a stab, open a new issue, and point to the repo you're working on.

erikbrinkman avatar Jun 14 '25 17:06 erikbrinkman