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
Closed
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,7 @@ dist
.idea
*.iml
/build
/web-ext-artifacts
.web-extension-id
/artifacts
.web-extension-id
.DS_Store
manifest.json
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@ Run the build as described below and then follow the instructions [here](https:/

Internally, we use `web-ext` to bundle a distribution package for the extension for Firefox. You do not need to install `web-ext`. Note that `web-ext` will generate a zip file which can also be used for the Chrome Web Store.

Then run the following bash script to generate a build (might need to make the file executable using `chmod +x build.sh`):
Then generate a build (might need to make the file executable using `chmod +x build.sh`):
```
./build.sh
npm run build:ext
```

The script does:
- Install all dependencies using NPM
- Runs rollup to transpile and minify source files, with output written to `build`
- Run web-ext to package the extension for uploading to the Mozilla addon store
- Packages the extension for uploading to the Chrome webstore and Mozilla addon store

After the build the root directory contains the complete, unpackaged extension. Use the `manifest.json` file to load it manually into the browser.

The packaged extension can be found in the `web-ext-artifacts` folder.
The unpackaged and packaged builds can be found in the `artifacts` folder.
32 changes: 27 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
#!/usr/bin/env bash

# Update dependencies
npm install
# npm install

# Run rollup build
npm run build

# Lint extension, while excluding dev files
npx web-ext lint --ignore-files .idea dist docs src web-ext-artifacts .gitignore *.sh *.iml *.js *.lock
# Build extension, while excluding dev files
npx web-ext build --overwrite-dest --ignore-files .idea dist docs src web-ext-artifacts .gitignore *.sh *.iml *.js *.lock
## FIREFOX

# Copy files to artifacts folder
mkdir -p artifacts/firefox
cp -r build icons options popup styles artifacts/firefox

# Build manifest file for Firefox
jq -s '.[0] * .[1]' manifests/manifest.COMMON.json manifests/manifest.FIREFOX.json > artifacts/firefox/manifest.json

# Lint extension
npx web-ext lint --source-dir artifacts/firefox

# Build extension
npx web-ext build --overwrite-dest --source-dir artifacts/firefox --artifacts-dir artifacts/firefox

## CHROME

# Copy files to artifacts folder
mkdir -p artifacts/chrome
cp -r build icons options popup styles artifacts/chrome

# Build manifest file
jq -s '.[0] * .[1]' manifests/manifest.COMMON.json manifests/manifest.CHROME.json > artifacts/chrome/manifest.json

# Build extension
npx web-ext build --overwrite-dest --source-dir artifacts/chrome --artifacts-dir artifacts/chrome

echo "✅ Done"
Binary file added icons/button_star_19x19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/button_star_32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/button_star_38x38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions manifests/manifest.CHROME.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"background": {
"service_worker": "build/background.js",
"type": "module"
},
"optional_host_permissions": [
"http://*/*",
"https://*/*"
]
}
34 changes: 14 additions & 20 deletions manifest.json → manifests/manifest.COMMON.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,44 @@
{
"manifest_version": 2,
"name": "linkding extension",
"version": "1.7",
"manifest_version": 3,
"name": "Linkding",
"version": "2.0.0",
"description": "Companion extension for the linkding bookmark service",
"homepage_url": "https://github.com/sissbruecker/linkding-extension/",

"icons": {
"48": "icons/logo_48x48.png",
"96": "icons/logo_96x96.png",
"128": "icons/logo_128x128.png"
},

"background": {
"scripts": ["build/background.js"]
},

"omnibox": {
"keyword": "ld"
},

"browser_action": {
"action": {
"default_icon": {
"19": "icons/button_19x19.png",
"32": "icons/button_32x32.png",
"38": "icons/button_38x38.png"
},
"default_title": "Add bookmark (Alt+Shift+L)",
"default_title": "Add bookmark",
"default_popup": "popup/index.html"
},

"commands": {
"_execute_browser_action": {
"_execute_action": {
"suggested_key": {
"default": "Alt+Shift+L"
},
"description": "Open a popup to bookmark current page."
}
},

"options_ui": {
"page": "options/index.html"
"page": "options/index.html",
"browser_style": false
},

"permissions": [
"tabs",
"http://*/*",
"https://*/*"
"storage",
"contextMenus",
"notifications",
"scripting",
"activeTab"
]
}
}
15 changes: 15 additions & 0 deletions manifests/manifest.FIREFOX.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"background": {
"scripts": ["build/background.js"]
},
"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 🤔

"strict_min_version": "109.0"
}
},
"optional_permissions": [
"http://*/*",
"https://*/*"
]
}
Loading