63 lines
2.7 KiB
JavaScript
63 lines
2.7 KiB
JavaScript
const fs = require('fs')
|
|
const p = 'E:/SodiumPet/WorkPlace/v0.1.1/src/main/index.ts'
|
|
let c = fs.readFileSync(p, 'utf8')
|
|
|
|
function rep(from, to, label) {
|
|
if (!c.includes(from)) {
|
|
console.log('MISS:', label)
|
|
return
|
|
}
|
|
c = c.replace(from, to)
|
|
console.log('ok:', label)
|
|
}
|
|
|
|
// 编辑器:切到「等级」页 + 截图
|
|
rep(
|
|
` await editorWindow.webContents.executeJavaScript(
|
|
"[...document.querySelectorAll('.detail-tabs .set-tab')].find(b => b.textContent === '界面')?.click()"
|
|
)`,
|
|
` await editorWindow.webContents.executeJavaScript(
|
|
"[...document.querySelectorAll('.detail-tabs .set-tab')].find(b => b.textContent === '等级')?.click()"
|
|
)`,
|
|
'editor tab level'
|
|
)
|
|
rep(
|
|
` const stickerCount = await editorWindow.webContents.executeJavaScript(
|
|
"document.querySelectorAll('.sticker-cell').length"
|
|
)
|
|
fs.writeFileSync(path.join(HOME, 'data', 'stickers.txt'), String(stickerCount))`,
|
|
` const stickerCount = await editorWindow.webContents.executeJavaScript(
|
|
"document.querySelectorAll('.sticker-cell').length"
|
|
)
|
|
fs.writeFileSync(path.join(HOME, 'data', 'stickers.txt'), String(stickerCount))
|
|
const catCount = await editorWindow.webContents.executeJavaScript(
|
|
"JSON.stringify({ cells: document.querySelectorAll('.ped-cell').length, zones: document.querySelectorAll('.color-row').length, s: getComputedStyle(document.querySelector('.ped-cell')).backgroundColor })"
|
|
)
|
|
fs.writeFileSync(path.join(HOME, 'data', 'ped-stats.txt'), String(catCount))
|
|
const shot = await editorWindow.webContents.capturePage()
|
|
fs.writeFileSync(path.join(HOME, 'data', 'editor.png'), shot.toPNG())`,
|
|
'editor capture'
|
|
)
|
|
|
|
// 详情:等级预览截图(放在现有 dump 之后)
|
|
rep(
|
|
` await detailWindow.webContents.executeJavaScript(
|
|
"[...document.querySelectorAll('.level-mode .set-tab')].find(b => b.textContent.includes('化学'))?.click()"
|
|
)`,
|
|
` await detailWindow.webContents.executeJavaScript(
|
|
"[...document.querySelectorAll('.level-mode .set-tab')].find(b => b.textContent.includes('化学'))?.click()"
|
|
)
|
|
await new Promise((r) => setTimeout(r, 300))
|
|
{
|
|
const shot = await detailWindow.webContents.capturePage()
|
|
fs.writeFileSync(path.join(HOME, 'data', 'detail.png'), shot.toPNG())
|
|
const leg = await detailWindow.webContents.executeJavaScript(
|
|
"JSON.stringify([...document.querySelectorAll('.legend-item')].map(x => x.innerText.trim()))"
|
|
)
|
|
fs.writeFileSync(path.join(HOME, 'data', 'legend.txt'), String(leg))
|
|
}`,
|
|
'detail capture'
|
|
)
|
|
|
|
fs.writeFileSync(p, c, 'utf8')
|