JabRef-Browser-Extension icon indicating copy to clipboard operation
JabRef-Browser-Extension copied to clipboard

JabRef BrowserExtension for Safari

Open AntonioDEM opened this issue 5 years ago • 17 comments
trafficstars

is there any way to insert an extension for safari?

AntonioDEM avatar Oct 06 '20 04:10 AntonioDEM

Theoretically, this should be possible with Safari 14. Only the distribution seems to a bit more complicated https://developer.apple.com/documentation/safariservices/safari_web_extensions

https://developer.apple.com/documentation/safariservices/safari_web_extensions/converting_a_web_extension_for_safari

@LyzardKing Maybe has an idea if this would be possible

Siedlerchr avatar Oct 06 '20 20:10 Siedlerchr

It should be possible... I'm not sure how the implementation of native-messaging is in safari, but according to this page it shouldn't be too bad: https://developer.apple.com/documentation/safariservices/safari_web_extensions/messaging_between_the_app_and_javascript_in_a_safari_web_extension

LyzardKing avatar Oct 07 '20 07:10 LyzardKing

I think this would be a nice addition, indeed! @Siedlerchr @LyzardKing could you try to create the xcode project as described in https://developer.apple.com/documentation/safariservices/safari_web_extensions/converting_a_web_extension_for_safari. I don't have a Mac, so this is hard for me to do.

It looks like that's all that is required on the extension side, and as @LyzardKing says it shouldn't be too hard to add the required native messaging infrastructure during the installation.

tobiasdiez avatar Oct 08 '20 07:10 tobiasdiez

I don't have a mac either.. I might be able to test something in a vm, but that's all the mac access I have

LyzardKing avatar Oct 08 '20 07:10 LyzardKing

I do have a Mac, so I can prepare this stuff. Will look into it. Just need to know where the extension has to be placed into afterwards

Siedlerchr avatar Oct 08 '20 08:10 Siedlerchr

There might be compatibility issues with the current version of native-messaging on macos: https://github.com/keepassxreboot/keepassxc-browser/issues/294

EDIT: this command might give a first idea on the feasibility of the extension: https://github.com/keepassxreboot/keepassxc-browser/issues/294#issuecomment-696301376

LyzardKing avatar Oct 08 '20 08:10 LyzardKing

@Siedlerchr that seems to be helpful: https://developer.apple.com/documentation/safariservices/safari_app_extensions/building_a_safari_app_extension#2957926

tobiasdiez avatar Oct 08 '20 09:10 tobiasdiez

I built it using the converter and could run it in Safari. Also started JabRef but seems not to work yet. https://github.com/JabRef/JabRef-Browser-Extension/tree/safariExt/safari

Bildschirmfoto 2020-10-08 um 15 37 35
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:
	run_at
	description
	version
	nativeMessaging
	content_security_policy
	js
	matches
	commands
	options_ui
	<all_urls>
	tabs
	page_action
	activeTab
	scripts
	storage
	developer
	webNavigation
	manifest_version
	name
	icons

https://developer.apple.com/documentation/safariservices/safari_web_extensions/assessing_your_safari_web_extension_s_browser_compatibility

Siedlerchr avatar Oct 08 '20 13:10 Siedlerchr

Cool! Can you try to update safari and/or xcode. These keys should be supported in more recent versions according to https://github.com/keepassxreboot/keepassxc-browser/issues/294#issuecomment-696318072

tobiasdiez avatar Oct 08 '20 13:10 tobiasdiez

Tried again witjh Safari 14.01 (latest technology preview) and I already use xcode 12. Version 12.0.1 (12A7300) in the js console I see:


[Error] Unhandled Promise Rejection: TypeError: Zotero.i18n.init is not a function. (In 'Zotero.i18n.init()', 'Zotero.i18n.init' is undefined)
	(anonyme Funktion) (zotero.js:228)
	asyncFunctionResume
	(anonyme Funktion) (zotero.js:224)
	doInject (inject.js:582)
	Globaler Code (inject.js:631)
[Error] ReferenceError: Can't find variable: safari
	(anonyme Funktion) (inject.js:73)
	(anonyme Funktion) (inject.js:616)

Siedlerchr avatar Oct 08 '20 14:10 Siedlerchr

Yeah, it's expected that there are gone be some problems as the the Zotero plugin contains some extra checks for their old-style Safari extension, like https://github.com/JabRef/JabRef-Browser-Extension/blob/master/Zotero/inject.js#L73

Maybe setting Zotero.isSafari to false somewhere early (e.g. in the background script) might already suffices. Otherwise the Zotero code needs to be changed as well.

tobiasdiez avatar Oct 08 '20 16:10 tobiasdiez

I will take a look at it in the next days.

Siedlerchr avatar Oct 08 '20 17:10 Siedlerchr

@Siedlerchr did you made any progress towards this?

tobiasdiez avatar Jan 17 '21 20:01 tobiasdiez

@Siedlerchr ping ;-)

tobiasdiez avatar Oct 22 '21 11:10 tobiasdiez

Any progress @Siedlerchr? I've read that the webextension api support of Safari has been improved in the meantime, so this might now be easier.

tobiasdiez avatar Jan 23 '22 16:01 tobiasdiez

I will give it a look again

Siedlerchr avatar Jan 23 '22 17:01 Siedlerchr