46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
|
|
const puppeteer = require('puppeteer-core');
|
||
|
|
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
||
|
|
|
||
|
|
(async () => {
|
||
|
|
const browser = await puppeteer.launch({
|
||
|
|
executablePath: '/usr/bin/chromium-browser',
|
||
|
|
headless: true,
|
||
|
|
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
||
|
|
});
|
||
|
|
|
||
|
|
const page = await browser.newPage();
|
||
|
|
page.on('console', msg => console.log('CONSOLE:', msg.type(), msg.text()));
|
||
|
|
page.on('pageerror', err => console.log('PAGEERROR:', err.message));
|
||
|
|
|
||
|
|
await page.goto('http://localhost:8765', { waitUntil: 'networkidle0' });
|
||
|
|
await sleep(1500);
|
||
|
|
|
||
|
|
// Check internal state
|
||
|
|
const stateInfo = await page.evaluate(() => {
|
||
|
|
return {
|
||
|
|
day: window._state?.day,
|
||
|
|
alive: window._state?.alive,
|
||
|
|
paused: window._state?.paused,
|
||
|
|
reincarnation: window._state?.reincarnation,
|
||
|
|
};
|
||
|
|
});
|
||
|
|
console.log('Internal state:', stateInfo);
|
||
|
|
|
||
|
|
// Try to manually tick
|
||
|
|
await page.evaluate(() => {
|
||
|
|
if (window._tick) {
|
||
|
|
window._tick(10);
|
||
|
|
console.log('Manual tick executed, day now:', window._state?.day);
|
||
|
|
} else {
|
||
|
|
console.log('tick function not exposed');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
await sleep(500);
|
||
|
|
|
||
|
|
const day = await page.$eval('#day', el => el.textContent).catch(() => 'N/A');
|
||
|
|
console.log('Day after manual tick:', day);
|
||
|
|
|
||
|
|
await browser.close();
|
||
|
|
})();
|