Add comment scrolling in capture (#1079)
* feat: add comment scrolling in capture * lint * feat use .waitForSelectore method * revert timeout
This commit is contained in:
parent
bc85a63091
commit
6a13c22ad2
|
@ -59,6 +59,9 @@ app.get('/*', async (req, res) => {
|
||||||
const url = new URL(req.originalUrl, captureUrl)
|
const url = new URL(req.originalUrl, captureUrl)
|
||||||
const timeLabel = `${Date.now()}-${url.href}`
|
const timeLabel = `${Date.now()}-${url.href}`
|
||||||
|
|
||||||
|
const urlParams = new URLSearchParams(url.search)
|
||||||
|
const commentId = urlParams.get('commentId')
|
||||||
|
|
||||||
let page, pages
|
let page, pages
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -87,6 +90,12 @@ app.get('/*', async (req, res) => {
|
||||||
await page.emulateMediaFeatures([{ name: 'prefers-color-scheme', value: 'dark' }])
|
await page.emulateMediaFeatures([{ name: 'prefers-color-scheme', value: 'dark' }])
|
||||||
await page.goto(url.href, { waitUntil: 'load', timeout })
|
await page.goto(url.href, { waitUntil: 'load', timeout })
|
||||||
console.timeLog(timeLabel, 'page loaded')
|
console.timeLog(timeLabel, 'page loaded')
|
||||||
|
|
||||||
|
if (commentId) {
|
||||||
|
console.timeLog(timeLabel, 'scrolling to comment')
|
||||||
|
await page.waitForSelector('.outline-it')
|
||||||
|
}
|
||||||
|
|
||||||
const file = await page.screenshot({ type: 'png', captureBeyondViewport: false })
|
const file = await page.screenshot({ type: 'png', captureBeyondViewport: false })
|
||||||
console.timeLog(timeLabel, 'screenshot complete')
|
console.timeLog(timeLabel, 'screenshot complete')
|
||||||
res.setHeader('Content-Type', 'image/png')
|
res.setHeader('Content-Type', 'image/png')
|
||||||
|
|
Loading…
Reference in New Issue