@@ -5,10 +5,13 @@ let _page: Page | null;
55async function getPage ( ) {
66 if ( _page ) return _page ;
77 const options = {
8- args : chromium . args ,
9- defaultViewport : chromium . defaultViewport ,
10- executablePath : await chromium . executablePath ( ) ,
11- headless : chromium . headless ,
8+ args : [ ...chromium . args , '--hide-scrollbars' , '--disable-web-security' ] ,
9+ defaultViewport : chromium . defaultViewport ,
10+ executablePath : await chromium . executablePath (
11+ `https://github.com/Sparticuz/chromium/releases/download/v116.0.0/chromium-v116.0.0-pack.tar`
12+ ) ,
13+ headless : chromium . headless ,
14+ ignoreHTTPSErrors : true ,
1215 } ;
1316 const browser = await launch ( options ) ;
1417 _page = await browser . newPage ( ) ;
@@ -18,8 +21,12 @@ async function getPage() {
1821export async function getScreenshot ( url , width , height ) {
1922 const page = await getPage ( ) ;
2023 await page . setViewport ( { width : Number ( width ) || 1280 , height : Number ( height ) || 720 , deviceScaleFactor : 2 } ) ;
21- await page . goto ( url ) ;
24+ await page . goto ( url , {
25+ waitUntil : 'domcontentloaded' ,
26+ } ) ;
2227 await new Promise ( r => setTimeout ( r , 5000 ) ) ;
2328 const file = await page . screenshot ( ) ;
2429 return file ;
2530}
31+
32+
0 commit comments