Skip to content

Commit

Permalink
Merge pull request #549 from acgotaku/feature/v3
Browse files Browse the repository at this point in the history
  • Loading branch information
acgotaku authored Jul 3, 2022
2 parents 894462c + 84a9e9e commit ab06789
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 27 deletions.
38 changes: 21 additions & 17 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ const httpSend = ({ url, options }, resolve, reject) => {
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
switch (request.method) {
case 'addScript':
chrome.tabs.executeScript(sender.tab.id, { file: request.data })
chrome.scripting.executeScript({
target: { tabId: sender.tab.id },
files: [request.data]
})
break
case 'rpcData':
httpSend(request.data, (data) => {
httpSend(request.data, () => {
sendResponse(true)
}, (err) => {
console.log(err)
Expand Down Expand Up @@ -77,25 +80,26 @@ const getCookies = (details) => {
}

const showNotification = (id, opt) => {
if (!chrome.notifications) {
return
}
chrome.notifications.create(id, opt, () => {})
setTimeout(() => {
chrome.notifications.clear(id, () => {})
}, 5000)
}
// 软件版本更新提示
const manifest = chrome.runtime.getManifest()
const previousVersion = localStorage.getItem('version')
if (previousVersion === '' || previousVersion !== manifest.version) {
const opt = {
type: 'basic',
title: '更新',
messa0ge: '115助手更新到' + manifest.version + '版本啦~\n此次更新添加会员下载功能~',
iconUrl: 'img/icon.jpg'
(async () => {
const manifest = chrome.runtime.getManifest()
const { version: previousVersion } = await chrome.storage.local.get('version')
if (previousVersion === '' || previousVersion !== manifest.version) {
const opt = {
type: 'basic',
title: '更新',
message: '115助手更新到' + manifest.version + '版本啦~\n此次更新升级到Manifest V3~',
iconUrl: 'img/icon.jpg'
}
const id = new Date().getTime().toString()
showNotification(id, opt)
await chrome.storage.local.set({
version: manifest.version
})
}
const id = new Date().getTime().toString()
showNotification(id, opt)
localStorage.setItem('version', manifest.version)
}
})()
10 changes: 9 additions & 1 deletion gulpfile.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import plumber from 'gulp-plumber'

import terser from 'gulp-terser'

import zip from 'gulp-zip'

const sass = gulpSass(dartSass)

const paths = {
Expand Down Expand Up @@ -132,9 +134,15 @@ function watch () {
gulp.watch(paths.styles.src, styles)
}

export function compress () {
return gulp.src(paths.compress.src)
.pipe(zip('chrome.zip'))
.pipe(gulp.dest(paths.compress.dest))
}

const build = gulp.parallel(scripts, styles, images, copys, copyVendor)
const serve = gulp.series(clean, build, watch)
const publish = gulp.series(clean, build)
const publish = gulp.series(clean, build, compress)

exports.build = build
exports.serve = serve
Expand Down
15 changes: 9 additions & 6 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"background": {
"scripts": ["background.js"],
"persistent": false
"service_worker": "background.js"
},
"content_scripts": [
{
Expand All @@ -27,9 +26,13 @@
"48": "img/logo48.png",
"128": "img/logo128.png"
},
"web_accessible_resources": ["js/115.js"],
"manifest_version": 2,
"permissions": ["cookies", "storage", "tabs", "*://*.115.com/*"],
"web_accessible_resources": [{
"resources": ["js/115.js"],
"matches": ["*://*.115.com/*"]
}],
"manifest_version": 3,
"permissions": ["cookies", "storage", "notifications", "scripting"],
"host_permissions": ["*://*.115.com/*"],
"name": "__MSG_appName__",
"version": "0.4.3"
"version": "0.5.0"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dev": "cross-env NODE_ENV=development gulp serve",
"build": "cross-env NODE_ENV=production gulp publish",
"clean": "gulp clean",
"eslint:fix": "eslint --fix src",
"eslint:fix": "eslint --fix src background.js",
"stylelint:fix": "stylelint \"src/**/*.scss\" --fix",
"lint:fix": "npm run stylelint:fix && npm run eslint:fix"
},
Expand Down Expand Up @@ -49,6 +49,7 @@
"gulp-rollup-each": "^4.0.1",
"gulp-sass": "^5.1.0",
"gulp-terser": "^2.0.1",
"gulp-zip": "^5.1.0",
"imagemin-mozjpeg": "^9.0.0",
"imagemin-pngquant": "^9.0.2",
"postcss": "^8.4.14",
Expand Down
25 changes: 25 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/js/lib/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Store from './store'

class UI {
constructor () {
this.version = '0.4.3'
this.updateDate = '2022/06/09'
this.version = '0.5.0'
this.updateDate = '2022/07/03'
Store.on('updateView', (configData) => {
this.updateSetting(configData)
this.updateMenu(configData)
Expand Down

0 comments on commit ab06789

Please sign in to comment.