Skip to content

Commit

Permalink
Fix for Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
foooomio committed May 28, 2024
1 parent 2691f5b commit f98d894
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
11 changes: 6 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
#!/bin/bash

set -eux
set -euo pipefail

NAME="view-background-image"
VERSION="$(jq -r .version src/manifest.json)"

rm -rf dist
mkdir -p dist
rm dist/*.zip

# for Chrome
./manifest.sh chrome
zip -r "dist/${NAME}-${VERSION}-chrome.zip" src -x "*.DS_Store"

# for Firefox
./manifest.sh firefox
cd src
sed -i -e 's/"service_worker": "background.js"/"scripts": \["background.js"\]/' manifest.json

zip -r "../dist/${NAME}-${VERSION}-firefox.zip" * -x "*.DS_Store"

sed -i -e 's/"scripts": \["background.js"\]/"service_worker": "background.js"/' manifest.json
cd ..
./manifest.sh chrome
21 changes: 21 additions & 0 deletions manifest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -euo pipefail

case "$1" in
'chrome')
jq '.background|={"service_worker": "background.js"}' < src/manifest.json | \
jq 'del(.browser_specific_settings)' > tmp/manifest.json
mv tmp/manifest.json src/manifest.json
yarn prettier --write src/manifest.json
;;
'firefox')
jq '.background|={"scripts": ["background.js"]}' < src/manifest.json |
jq '.browser_specific_settings|={"gecko":{"id":"{f1f7b448-d666-46c6-9dfa-3ee4c5c83578}"}}' > tmp/manifest.json
mv tmp/manifest.json src/manifest.json
yarn prettier --write src/manifest.json
;;
*)
echo 'Unknown argument'
;;
esac

0 comments on commit f98d894

Please sign in to comment.