openinbrowser icon indicating copy to clipboard operation
openinbrowser copied to clipboard

Convert to WebExtension?

Open theres-waldo opened this issue 7 years ago • 21 comments

Mozilla recently announced that starting in Firefox 57, Firefox will no longer support addons that are not WebExtensions.

Is it possible to convert Open In Browser to be a WebExtension, so it can continue working in Firefox 57 and beyond?

theres-waldo avatar Dec 08 '16 01:12 theres-waldo

I haven't analyzed if and how that's possible to convert it to a WebExtension.

Unfortunately I won't have time to do that in the near future, I'd be happy if someone can help.

spasche avatar Dec 08 '16 10:12 spasche

I'd assume an implementation of the general idea of an override functionality should be possible, however Webextensions seem to have a lot less possibilities to alter the UI and so it might not be possible to add the dropdown menu in the same way as it is currently done but an alternative might be required.

There is more information about the migration at https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Comparison_with_XUL_XPCOM_extensions

neroux avatar Dec 24 '16 23:12 neroux

Seems like its not possible to port this to Web extensions. Yet i hope.

I've filed an issue on bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1344646

est31 avatar Mar 06 '17 09:03 est31

@est31 Why would you think so? It is probably not possible to port over the UI as it is now, but I wouldnt assume it is generally impossible.

neroux avatar Mar 06 '17 09:03 neroux

Well from what I saw on that page, there are a couple of options:

  • Button in the browser toolbar, with an optional popup panel.
  • Button in the URL bar, with an optional popup panel.
  • Keyboard shortcuts.
  • Adds items and submenus to the browser's context menu.

None of them actually allow smooth interaction. I mean you only find out that it wants to download stuff when you are met with the "what to do with this MIME type" dialog. Cancelling that and then going back to the link to right click it or something doesn't feel smooth at all.

est31 avatar Mar 06 '17 09:03 est31

That dialog feels like the natural place for the extension to be.

est31 avatar Mar 06 '17 09:03 est31

I agree the selection dialog would appear to be the natural place, but it is also specific to Firefox, Chrome does not have it at all.

Maybe it is/will be possible to re-route qualifiying downloads to a similar intermediate dialog. Not being too familiar with the available API calls I cant comment on whether this is already possible or will be.

neroux avatar Mar 06 '17 09:03 neroux

Okay, I've managed to assemble a proof of concept. See #28.

est31 avatar Mar 06 '17 15:03 est31

I've uploaded the Webextension version to AMO: https://addons.mozilla.org/en-us/firefox/addon/open-in-browser/versions/beta

Please try it out and report any feedback here or in issues on my repo.

est31 avatar Sep 23 '17 13:09 est31

@est31 Not sure how high of a priority it is, but right now the extension is pretty incompatible with Chrome.

As for Firefox, juding from a quick glance it seems to install and run fine. Of course some more thorough testing would be advised. Also, the UI could do with some polishing :).

neroux avatar Sep 23 '17 16:09 neroux

right now the extension is pretty incompatible with Chrome.

Supporting Chrome is no goal for me. One browser with a bunch of versions is enough testing work, and I'm not a particular fan of Chrome either.

the UI could do with some polishing :)

I'm no expert on UI design, so PRs welcome! (As long as you don't use a framework, I want to keep it lean and simple). Originally I just had normally sized, "native" UI controls, but those didn't really dominate the site, if it opened your initial impression wasn't one of an UI but of a blank page. Also "native" buttons look pretty bad on the web nowadays, every site has to invent its own style of how buttons look like, so I did my own attempt.

est31 avatar Sep 23 '17 18:09 est31

4 years ago I tried to port this add-on to Chrome, but the APIs weren't good enough. Firefox's WebExtensions APIs contains everything that I need, so I blew off the dust and updated the extension so that it can be used in Firefox.

Here it is: https://github.com/Rob--W/open-in-browser Screenshot:

The objective is to have a UX that is at least as good as the current legacy add-on. If this goal is reached, would you be willing to add me to the add-on listing so I can publish my extension with your add-on ID?

I want to improve a few things, such as customizable external viewer support (the "Open with Google Docs" viewer is currently the only external viewer, but the system already supports any number of viewers) and updating the internal MIME database.

There is also a preference page (WIP too):

screenshot-options-page

Rob--W avatar Sep 23 '17 18:09 Rob--W

@Rob--W I've checked out your add on. The UI looks much closer to the original, quite impressive!

Some nits:

  • Clicking the text doesnt change the text box change, while in the original UI it does
  • It doesn't support the text/x-... use case, see this test URL: https://bugs.eclipse.org/bugs/attachment.cgi?id=270041
  • Also there seems to be an issue on firefox 55 where the content-type header doesn't get stripped since I've opened the settings menu

Generally, I don't have a problem if instead of my rewrite yours gets taken (less maintenance work for me :)), but I'd also be okay if your extension gets published separately. Its @spasche 's choice. My priority is that I can continue using the add on!

est31 avatar Sep 23 '17 19:09 est31

@Rob--W: I tried your add-on with Firefox beta on Windows 10, but the popup window is very small and not usable: image.

Otherwise I agree with est31 that it looks quite close to the original. In that regard, it might be a smoother transition for existing users. If you're willing to maintain the add-on in the future and if @est31 is ok with it, I can give you access to AMO to publish it.

My comment in https://github.com/spasche/openinbrowser/pull/28#issuecomment-331468463 would also apply.

spasche avatar Sep 24 '17 11:09 spasche

@spasche Do you see any error messages in the global JS console (Ctrl-Shift-J)? The dialog starts at 10x10 and is supposed to resize to be big enough to show the content. Apparently it is not working as intended in your setup (I'll investigate after improving MIME detection).

I'm fine with maintaining it. Just like the others in this thread, all I want is that Open in Browser continues to work. My AMO account is https://addons.mozilla.org/firefox/user/RobW/ , and my e-mail can be found at the bottom of my website.

I intend to set the min version to 57+ to avoid triggering this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1401516

Rob--W avatar Sep 24 '17 11:09 Rob--W

Another thing I observed after trying out @Rob--W 's extension is that when I restart firefox, the windows are now much smaller, having the same size as the dialog window.

est31 avatar Sep 24 '17 12:09 est31

@Rob--W: I see this error in the logs (which doesn't happen without the add-on): TypeError: invalid 'in' operand browser[Learn More] tabbrowser.xml:2408:1 _insertBrowser chrome://browser/content/tabbrowser.xml:2408:1 getRelatedElement chrome://browser/content/tabbrowser.xml:7048:11 set_selectedIndex chrome://global/content/bindings/tabbox.xml:406:31 tabs_XBL_Constructor chrome://global/content/bindings/tabbox.xml:275:13 chrome://browser/content/tabbrowser.xml:46:9 tabbrowser_XBL_Constructor chrome://browser/content/tabbrowser.xml:5802:11

I added you on the AMO project.

By the way, I don't see license information in your repo. Could you clarify that? The current add-on is using MPL.

spasche avatar Sep 24 '17 13:09 spasche

Another thing I observed after trying out @Rob--W 's extension is that when I restart firefox, the windows are now much smaller, having the same size as the dialog window.

Reported as https://github.com/Rob--W/open-in-browser/issues/2

I don't see license information in your repo. Could you clarify that? The current add-on is using MPL.

I use MPL 2.0 - https://github.com/Rob--W/open-in-browser/blob/e5d5386ca55dd1f845ff0e87682e6df0f2ec73ff/package.json#L18 I will revisit the README and other non-critical files (e.g. license, contributing guidelines) after the extension's functionality is fully ready.

Rob--W avatar Sep 24 '17 13:09 Rob--W

@spasche I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1402703 for the other thing you mentioned. The extension seems to work fine despite the error message.

Rob--W avatar Sep 24 '17 16:09 Rob--W

@Rob--W: I got the same situation as @spasche - the dialog is not resized automatically. After some trials, I find the 10x10 is not a good initial value. The height should be at least 23 on my machine to allow automatic resizing. Looks like 23 is the height of the title bar + 1 pixel. The value of width does not matter. An 1x23 dialog still gets resized.

My environment: OS: macOS Sierra Hardware: MacBook Air, screen resolution 1280x800 Firefox: 56.0, installed from official dmg

yan12125 avatar Oct 04 '17 19:10 yan12125

The 2.0 version of the extension using @Rob--W 's code has been uploaded to AMO! Firefox 57 can come :).

est31 avatar Nov 13 '17 18:11 est31