feat: 时间优化 (#3330)
This commit is contained in:
1 parent
647719fab8
commit
71111b9611
4 files changed
+316
-126
No files matched your search
+45
-1
@@ -196,6 +196,49 @@ async function findText(
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取指定区域内的全部 OCR 文本。
|
||||
* 与 findText 不同,本方法不要求预先提供关键词,适合先识别再在内存中匹配候选项。
|
||||
*
|
||||
* @param {number} [x=0] OCR 区域左上角 X
|
||||
* @param {number} [y=0] OCR 区域左上角 Y
|
||||
* @param {number} [w=1920] OCR 区域宽度
|
||||
* @param {number} [h=1080] OCR 区域高度
|
||||
* @param {number} [attempts=1] OCR 尝试次数
|
||||
* @param {number} [interval=50] 每次 OCR 之间的等待间隔(毫秒)
|
||||
* @returns {Promise<string>} 按识别顺序拼接的文本,未识别到内容时返回空字符串
|
||||
*/
|
||||
async function ocrRegion(
|
||||
x = 0,
|
||||
y = 0,
|
||||
w = 1920,
|
||||
h = 1080,
|
||||
attempts = 1,
|
||||
interval = 50
|
||||
) {
|
||||
for (let i = 0; i < attempts; i++) {
|
||||
const gameRegion = captureGameRegion();
|
||||
try {
|
||||
const ro = RecognitionObject.Ocr(x, y, w, h);
|
||||
const results = gameRegion.findMulti(ro);
|
||||
const texts = [];
|
||||
|
||||
for (let j = 0; j < results.count; j++) {
|
||||
const result = results[j];
|
||||
if (result.isExist() && result.text) texts.push(result.text.trim());
|
||||
}
|
||||
|
||||
if (texts.length > 0) return texts.join(' ');
|
||||
} finally {
|
||||
gameRegion.dispose();
|
||||
}
|
||||
|
||||
if (i < attempts - 1) await sleep(interval);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用找文本并点击(OCR)
|
||||
* @param {string|string[]} text 目标文本(单个文本或文本列表,列表时需全部匹配)
|
||||
@@ -588,6 +631,7 @@ export {
|
||||
findImg,
|
||||
findImgAndClick,
|
||||
findText,
|
||||
ocrRegion,
|
||||
findTextAndClick,
|
||||
waitUntilImgAppear,
|
||||
waitUntilImgDisappear,
|
||||
@@ -596,4 +640,4 @@ export {
|
||||
isInMainUI,
|
||||
startMonthCardWatcher,
|
||||
openBag
|
||||
};
|
||||
};
|
||||
@@ -5,103 +5,256 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>圣遗物评分</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: transparent; }
|
||||
body { color: #f7f1df; font-family: "Microsoft YaHei", sans-serif; }
|
||||
.panel {
|
||||
position: fixed; top: 50%; left: 50%; width: calc(100% - 36px); max-width: 400px; padding: 21px;
|
||||
transform: translate(-50%, -50%);
|
||||
border: 1.5px solid rgba(231, 202, 132, .72); border-radius: 24px;
|
||||
background: linear-gradient(145deg, rgba(38, 42, 55, .94), rgba(21, 24, 33, .92));
|
||||
box-shadow: 0 21px 57px rgba(0, 0, 0, .42), inset 0 1.5px rgba(255, 255, 255, .08);
|
||||
}
|
||||
.header { text-align: center; }
|
||||
.title { color: #ead8a5; font-size: 24px; font-weight: 700; letter-spacing: 3px; }
|
||||
.score-row { margin: 18px 0 15px; text-align: center; }
|
||||
.score { color: #fff2ba; font-size: 60px; font-weight: 800; line-height: 1; text-shadow: 0 3px 18px rgba(232, 202, 120, .25); }
|
||||
.score.with-character { font-size: 32px; line-height: 1.25; }
|
||||
.grade { display: inline-block; margin-top: 11px; padding: 5px 15px; border: 1.5px solid currentColor; border-radius: 999px; color: #e8ca78; font-size: 18px; font-weight: 700; }
|
||||
.stats { margin-bottom: 14px; padding: 12px; border: 1px solid rgba(234, 216, 165, .22); border-radius: 10px; background: rgba(255, 255, 255, .035); }
|
||||
.stats-title { margin-bottom: 7px; color: #aeb7c9; font-size: 14px; text-align: center; }
|
||||
.stat-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 4px 6px; border-radius: 5px; font-size: 15px; }
|
||||
.stat-row:nth-child(odd) { background: rgba(255, 255, 255, .03); }
|
||||
.stat-row.main-stat { margin-bottom: 4px; color: #fff2ba; font-weight: 700; }
|
||||
.stat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.stat-value { color: #ead8a5; font-variant-numeric: tabular-nums; }
|
||||
.stat-row.unrecognized .stat-name, .stat-row.unrecognized .stat-value { color: #d99898; }
|
||||
.stat-row.pending .stat-name, .stat-row.pending .stat-value { color: #aeb7c9; }
|
||||
.characters { border-top: 1.5px solid rgba(255,255,255,.12); padding-top: 14px; }
|
||||
.characters-title { margin-bottom: 8px; color: #aeb7c9; font-size: 15px; text-align: center; }
|
||||
.character { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 5px 3px; border-radius: 6px; font-size: 17px; }
|
||||
.character:nth-child(odd) { background: rgba(255, 255, 255, .025); }
|
||||
.character span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.character-score { color: #ead8a5; font-variant-numeric: tabular-nums; }
|
||||
.empty { padding: 23px 0 9px; color: #aeb7c9; text-align: center; font-size: 17px; }
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
body {
|
||||
color: #f7f1df;
|
||||
font-family: "Microsoft YaHei", sans-serif;
|
||||
}
|
||||
|
||||
.panel-anchor {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.panel {
|
||||
width: calc(100% - 36px);
|
||||
max-width: 420px;
|
||||
padding: 21px;
|
||||
transform: scale(var(--dpi-scale, 1));
|
||||
transform-origin: center;
|
||||
pointer-events: auto;
|
||||
border: 1.5px solid rgba(231, 202, 132, .72);
|
||||
border-radius: 24px;
|
||||
background: linear-gradient(145deg, rgba(38, 42, 55, .94), rgba(21, 24, 33, .92));
|
||||
box-shadow: 0 21px 57px rgba(0, 0, 0, .42), inset 0 1.5px rgba(255, 255, 255, .08);
|
||||
}
|
||||
|
||||
.header {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.title {
|
||||
color: #ead8a5;
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 3px;
|
||||
}
|
||||
|
||||
.score-row {
|
||||
margin: 18px 0 15px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.score {
|
||||
color: #fff2ba;
|
||||
font-size: 69px;
|
||||
font-weight: 800;
|
||||
line-height: 1;
|
||||
text-shadow: 0 3px 18px rgba(232, 202, 120, .25);
|
||||
}
|
||||
|
||||
.score.with-character {
|
||||
font-size: 37px;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.grade {
|
||||
display: inline-block;
|
||||
margin-top: 11px;
|
||||
padding: 5px 15px;
|
||||
border: 1.5px solid currentColor;
|
||||
border-radius: 999px;
|
||||
color: #e8ca78;
|
||||
font-size: 21px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.stats {
|
||||
margin-bottom: 14px;
|
||||
padding: 12px;
|
||||
border: 1px solid rgba(234, 216, 165, .22);
|
||||
border-radius: 10px;
|
||||
background: rgba(255, 255, 255, .035);
|
||||
}
|
||||
|
||||
.stats-title {
|
||||
margin-bottom: 7px;
|
||||
color: #aeb7c9;
|
||||
font-size: 16px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.stat-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
gap: 10px;
|
||||
padding: 4px 6px;
|
||||
border-radius: 5px;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.stat-row:nth-child(odd) {
|
||||
background: rgba(255, 255, 255, .03);
|
||||
}
|
||||
|
||||
.stat-row.main-stat {
|
||||
margin-bottom: 4px;
|
||||
color: #fff2ba;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.stat-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
color: #ead8a5;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.stat-row.unrecognized .stat-name, .stat-row.unrecognized .stat-value {
|
||||
color: #d99898;
|
||||
}
|
||||
|
||||
.stat-row.pending .stat-name, .stat-row.pending .stat-value {
|
||||
color: #aeb7c9;
|
||||
}
|
||||
|
||||
.characters {
|
||||
border-top: 1.5px solid rgba(255, 255, 255, .12);
|
||||
padding-top: 14px;
|
||||
}
|
||||
|
||||
.characters-title {
|
||||
margin-bottom: 8px;
|
||||
color: #aeb7c9;
|
||||
font-size: 17px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.character {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
gap: 12px;
|
||||
padding: 5px 3px;
|
||||
border-radius: 6px;
|
||||
font-size: 19px;
|
||||
}
|
||||
|
||||
.character:nth-child(odd) {
|
||||
background: rgba(255, 255, 255, .025);
|
||||
}
|
||||
|
||||
.character span:first-child {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.character-score {
|
||||
color: #ead8a5;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding: 23px 0 9px;
|
||||
color: #aeb7c9;
|
||||
text-align: center;
|
||||
font-size: 19px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main class="panel">
|
||||
<div class="header">
|
||||
<div class="title">圣遗物评分</div>
|
||||
<div class="panel-anchor">
|
||||
<main class="panel">
|
||||
<div class="header">
|
||||
<div class="title">圣遗物评分</div>
|
||||
</div>
|
||||
<div id="empty" class="empty">请打开圣遗物详情界面</div>
|
||||
<section id="result" hidden>
|
||||
<div class="score-row">
|
||||
<div id="score" class="score">0.0</div>
|
||||
<div id="grade" class="grade">D</div>
|
||||
</div>
|
||||
<div id="empty" class="empty">请打开圣遗物详情界面</div>
|
||||
<section id="result" hidden>
|
||||
<div class="score-row">
|
||||
<div id="score" class="score">0.0</div>
|
||||
<div id="grade" class="grade">D</div>
|
||||
</div>
|
||||
<div class="stats">
|
||||
<div class="stats-title">识别词条</div>
|
||||
<div id="main-stat"></div>
|
||||
<div id="sub-stat-list"></div>
|
||||
</div>
|
||||
<div class="characters">
|
||||
<div class="characters-title">适配角色</div>
|
||||
<div id="character-list"></div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
<script>
|
||||
const byId = (id) => document.getElementById(id)
|
||||
const escapeHtml = (value) => String(value ?? '')
|
||||
.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')
|
||||
.replaceAll('"', '"').replaceAll("'", ''')
|
||||
<div class="stats">
|
||||
<div class="stats-title">识别词条</div>
|
||||
<div id="main-stat"></div>
|
||||
<div id="sub-stat-list"></div>
|
||||
</div>
|
||||
<div class="characters">
|
||||
<div class="characters-title">适配角色</div>
|
||||
<div id="character-list"></div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
<script>
|
||||
const byId = (id) => document.getElementById(id)
|
||||
const escapeHtml = (value) => String(value ?? '')
|
||||
.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')
|
||||
.replaceAll('"', '"').replaceAll("'", ''')
|
||||
|
||||
function render(data) {
|
||||
if (!data || data.waiting) {
|
||||
byId('empty').hidden = false
|
||||
byId('result').hidden = true
|
||||
return
|
||||
}
|
||||
// BetterGI 的 HTML 遮罩会继承系统 DPI;反向缩放可保持面板物理尺寸稳定。
|
||||
function applyDpiScale() {
|
||||
const dpr = window.devicePixelRatio || 1
|
||||
document.documentElement.style.setProperty('--dpi-scale', String(1 / dpr))
|
||||
}
|
||||
|
||||
const score = byId('score')
|
||||
score.classList.toggle('with-character', Boolean(data.character))
|
||||
score.textContent = data.character
|
||||
? `${data.character.name}:${Number(data.character.score || 0).toFixed(1)}`
|
||||
: Number(data.score || 0).toFixed(1)
|
||||
byId('grade').textContent = data.grade || '-'
|
||||
const stats = data.artifactStats || { main: {}, subs: [] }
|
||||
byId('main-stat').innerHTML = `<div class="stat-row main-stat"><span class="stat-name">${escapeHtml(stats.main?.name || '主词条未识别')}</span><span class="stat-value">${escapeHtml(stats.main?.value || '--')}</span></div>`
|
||||
byId('sub-stat-list').innerHTML = (stats.subs || []).map((item) => {
|
||||
const stateClass = item.name === '未识别' ? ' unrecognized' : item.name === '待激活' ? ' pending' : ''
|
||||
return `<div class="stat-row${stateClass}"><span class="stat-name">${escapeHtml(item.name)}</span><span class="stat-value">${escapeHtml(item.value)}</span></div>`
|
||||
}).join('')
|
||||
byId('character-list').innerHTML = (data.characters || []).map((item) =>
|
||||
`<div class="character"><span>${escapeHtml(item.name)}</span><span class="character-score">${Number(item.score || 0).toFixed(1)}</span></div>`
|
||||
).join('') || '<div class="empty">暂无适配角色</div>'
|
||||
byId('empty').hidden = true
|
||||
byId('result').hidden = false
|
||||
applyDpiScale()
|
||||
window.addEventListener('resize', applyDpiScale)
|
||||
|
||||
function render(data) {
|
||||
if (!data || data.waiting) {
|
||||
byId('empty').hidden = false
|
||||
byId('result').hidden = true
|
||||
return
|
||||
}
|
||||
|
||||
if (window.htmlMask) {
|
||||
window.htmlMask.onMessage = (message) => {
|
||||
if (message.url === '/score') render(message.data?.data || message.data)
|
||||
if (message.url === '/visibility') {
|
||||
const data = message.data?.data || message.data
|
||||
document.body.style.display = data?.visible === false ? 'none' : ''
|
||||
}
|
||||
const score = byId('score')
|
||||
score.classList.toggle('with-character', Boolean(data.character))
|
||||
score.textContent = data.character
|
||||
? `${data.character.name}:${Number(data.character.score || 0).toFixed(1)}`
|
||||
: Number(data.score || 0).toFixed(1)
|
||||
byId('grade').textContent = data.grade || '-'
|
||||
const stats = data.artifactStats || {main: {}, subs: []}
|
||||
byId('main-stat').innerHTML = `<div class="stat-row main-stat"><span class="stat-name">${escapeHtml(stats.main?.name || '主词条未识别')}</span><span class="stat-value">${escapeHtml(stats.main?.value || '--')}</span></div>`
|
||||
byId('sub-stat-list').innerHTML = (stats.subs || []).map((item) => {
|
||||
const stateClass = item.name === '未识别' ? ' unrecognized' : item.name === '待激活' ? ' pending' : ''
|
||||
return `<div class="stat-row${stateClass}"><span class="stat-name">${escapeHtml(item.name)}</span><span class="stat-value">${escapeHtml(item.value)}</span></div>`
|
||||
}).join('')
|
||||
byId('character-list').innerHTML = (data.characters || []).map((item) =>
|
||||
`<div class="character"><span>${escapeHtml(item.name)}</span><span class="character-score">${Number(item.score || 0).toFixed(1)}</span></div>`
|
||||
).join('') || '<div class="empty">暂无适配角色</div>'
|
||||
byId('empty').hidden = true
|
||||
byId('result').hidden = false
|
||||
}
|
||||
|
||||
if (window.htmlMask) {
|
||||
window.htmlMask.onMessage = (message) => {
|
||||
if (message.url === '/score') render(message.data?.data || message.data)
|
||||
if (message.url === '/visibility') {
|
||||
const data = message.data?.data || message.data
|
||||
document.body.style.display = data?.visible === false ? 'none' : ''
|
||||
}
|
||||
}
|
||||
</script>
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* 所有坐标均基于 BetterGI 的 1920x1080 标准截图。
|
||||
*/
|
||||
import { findImg, findText } from "../../../packages/utils/tool.js"
|
||||
import { findImg, findText, ocrRegion } from "../../../packages/utils/tool.js"
|
||||
import scoreData, {
|
||||
analyzeArtifact,
|
||||
calcArtifactScore,
|
||||
@@ -18,7 +18,7 @@ const MASK_PATH = "assets/score-mask.html"
|
||||
const MASK_ID_PREFIX = "artiscope-score"
|
||||
const BACK_TEMPLATE = "assets/images/back.png"
|
||||
const POLL_INTERVAL = 500
|
||||
const TYPE_SETTLE_DELAY = 300
|
||||
const TYPE_SETTLE_DELAY = 50
|
||||
const CHARACTER_SCAN_BUDGET = 2000
|
||||
|
||||
const REGIONS = {
|
||||
@@ -48,7 +48,6 @@ const SUB_STAT_NAMES = [
|
||||
"暴击率", "暴击伤害", "攻击力", "防御力", "生命值",
|
||||
"元素精通", "元素充能效率"
|
||||
]
|
||||
const DIGITS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
|
||||
const CHARACTER_NAMES = Object.keys(scoreData.usefulAttr).sort((a, b) => b.length - a.length)
|
||||
const CHARACTER_ELEMENT_MAP = scoreData.charElemMap || {}
|
||||
const ELEMENTS = [
|
||||
@@ -163,6 +162,12 @@ async function findAnyText(keywords, region) {
|
||||
return null
|
||||
}
|
||||
|
||||
/** 将一次区域 OCR 的结果与候选词匹配,不再为每个候选词重复 OCR。 */
|
||||
function matchKnownText(text, candidates) {
|
||||
const normalized = String(text || "").replace(/\s/g, "")
|
||||
return candidates.find(candidate => normalized.includes(candidate.replace(/\s/g, ""))) || ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 分批扫描角色名。单轮达到时间预算后保存索引,下一轮继续,
|
||||
* 防止较慢电脑一次执行上百次 OCR 时表现为长时间卡死。
|
||||
@@ -188,12 +193,13 @@ async function scanCharacterNames(region) {
|
||||
|
||||
/** 读取圣遗物部位,并转换为评分模块使用的 0~4 索引。 */
|
||||
async function readArtifactPosition() {
|
||||
const result = await findAnyText(POSITION_NAMES, REGIONS.position)
|
||||
if (!result) return null
|
||||
const text = await ocrRegion(...REGIONS.position, 1, 0)
|
||||
const name = matchKnownText(text, POSITION_NAMES)
|
||||
if (!name) return null
|
||||
|
||||
return {
|
||||
name: result.keyword,
|
||||
pos: POSITION_NAMES.indexOf(result.keyword)
|
||||
name,
|
||||
pos: POSITION_NAMES.indexOf(name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,8 +346,8 @@ function getSubStatKey(name, hasPercent) {
|
||||
|
||||
/** 读取一条副词条;待激活和未识别项以 0 分占位。 */
|
||||
async function readSubStat(region, index) {
|
||||
const pending = await findText("待激活", ...region, 1, 0)
|
||||
if (pending) {
|
||||
const text = await ocrRegion(...region, 1, 0)
|
||||
if (text.includes("待激活")) {
|
||||
return {
|
||||
key: `待激活${index + 1}`,
|
||||
value: 0,
|
||||
@@ -350,8 +356,8 @@ async function readSubStat(region, index) {
|
||||
}
|
||||
}
|
||||
|
||||
const stat = await findAnyText(SUB_STAT_NAMES, region)
|
||||
if (!stat) {
|
||||
const statName = matchKnownText(text, SUB_STAT_NAMES)
|
||||
if (!statName) {
|
||||
return {
|
||||
key: `未识别${index + 1}`,
|
||||
value: 0,
|
||||
@@ -360,35 +366,21 @@ async function readSubStat(region, index) {
|
||||
}
|
||||
}
|
||||
|
||||
let value = parseNumber(stat.text)
|
||||
let valueText = stat.text
|
||||
if (!Number.isFinite(value)) {
|
||||
const numberResult = await findAnyText(DIGITS, region)
|
||||
if (!numberResult) {
|
||||
return {
|
||||
key: `未识别${index + 1}`,
|
||||
value: 0,
|
||||
name: stat.keyword,
|
||||
displayValue: "--"
|
||||
}
|
||||
}
|
||||
valueText = numberResult.text
|
||||
value = parseNumber(valueText)
|
||||
}
|
||||
const value = parseNumber(text)
|
||||
if (!Number.isFinite(value)) {
|
||||
return {
|
||||
key: `未识别${index + 1}`,
|
||||
value: 0,
|
||||
name: stat.keyword,
|
||||
name: statName,
|
||||
displayValue: "--"
|
||||
}
|
||||
}
|
||||
|
||||
const hasPercent = /[%%]/.test(`${stat.text}${valueText}`)
|
||||
const hasPercent = /[%%]/.test(text)
|
||||
return {
|
||||
key: getSubStatKey(stat.keyword, hasPercent),
|
||||
key: getSubStatKey(statName, hasPercent),
|
||||
value,
|
||||
name: stat.keyword,
|
||||
name: statName,
|
||||
displayValue: formatStatValue(value, hasPercent, true)
|
||||
}
|
||||
}
|
||||
@@ -398,11 +390,12 @@ async function readSubStat(region, index) {
|
||||
* 若前后不一致则丢弃本轮,防止切换动画混入新旧数据。
|
||||
*/
|
||||
async function readArtifactFromOcr(position) {
|
||||
const mainStat = await findAnyText(MAIN_STAT_NAMES, REGIONS.mainName)
|
||||
const mainValueResult = await findAnyText(DIGITS, REGIONS.mainValue)
|
||||
if (!mainStat || !mainValueResult) return null
|
||||
const mainNameText = await ocrRegion(...REGIONS.mainName, 1, 0)
|
||||
const mainName = matchKnownText(mainNameText, MAIN_STAT_NAMES)
|
||||
const mainValueText = await ocrRegion(...REGIONS.mainValue, 1, 0)
|
||||
if (!mainName || !mainValueText) return null
|
||||
|
||||
const mainValue = parseNumber(mainValueResult.text)
|
||||
const mainValue = parseNumber(mainValueText)
|
||||
if (!Number.isFinite(mainValue)) return null
|
||||
|
||||
const subs = {}
|
||||
@@ -419,9 +412,9 @@ async function readArtifactFromOcr(position) {
|
||||
|
||||
const artifact = {
|
||||
pos: position.pos,
|
||||
main: mainStat.keyword,
|
||||
main: mainName,
|
||||
value: mainValue,
|
||||
mainDisplayValue: formatStatValue(mainValue, /[%%]/.test(mainValueResult.text)),
|
||||
mainDisplayValue: formatStatValue(mainValue, /[%%]/.test(mainValueText)),
|
||||
subs,
|
||||
subStats
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "圣遗物实时评分",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"bgi_version": "0.61.2",
|
||||
"description": "在角色圣遗物界面通过浮窗实时显示圣遗物的评分",
|
||||
"authors": [
|
||||
|
||||
Reference in new issue
Block a user