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

Manifest V3 + multiple feature requests #46

Closed
wants to merge 15 commits into from

Conversation

gantoine
Copy link

@gantoine gantoine commented Jul 28, 2023

Soooooo what started as a small change to replace permissions: ["http://*/*", "https://*/*"] quickly devolved into an evening-long refactor and enhancement of the extension. 🙃

QA

If you're interested in testing these changes but don't want to pull and build locally, you can use these builds:

  • chrome-2.0.0.zip: download and extract, then "Load unpacked" in chrome://extensions/
  • firefox-2.0.0.zip: download the zip file, then "Load temporary add-on" in about:debugging#/runtime/this-firefox

Manifest V3

With the switch to manifest V3, the spec for Chrome and Firefox splits; those differences need to be taken into consideration when building a manifest.json. Therefore, this PR takes the approach of splitting the manifest into 3 files: manifest.COMMON.json, manifest.FIREFOX.json and manifest.CHROME.json. During the build process, the COMMON file and one the browser files are merged using jq, and the output is saved as manifest.json (which is no longer tracked in git).

  • background is now split as Chrome now uses a service worker to run the background script
  • Renamed browser_action to action
  • Shortcut text removed from default_title
  • browser_style set to false since now deprecated
  • browser_specific_settings.id required for Firefox (set to random UUIDv4)
  • New permission required to support new functionality:
    • storage: localStorage is deprecated in extension contexts
    • contextMenus + notifications: quick add link via right-click
    • scripting + activeTab: get highlighted text for notes

And one more thing: the build script now outputs both packaged and unpackaged builds to /artifacts/chrome and /artifacts/firefox.

Major Changes

Granular permissions

By marking ["http://*/*", "https://*/*"] as optional_host_permissions, we can request only the permission(s) we need to connect to the Linkding instance. When first configuring the extension, you'll be prompted to grant permission to the page that hosts Linkding.

Firefox Chrome
Screenshot 2023-07-27 at 5 46 09 PM Screenshot 2023-07-27 at 6 29 21 PM

Dark mode

The extension popup and settings will appear in dark mode, based on the appearance/theme settings of your browser/OS, via the prefers-color-scheme media feature. I may get around to adding a small toggle in the settings to allow for manual control. Closes #41

Screenshot 2023-07-27 at 10 28 39 PM

Context menu entry

Right-clicking on a link will give you the option to quick-add it to your bookmarks, without having to visit the page. A notification is displayed if it's been added, or if it was already bookmarked. Closes #35

Context menu Notification
Screenshot 2023-07-27 at 10 59 17 PM Screenshot 2023-07-27 at 10 59 34 PM

Starred pinned badge

On bookmarked pages, a yellow star will appear on the badge (bottom-right on Chrome, top-right on Firefox). The star should appear as soon as a page is bookmarked, or when a new tab is opened. Closes #30

Screenshot 2023-07-27 at 9 49 54 PM

Other smaller changes

  • The state of the popup changes from "Save" to "Update" on first save
  • Add a trash button to delete a saved bookmark
  • Add link to main site (closes Add link to open linkding web site #29)
  • Highlighted text is saved to notes when creating/updating a bookmark (closes Put selected text in the description #20)
  • Update all dependencies to their latest versions
    • Required the removal of the Commonjs plugin in favour of ESM

As always, thoughts, questions and concerns are welcome!

Bonus screenshots

Settings A bookmarked page
256712627-d9a07b23-de34-40c7-b5d3-22e5bdf2564f Screenshot 2023-07-27 at 10 32 47 PM

},
"browser_specific_settings": {
"gecko": {
"id": "{6bc19aa2-7d91-4791-b5d4-8d84b5f3cdad}",
Copy link
Author

Choose a reason for hiding this comment

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

I'm not exactly sure what this UUID actually means, but setting a unique one like this does allow the build to pass 🤔

return { url: "", title: "" };
}

return tab;
Copy link
Author

Choose a reason for hiding this comment

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

This is so I can access more properties on the tab (like id)

Comment on lines +83 to +84
title: title || titlePlaceholder,
description: description || descriptionPlaceholder,
Copy link
Author

Choose a reason for hiding this comment

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

I think this may be a bug in the current extension, but in any case this change also works as expected.

@bsecker
Copy link

bsecker commented Jul 28, 2023

Dude, you're a legend! Thanks so much for this PR, it adds so many feature requests I've been following in one fell swoop 🚀

@gantoine
Copy link
Author

@bsecker Glad to hear it! If you're interested in testing the changes but don't want to pull and build locally, let me know and I can upload builds for Chrome and Firefox. Any QA would be appreciated. 🙇🏼

@bsecker
Copy link

bsecker commented Jul 28, 2023

@gantoine I'll happily test it. A build for Firefox would be awesome!

@gantoine
Copy link
Author

Awesome, and thank you! Here are the builds and instructions, which I've also added to the body of the PR.

  • chrome-2.0.0.zip: download and extract, then "Load unpacked" in chrome://extensions/
  • firefox-2.0.0.zip: download the zip file, then "Load temporary add-on" in about:debugging#/runtime/this-firefox

@sissbruecker
Copy link
Owner

Hey, thanks for the effort here, but this PR contains way too many changes for me to properly review it. Could you please extract individual features into separate PRs? Likewise for refactorings / manifest + build changes / etc.

Some quick notes:

  • The Chrome extension already uses Manifest V3, there is a chrome branch with the relevant changes to the manifest that I just rebase for a release. Your solution would be more convenient though, so I'd take a look at a PR for that.
  • There's probably a lot that I'd change about the dark theme to the point that I should probably do it myself rather than go into an exhausting review loop. Let's exclude this for now.

@bsecker
Copy link

bsecker commented Jul 29, 2023

Initial impressions from 10 mins of playing around:

  • I get a small blue dot that appears on each page, which disappears after I click the extension.
image
  • I don't get any context menu when right clicking to save a bookmark
  • there also doesn't seem to be any links to the linkding instance (also after saving the link):
image

If it helps here's a dump of my troubleshooting info

image

@gantoine
Copy link
Author

Could you please extract individual features into separate PRs?

Yes absolutely! Since some of the work builds onto itself, I'll start by opening a PR just for the manifest changes that covers permissions.

There's probably a lot that I'd change about the dark theme to the point that I should probably do it myself rather than go into an exhausting review loop

I took a "something-is-better-then-nothing" approach to dark mode that could be done quickly. I'd love to see a more robust dark mode at some point, but until then I'll open a split PR for dark mode.

@gantoine gantoine closed this Jul 29, 2023
@gantoine
Copy link
Author

gantoine commented Jul 29, 2023

I get a small blue dot that appears on each page, which disappears after I click the extension.

My understanding is that the dot appears for websites where explicit permission isn't granted in the manifest. I see it as well, and I believe is has to do with the "tabs" permission. If you reload a page where the dot was removed after clicking it, it comes back.

"After installing an extension, if you navigate to a website that requires permissions for the extension to work, the extensions button will display a notification dot. If the extension is already pinned in the toolbar, the notification dot will appear below the extension icon."

https://support.mozilla.org/en-US/kb/extensions-button

I don't get any context menu when right clicking to save a bookmark
there also doesn't seem to be any links to the linkding instance

This makes me think it's interacting with the old linkding extension (I assume) you had installed in Firefox. Could you try installing Firefox Developer Edition and testing it there, as it allows for installing unsigned add-ons (instead of having to load it temporarily)?

@bsecker Thanks for taking the time to test it!

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