File tree 8 files changed +242
-117
lines changed
8 files changed +242
-117
lines changed Original file line number Diff line number Diff line change 1
1
# 更新日志
2
2
3
+ ## 1.3.0
4
+
5
+ - 启动时自动检查扩展更新
6
+ - 更新翻译 (#184 ,#185 ,#186 )
7
+
3
8
## 1.2.13
4
9
5
10
- 更新翻译 (#180 )
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " ehsyringe" ,
3
3
"displayName" : " EhSyringe" ,
4
- "version" : " 1.2.13 " ,
4
+ "version" : " 1.3.0 " ,
5
5
"description" : " E 站注射器,将中文翻译注入到 E 站体内。" ,
6
6
"author" : " EhTagTranslation" ,
7
7
"main" : " syringe.js" ,
Original file line number Diff line number Diff line change
1
+ import { browser } from 'webextension-polyfill-ts' ;
2
+ import { logger } from '../tool/log' ;
3
+
4
+ async function main ( ) : Promise < void > {
5
+ const info = await browser . management . getSelf ( ) ;
6
+ const response = await fetch ( 'https://api.github.com/repos/EhTagTranslation/EhSyringe/releases/latest' , {
7
+ headers : {
8
+ accept : 'application/json' ,
9
+ } ,
10
+ } ) ;
11
+ const payload = ( await response . json ( ) ) as { tag_name : string ; html_url : string } ;
12
+ const current = `v${ info . version } ` ;
13
+ const latest = payload . tag_name ;
14
+ logger . log ( '检查插件更新' , { current, latest } ) ;
15
+ if ( latest !== current ) {
16
+ const id = await browser . notifications . create ( {
17
+ type : 'basic' ,
18
+ title : info . name ,
19
+ message : `发现新的版本 ${ latest } ,点击跳转到下载页面。` ,
20
+ iconUrl : '../assets/logo-padding.svg' ,
21
+ } ) ;
22
+ browser . notifications . onClicked . addListener ( ( cid ) => {
23
+ if ( cid === id ) {
24
+ chrome . tabs . create ( {
25
+ url : payload . html_url ,
26
+ } ) ;
27
+ }
28
+ } ) ;
29
+ }
30
+ }
31
+
32
+ export const result = main ( ) ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ class Background {
12
12
readonly contextMenu : typeof contextMenu = require ( './context-menu' ) . contextMenu ;
13
13
readonly omnibox : typeof omnibox = require ( './omnibox' ) . omnibox ;
14
14
readonly tagDatabase : typeof tagDatabase = require ( './tag-database' ) . tagDatabase ;
15
+ readonly extensionUpdate = require ( './extension-updater' ) ;
15
16
}
16
17
17
18
function getBackground ( ) : Background {
Original file line number Diff line number Diff line change @@ -53,14 +53,7 @@ class TagDatabase {
53
53
'sha' ,
54
54
'dataStructureVersion' ,
55
55
] ) ;
56
- if (
57
- dataStructureVersion !== DATA_STRUCTURE_VERSION ||
58
- ! tagList ||
59
- ! tagReplace ||
60
- ! releaseLink ||
61
- ! sha ||
62
- ! updateTime
63
- ) {
56
+ if ( dataStructureVersion !== DATA_STRUCTURE_VERSION || ! tagList || ! tagReplace || ! releaseLink || ! sha ) {
64
57
const timer = logger . time ( '数据结构变化, 重新构建数据' ) ;
65
58
await this . updateUseLocal ( ) ;
66
59
timer . end ( ) ;
@@ -130,7 +123,7 @@ class TagDatabase {
130
123
tagReplace,
131
124
releaseLink,
132
125
sha,
133
- updateTime : updateTime . getTime ( ) || undefined ,
126
+ updateTime : updateTime . getTime ( ) ?? undefined ,
134
127
dataStructureVersion : DATA_STRUCTURE_VERSION ,
135
128
} )
136
129
. catch ( logger . error ) ;
You can’t perform that action at this time.
0 commit comments