Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility with most browsers supporting WebExtension #1

Merged
merged 1 commit into from
May 17, 2021

Conversation

alin23
Copy link
Contributor

@alin23 alin23 commented May 10, 2021

  • Use browser-polyfill.js (https://github.com/mozilla/webextension-polyfill)
  • For auth, send extension URL instead of extension ID to support schemes like moz-extension://
  • Fix manifest errors (wrong logo sizes for 16px and 48px)
  • Optimize PNGs using pngquant
  • Remove .DS_Store files
  • Some code style fixes applied by prettier (I have format on save enabled and I noticed too late)

Tested on latest Chrome Canary and Firefox Developer Edition

* Use browser-polyfill.js (https://github.com/mozilla/webextension-polyfill)
* For auth, send extension URL instead of extension ID to support schemes like `moz-extension://`
* Fix manifest errors (wrong logo sizes for 16px and 48px)
* Optimize PNGs using `pngquant`
* Remove `.DS_Store` files
* Some code style fixes applied by prettier (I have format on save enabled and I noticed too late)
@joelewis
Copy link
Owner

Hi @alin23

Much needed patch. Thank you for taking the time to contribute back.
The delta looks huge and I might take some time to review & merge them upstream. Will keep this thread updated.

Best,
Joe

@alin23
Copy link
Contributor Author

alin23 commented May 10, 2021

To help with the review this is an outline of the code changes:

  • Replace chrome. with browser.
  • Use tabs.query({ active: true, currentWindow: true }) instead of the deprecated tabs.getCurrent
  • Use Promise based calls instead of callbacks (required by the polyfill)

Copy link
Owner

@joelewis joelewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @alin23,
Thanks for the PR. See if you can commit the minor fix I've suggested.

passport.authenticate('google', { failureRedirect: '/login' }),
function(req, res) {
const redirect = req.session.returnTo;
delete req.session.returnTo;

if (req.session.from_extension) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter name change from_extension to from_extension_url might break the app if the server update and extension update doesn't happen at the same time – which is hard to ensure, given that the extension update is in the browser's control.

Can you edit the patch to exclude these param change alone?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the server handles both cases, would it be hard to ensure the server is updated first?

I think you could deploy the server first, which would still be compatible with the current version of the extension, and then you can publish the extension on the web store.

What do you think?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, makes sense. I didn't notice you've preserved the old handling as well. That should do 👍

@joelewis joelewis merged commit 99f3d5f into joelewis:master May 17, 2021
@joelewis
Copy link
Owner

Neat & timely! Merged now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants