Skip to content

Commit

Permalink
Use a separate manifest.json for Chrome and Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
dstein64 committed Mar 18, 2024
1 parent 3871859 commit b004942
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store
Thumbs.db
/archive.zip
/archive_chrome.zip
/archive_firefox.zip
/manifest.json
File renamed without changes.
26 changes: 26 additions & 0 deletions manifest_firefox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "Auto Highlight",
"version": "3.5.0",
"description": "*Auto Highlight* automatically highlights the important content on article pages.",
"options_ui": {
"page": "src/options/options.html"
},
"permissions": ["activeTab", "contextMenus", "scripting", "storage"],
"optional_permissions": ["tabs", "clipboardWrite", "<all_urls>"],
"background": {
"scripts": ["src/matchPattern.js", "src/shared.js", "src/eventPage.js"]
},
"action": {
"default_icon": {
"19": "icons/0highlight19x19.png",
"38": "icons/0highlight38x38.png"
},
"default_title": "Toggle highlighting"
},
"icons": {
"16": "icons/16x16.png",
"48": "icons/48x48.png",
"128": "icons/128x128.png"
},
"manifest_version": 3
}
6 changes: 5 additions & 1 deletion src/eventPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// TODO: Use consistent variable naming (camel case or underscores, not both)

importScripts('matchPattern.js', 'shared.js');
// If we're running as a service worker (Chrome), import dependencies. For
// Firefox, they've already been loaded as background scripts.
if (self.WorkerGlobalScope !== undefined) {
importScripts('matchPattern.js', 'shared.js');
}

// *****************************
// * Utilities and Options
Expand Down
39 changes: 24 additions & 15 deletions zip.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
#!/usr/bin/env bash

# run this from the package directory
scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "${scriptdir}"

# easier to see args in an array than a string
ARGS=()
ARGS+=("icons/")
ARGS+=("src/")
ARGS+=("manifest.json")
gen_archive() {
browser="${1}"

# exclude
ARGS+=("-x")
ARGS+=("*.DS_Store")
ARGS+=("*Thumbs.db")
# easier to see args in an array than a string
args=()
args+=("icons/")
args+=("src/")
args+=("manifest_${browser}.json")

archive="archive.zip"
# exclude
args+=("-x")
args+=("*.DS_Store")
args+=("*Thumbs.db")

if [ -f "${archive}" ]; then
rm "${archive}"
fi
archive="archive_${browser}.zip"

zip -r "${archive}" "${ARGS[@]}"
if [ -f "${archive}" ]; then
rm "${archive}"
fi

zip -r "${archive}" "${args[@]}"
printf "@ manifest_${browser}.json\n@=manifest.json\n" | zipnote -w "${archive}"
}

gen_archive chrome
gen_archive firefox

0 comments on commit b004942

Please sign in to comment.