mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-03-30 05:49:51 +08:00
* Create README.md * Create settings.json * Create manifest.json * Create main.js * Create Artifact.js * Create Constants.js * Create Parser.js * Create a.txt * Delete repo/js/OCRArtifacts/records/a.txt * Create a.txt * Create a.txt
17 lines
718 B
JavaScript
17 lines
718 B
JavaScript
async function parse(filePath) {
|
|
let content = file.readTextSync(filePath)
|
|
content = content.replace(/=+第(\d*)个圣遗物信息:/g, ';;;;;$1')
|
|
content = content.replace(/=+.*/g, '')
|
|
const arr = content.split(';;;;;')
|
|
const total = arr.shift().match(/圣遗物数量: (\d*),/)[1]
|
|
log.info(`total: ${total}`)
|
|
let result = []
|
|
while (arr.length > 0) {
|
|
result.push(new Artifact(arr.shift().trim().split('\n')))
|
|
}
|
|
let name = filePath.replace('artifact_log', 'parsed_result').replace('.txt', '.json')
|
|
file.WriteTextSync(name, JSON.stringify(result, null, 2), true)
|
|
log.info(`解析完成,请查看文件: ${name}`)
|
|
return new Promise((res, rej) => { res() })
|
|
}
|