-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It is now possible to output as a Chrome/Firefox extension
- Loading branch information
1 parent
dabbd4c
commit 23d190c
Showing
4 changed files
with
1,018 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import archiver from "archiver"; | ||
import fs from "fs-extra"; | ||
import path from "path"; | ||
|
||
const extName = "auto-hide-next-up-card"; | ||
|
||
const distDir = "dist"; | ||
const chromeExtDir = path.join(distDir, "chrome"); | ||
const firefoxExtDir = path.join(distDir, "firefox"); | ||
|
||
const pkgMetadata = JSON.parse(fs.readFileSync("package.json", "utf-8")); | ||
const pkgVersion = pkgMetadata.version; | ||
const baseArchiveName = `${extName}_${pkgVersion}`; | ||
|
||
const prepareSrc = (parentDir) => { | ||
if (!fs.existsSync(parentDir)) { | ||
fs.mkdirSync(parentDir, { recursive: true }); | ||
} | ||
const targetDir = path.join(parentDir, "ext"); | ||
if (fs.existsSync(targetDir)) { | ||
fs.rmSync(targetDir, { recursive: true }); | ||
} | ||
fs.copySync("src/", targetDir); | ||
fs.copySync("LICENSE", path.join(targetDir, "LICENSE")); | ||
return targetDir; | ||
}; | ||
|
||
const buildChromeExt = async () => { | ||
const targetDir = prepareSrc(chromeExtDir); | ||
const archiveName = `${baseArchiveName}_chrome.zip`; | ||
const archivePath = path.join(chromeExtDir, archiveName); | ||
|
||
const output = fs.createWriteStream(archivePath); | ||
const archive = archiver("zip", { | ||
zlib: { level: 9 }, | ||
}); | ||
archive.directory(targetDir, false); | ||
archive.pipe(output); | ||
await archive.finalize(); | ||
console.log(`created ${archivePath}`); | ||
}; | ||
|
||
const buildFirefoxExt = async () => { | ||
const targetDir = prepareSrc(firefoxExtDir); | ||
const archiveName = `${baseArchiveName}_firefox.zip`; | ||
const archivePath = path.join(firefoxExtDir, archiveName); | ||
const manifestPath = path.join(targetDir, "manifest.json"); | ||
|
||
fs.rmSync(manifestPath); | ||
fs.copySync("misc/manifest.firefox.json", manifestPath); | ||
|
||
const output = fs.createWriteStream(archivePath); | ||
const archive = archiver("zip", { | ||
zlib: { level: 9 }, | ||
}); | ||
archive.directory(targetDir, false); | ||
archive.pipe(output); | ||
await archive.finalize(); | ||
console.log(`created ${archivePath}`); | ||
}; | ||
|
||
const main = async () => { | ||
await buildChromeExt(); | ||
await buildFirefoxExt(); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "Auto hide next up card for Amazon Prime Video", | ||
"version": "2.1.1", | ||
"default_locale": "en", | ||
"description": "__MSG_desc__", | ||
"icons": { | ||
"16": "icons/16.png", | ||
"32": "icons/32.png", | ||
"48": "icons/48.png", | ||
"128": "icons/128.png" | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": [ | ||
"https://*.amazon.co.jp/*", | ||
"https://*.amazon.com/*", | ||
"https://*.amazon.ae/*", | ||
"https://*.amazon.co.uk/*", | ||
"https://*.amazon.it/*", | ||
"https://*.amazon.in/*", | ||
"https://*.amazon.eg/*", | ||
"https://*.amazon.com.au/*", | ||
"https://*.amazon.nl/*", | ||
"https://*.amazon.ca/*", | ||
"https://*.amazon.sa/*", | ||
"https://*.amazon.sg/*", | ||
"https://*.amazon.se/*", | ||
"https://*.amazon.es/*", | ||
"https://*.amazon.de/*", | ||
"https://*.amazon.com.tr/*", | ||
"https://*.amazon.com.br/*", | ||
"https://*.amazon.fr/*", | ||
"https://*.amazon.com.be/*", | ||
"https://*.amazon.pl/*", | ||
"https://*.amazon.com.mx/*", | ||
"https://*.amazon.cn/*", | ||
"https://*.primevideo.com/*" | ||
], | ||
"js": ["main.js"] | ||
} | ||
], | ||
"browser_specific_settings": { | ||
"gecko": { | ||
"id": "auto-hide-next-up-card-for-amazon-prime-video@ryo-fujinone.net", | ||
"strict_min_version": "121.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.