From 042b1ca0ddb1d6967420b922d6d2ccd008bd9e10 Mon Sep 17 00:00:00 2001 From: MengYX Date: Mon, 8 Feb 2021 01:28:30 +0800 Subject: [PATCH] Add Feature: Browser Extension --- extension-manifest.json | 15 +++++++++++++++ make-extension.js | 20 ++++++++++++++++++++ package.json | 3 ++- src/extension/popup.html | 1 + src/extension/popup.js | 1 + 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 extension-manifest.json create mode 100644 make-extension.js create mode 100644 src/extension/popup.html create mode 100644 src/extension/popup.js diff --git a/extension-manifest.json b/extension-manifest.json new file mode 100644 index 0000000..ffcf14f --- /dev/null +++ b/extension-manifest.json @@ -0,0 +1,15 @@ +{ + "manifest_version": 2, + "name": "音乐解锁", + "short_name": "音乐解锁", + "icons": { + "128": "./img/icons/msapplication-icon-144x144.png" + }, + "description": "在任何设备上解锁已购的加密音乐!", + "offline_enabled": true, + "options_page": "./index.html", + "homepage_url": "https://github.com/ix64/unlock-music", + "browser_action": { + "default_popup": "./popup.html" + } +} diff --git a/make-extension.js b/make-extension.js new file mode 100644 index 0000000..2f68dd0 --- /dev/null +++ b/make-extension.js @@ -0,0 +1,20 @@ +const fs = require('fs') +const path = require('path') +const src = "./src/extension/" +const dst = "./dist" +fs.readdirSync(src).forEach(file => { + let srcPath = path.join(src, file) + let dstPath = path.join(dst, file) + fs.copyFileSync(srcPath, dstPath) + console.log(`Copy: ${srcPath} => ${dstPath}`) +}) + +const manifestRaw = fs.readFileSync("./extension-manifest.json", "utf-8") +const manifest = JSON.parse(manifestRaw) + +const pkgRaw = fs.readFileSync("./package.json", "utf-8") +const pkg = JSON.parse(pkgRaw) + +manifest["version"] = pkg["version"] +fs.writeFileSync("./dist/manifest.json", JSON.stringify(manifest), "utf-8") +console.log("Write: manifest.json") diff --git a/package.json b/package.json index b97884f..25e7f44 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", - "fix-compatibility": "node ./src/fix-compatibility.js" + "fix-compatibility": "node ./src/fix-compatibility.js", + "make-extension": "node ./make-extension.js" }, "dependencies": { "base64-js": "^1.5.1", diff --git a/src/extension/popup.html b/src/extension/popup.html new file mode 100644 index 0000000..b28b4e7 --- /dev/null +++ b/src/extension/popup.html @@ -0,0 +1 @@ + diff --git a/src/extension/popup.js b/src/extension/popup.js new file mode 100644 index 0000000..244624f --- /dev/null +++ b/src/extension/popup.js @@ -0,0 +1 @@ +window.open(chrome.runtime.getURL('./index.html'));