Initial commit
This commit is contained in:
27
skills/browser-tools/scripts/browser-screenshot.js
Executable file
27
skills/browser-tools/scripts/browser-screenshot.js
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { tmpdir } from "node:os"
|
||||
import { join } from "node:path"
|
||||
import puppeteer from "puppeteer-core"
|
||||
|
||||
const b = await puppeteer.connect({
|
||||
browserURL: "http://localhost:9222",
|
||||
defaultViewport: null,
|
||||
})
|
||||
|
||||
const p = (await b.pages()).at(-1)
|
||||
|
||||
if (!p) {
|
||||
console.error("✗ No active tab found")
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, "-")
|
||||
const filename = `screenshot-${timestamp}.png`
|
||||
const filepath = join(tmpdir(), filename)
|
||||
|
||||
await p.screenshot({ path: filepath })
|
||||
|
||||
console.log(filepath)
|
||||
|
||||
await b.disconnect()
|
||||
Reference in New Issue
Block a user