Files
Obsidian/工具学习/车机诊断员 Agent/render-profile.cjs
T

45 lines
1.5 KiB
JavaScript
Raw Normal View History

2026-11-05 14:35:04 +08:00
const path = require("path");
const { pathToFileURL } = require("url");
const { chromium } = require("F:/software/Hermes/hermes-agent/node_modules/playwright");
(async () => {
const root = __dirname;
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({
viewport: { width: 1920, height: 1200 },
deviceScaleFactor: 1,
});
await page.goto(pathToFileURL(path.join(root, "profile-visual.html")).href, {
waitUntil: "load",
});
await page.evaluate(() => document.fonts.ready);
const profile = page.locator("#profile");
await profile.screenshot({
path: path.join(root, "Hermes-Agent-Profile.png"),
animations: "disabled",
});
const report = await page.evaluate(() => {
const sheet = document.querySelector("#profile");
const overflowing = [...sheet.querySelectorAll("*")]
.filter((el) => el.children.length === 0 && el.textContent.trim())
.filter((el) => el.scrollWidth > el.clientWidth + 1 || el.scrollHeight > el.clientHeight + 1)
.map((el) => el.textContent.trim().slice(0, 80));
return {
width: sheet.getBoundingClientRect().width,
height: sheet.getBoundingClientRect().height,
overflowX: sheet.scrollWidth > sheet.clientWidth,
overflowY: sheet.scrollHeight > sheet.clientHeight,
overflowing,
};
});
console.log(JSON.stringify(report, null, 2));
await browser.close();
})().catch((error) => {
console.error(error);
process.exitCode = 1;
});