1
0
forked from um/web

Add Feature: Browser Extension

This commit is contained in:
MengYX 2021-02-08 01:28:30 +08:00
parent e089fe1268
commit 042b1ca0dd
No known key found for this signature in database
GPG Key ID: E63F9C7303E8F604
5 changed files with 39 additions and 1 deletions

15
extension-manifest.json Normal file
View File

@ -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"
}
}

20
make-extension.js Normal file
View File

@ -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")

View File

@ -12,7 +12,8 @@
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build", "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": { "dependencies": {
"base64-js": "^1.5.1", "base64-js": "^1.5.1",

1
src/extension/popup.html Normal file
View File

@ -0,0 +1 @@
<script src="./popup.js"></script>

1
src/extension/popup.js Normal file
View File

@ -0,0 +1 @@
window.open(chrome.runtime.getURL('./index.html'));