Open
Description
Describe the bug
I was trying to use singlefile in my puppeteer code and in some sites it lost some images.
To Reproduce
This issue can be reproduced in https://image.baidu.com/
I got correct result when using chrome extension:

But with my codes:

Minimal reproducible codes:
const fs = require('fs')
const puppeteer = require('puppeteer')
// downloaded from https://github.com/gildas-lormeau/single-file-cli/blob/master/lib/single-file-bundle.js
// and modified its way to export, making it a cjs module
const { script } = require('./lib/single-file-bundle')
;(async () => {
const browser = await puppeteer.launch({
defaultViewport: {
width: 940,
height: 700
},
// in headful mode I can see all images are loaded
// but still lost those images
// headless: false
})
const pages = await browser.pages();
const page = pages[0];
await page.evaluateOnNewDocument(script);
await page.goto('https://image.baidu.com/', {
waitUntil: ['networkidle0']
})
// tried to sleep some times here but not working
const pageData = await page.evaluate(async () => {
// I guess that some configs are needed so I tried to use the DEFAULT_CONFIG in
// https://github.com/gildas-lormeau/SingleFile/blob/master/src/core/bg/config.js#L52
// but not working
return await singlefile.getPageData({})
});
fs.writeFileSync(`./test-${new Date().getTime()}.html`, pageData.content, { encoding: 'utf-8' })
await browser.close()
})()
Expected behavior
Puppeteer gets the same result as chrome extension
Screenshots
Environment
- OS: mbp m1 Sonoma 14.3.1
- Browser: Chrome
- Version: 131.0.6778.140
Additional context
Metadata
Metadata
Assignees
Labels
No labels