Skip to content

Commit c66fd10

Browse files
committed
Clean code and correct spellings
1 parent 7c38c70 commit c66fd10

File tree

12 files changed

+88
-94
lines changed

12 files changed

+88
-94
lines changed

script/crowdin/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export class CrowdinClient {
274274
createStorage = createStorage
275275
/**
276276
* Get the main branch
277-
*
277+
*
278278
* @returns main branch or undefined
279279
*/
280280
getMainBranch = getMainBranch
@@ -317,7 +317,7 @@ export class CrowdinClient {
317317

318318
/**
319319
* Get the client from environment variable [TIMER_CROWDIN_AUTH]
320-
*
320+
*
321321
* @returns client
322322
*/
323323
export function getClientFromEnv(): CrowdinClient {

script/crowdin/common.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ export const MSG_BASE = path.join(__dirname, '..', '..', 'src', 'i18n', 'message
5454
export const RSC_FILE_SUFFIX = "-resource.json"
5555

5656
/**
57-
* Read all messages from source file
58-
*
57+
* Read all messages from source file
58+
*
5959
* @param dir the directory of messages
60-
* @returns
60+
* @returns
6161
*/
6262
export async function readAllMessages(dir: Dir): Promise<Record<string, Messages<any>>> {
6363
const dirPath = path.join(MSG_BASE, dir)
@@ -78,7 +78,7 @@ export async function readAllMessages(dir: Dir): Promise<Record<string, Messages
7878

7979
/**
8080
* Merge crowdin message into locale resource json files
81-
*
81+
*
8282
* @param dir dir
8383
* @param filename the name of json file
8484
* @param messages crowdin messages
@@ -99,15 +99,11 @@ export async function mergeMessage(
9999
Object.entries(messages).forEach(([locale, itemSet]) => {
100100
let existMessage: any = existMessages[locale] || {}
101101
Object.entries(itemSet).forEach(([path, text]) => {
102-
if (!text) {
103-
// Not translated
104-
return
105-
}
102+
// Not translated
103+
if (!text) return
106104
const sourceText = sourceItemSet[path]
107-
if (!sourceText) {
108-
// Deleted key
109-
return
110-
}
105+
// Deleted key
106+
if (!sourceText) return
111107
if (!checkPlaceholder(text, sourceText)) {
112108
console.error(`Invalid placeholder: dir=${dir}, filename=${filename}, path=${path}, source=${sourceText}, translated=${text}`)
113109
return

script/crowdin/crowdin.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type ItemSet = {
2929

3030
/**
3131
* The language code of crowdin
32-
*
32+
*
3333
* @see https://developer.crowdin.com/language-codes/
3434
*/
3535
type CrowdinLanguage =

script/crowdin/sync-source.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async function initBranch(client: CrowdinClient): Promise<SourceFilesModel.Branc
1414

1515
/**
1616
* Process strings
17-
*
17+
*
1818
* @param client client
1919
* @param existFile exist crowdin file
2020
* @param fileContent strings
@@ -55,7 +55,7 @@ async function processByDir(client: CrowdinClient, dir: Dir, branch: SourceFiles
5555
if (!directory) {
5656
directory = await client.createDirectory(dirKey)
5757
}
58-
console.log('Direcotory: ' + JSON.stringify(directory))
58+
console.log('Directory: ' + JSON.stringify(directory))
5959
// 2. iterate all messages
6060
const messages = await readAllMessages(dir)
6161
// 3. list all files in directory

src/app/components/limit/table/column/common.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { defineComponent, h, onMounted, ref, VNode } from "vue"
1010

1111
/**
1212
* Judge wether verification is required
13-
*
13+
*
1414
* @returns T/F
1515
*/
1616
export async function judgeVerificationRequired(item: timer.limit.Item): Promise<boolean> {
@@ -26,15 +26,13 @@ export async function judgeVerificationRequired(item: timer.limit.Item): Promise
2626
}
2727
// Visit
2828
if (visitTime) {
29-
console.log("visiTime", visitTime)
3029
const hitVisit = await sendMsg2Runtime("askHitVisit", item)
31-
console.log("visiTimeHit", hitVisit)
3230
if (hitVisit) return true
3331
}
3432
return false
3533
}
3634

37-
const PROMT_TXT_CSS: Partial<CSSStyleDeclaration> = {
35+
const PROMPT_TXT_CSS: Partial<CSSStyleDeclaration> = {
3836
userSelect: 'none',
3937
}
4038

@@ -79,23 +77,23 @@ const AnswerCanvas = defineComponent({
7977
})
8078

8179
/**
82-
* @returns null if verification not required,
83-
* or promise with resolve invocked only if verification code or password correct
80+
* @returns null if verification not required,
81+
* or promise with resolve invoked only if verification code or password correct
8482
*/
8583
export async function processVerification(option: timer.option.DailyLimitOption): Promise<void> {
8684
const { limitLevel, limitPassword, limitVerifyDifficulty } = option
8785
let answerValue: string
8886
let messageNodes: (VNode | string)[]
89-
let incrorectMessage: string
87+
let incorrectMessage: string
9088
if (limitLevel === 'password' && limitPassword) {
9189
answerValue = limitPassword
9290
messageNodes = [t(msg => msg.limit.verification.pswInputTip)]
93-
incrorectMessage = t(msg => msg.limit.verification.incorrectPsw)
91+
incorrectMessage = t(msg => msg.limit.verification.incorrectPsw)
9492
} else if (limitLevel === 'verification') {
9593
const pair: VerificationPair = verificationProcessor.generate(limitVerifyDifficulty, locale)
9694
const { prompt, promptParam, answer } = pair || {}
9795
answerValue = typeof answer === 'function' ? t(msg => answer(msg.limit.verification)) : answer
98-
incrorectMessage = t(msg => msg.limit.verification.incorrectAnswer)
96+
incorrectMessage = t(msg => msg.limit.verification.incorrectAnswer)
9997
if (prompt) {
10098
const promptTxt = typeof prompt === 'function'
10199
? t(msg => prompt(msg.limit.verification), { ...promptParam, answer: answerValue })
@@ -114,7 +112,7 @@ export async function processVerification(option: timer.option.DailyLimitOption)
114112
boxType: 'prompt',
115113
type: 'warning',
116114
title: '',
117-
message: h('div', { style: PROMT_TXT_CSS }, messageNodes),
115+
message: h('div', { style: PROMPT_TXT_CSS }, messageNodes),
118116
showInput: true,
119117
showCancelButton: true,
120118
showClose: true,
@@ -123,7 +121,7 @@ export async function processVerification(option: timer.option.DailyLimitOption)
123121
if (value === answerValue) {
124122
return resolve()
125123
}
126-
ElMessage.error(incrorectMessage)
124+
ElMessage.error(incorrectMessage)
127125
}).catch(() => { })
128126
)
129127
: null

src/background/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Copyright (c) 2021 Hengyang Zhang
3-
*
3+
*
44
* This software is released under the MIT License.
55
* https://opensource.org/licenses/MIT
66
*/
@@ -13,7 +13,7 @@ import VersionManager from "./version-manager"
1313
import ActiveTabListener from "./active-tab-listener"
1414
import badgeTextManager from "./badge-text-manager"
1515
import MessageDispatcher from "./message-dispatcher"
16-
import initLimitProcesser from "./limit-processor"
16+
import initLimitProcessor from "./limit-processor"
1717
import initCsHandler from "./content-script-handler"
1818
import { isBrowserUrl } from "@util/pattern"
1919
import BackupScheduler from "./backup-scheduler"
@@ -28,7 +28,7 @@ openLog()
2828
const messageDispatcher = new MessageDispatcher()
2929

3030
// Limit processor
31-
initLimitProcesser(messageDispatcher)
31+
initLimitProcessor(messageDispatcher)
3232

3333
// Content-script's request handler
3434
initCsHandler(messageDispatcher)

src/content-script/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Copyright (c) 2021 Hengyang Zhang
3-
*
3+
*
44
* This software is released under the MIT License.
55
* https://opensource.org/licenses/MIT
66
*/
@@ -43,7 +43,7 @@ async function main() {
4343
)
4444
tracker.init()
4545

46-
// Execute only one time
46+
// Execute only one time for each dom
4747
if (getOrSetFlag()) return
4848
if (!host) return
4949

src/content-script/locale.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Copyright (c) 2022 Hengyang Zhang
3-
*
3+
*
44
* This software is released under the MIT License.
55
* https://opensource.org/licenses/MIT
66
*/

src/guide/component/merge/target-table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const SITE_EXAMPLES: _SiteExample[] = [{
9191
original: 'es.news.google.com',
9292
ruleIdx: [2],
9393
}, {
94-
original: 'a.b.c.phontos.google.com',
94+
original: 'a.b.c.photos.google.com',
9595
ruleIdx: [2],
9696
}, {
9797
original: 'pass.hust.edu.cn',

src/manifest.ts

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
11
/**
22
* Copyright (c) 2021 Hengyang Zhang
3-
*
3+
*
44
* This software is released under the MIT License.
55
* https://opensource.org/licenses/MIT
66
*/
77

88
/**
99
* Build the manifest.json in chrome extension directory via this file
10-
*
10+
*
1111
* @author zhy
1212
* @since 0.0.1
1313
*/
14-
// Not use path alias in manifest.json
14+
// Not use path alias in manifest.json
1515
import packageInfo from "./package"
1616
import { OPTION_ROUTE } from "./app/router/constants"
1717
const { version, author: { name: author }, homepage } = packageInfo
1818

1919
const _default: chrome.runtime.ManifestV3 = {
20-
name: '__MSG_meta_marketName__',
21-
description: "__MSG_meta_description__",
22-
version,
23-
author,
24-
default_locale: 'en',
25-
homepage_url: homepage,
26-
manifest_version: 3,
27-
icons: {
28-
16: "static/images/icon.png",
29-
48: "static/images/icon.png",
30-
128: "static/images/icon.png"
31-
},
32-
background: {
33-
service_worker: 'background.js'
34-
},
35-
content_scripts: [
36-
{
37-
matches: [
38-
"<all_urls>"
39-
],
40-
js: [
41-
"content_scripts.js"
42-
],
43-
run_at: "document_start"
44-
}
45-
],
46-
permissions: [
47-
'storage',
48-
'tabs',
49-
'webNavigation',
50-
'contextMenus',
51-
'alarms',
52-
'scripting',
53-
],
54-
host_permissions: [
55-
"<all_urls>",
56-
],
57-
/**
58-
* @since 0.3.4
59-
*/
60-
optional_permissions: [
61-
'clipboardRead'
62-
],
63-
action: {
64-
default_popup: "static/popup.html",
65-
default_icon: "static/images/icon.png"
66-
},
67-
/**
68-
* @since 0.4.0
69-
*/
70-
options_page: 'static/app.html#' + OPTION_ROUTE
20+
name: '__MSG_meta_marketName__',
21+
description: "__MSG_meta_description__",
22+
version,
23+
author,
24+
default_locale: 'en',
25+
homepage_url: homepage,
26+
manifest_version: 3,
27+
icons: {
28+
16: "static/images/icon.png",
29+
48: "static/images/icon.png",
30+
128: "static/images/icon.png"
31+
},
32+
background: {
33+
service_worker: 'background.js'
34+
},
35+
content_scripts: [
36+
{
37+
matches: [
38+
"<all_urls>"
39+
],
40+
js: [
41+
"content_scripts.js"
42+
],
43+
run_at: "document_start"
44+
}
45+
],
46+
permissions: [
47+
'storage',
48+
'tabs',
49+
'webNavigation',
50+
'contextMenus',
51+
'alarms',
52+
'scripting',
53+
],
54+
host_permissions: [
55+
"<all_urls>",
56+
],
57+
/**
58+
* @since 0.3.4
59+
*/
60+
optional_permissions: [
61+
'clipboardRead'
62+
],
63+
action: {
64+
default_popup: "static/popup.html",
65+
default_icon: "static/images/icon.png"
66+
},
67+
/**
68+
* @since 0.4.0
69+
*/
70+
options_page: 'static/app.html#' + OPTION_ROUTE
7171
}
7272

7373
export default _default

0 commit comments

Comments
 (0)