@@ -117,7 +117,7 @@ function isRepeat(edit) {
117117async function takeScreenshot ( url ) {
118118 const browser = await puppeteer . launch ( { headless : true , defaultViewport : null } )
119119 const page = await browser . newPage ( )
120- await page . goto ( url , { waitUntil : 'networkidle2 ' } )
120+ await page . goto ( url , { waitUntil : 'networkidle0 ' } )
121121 await page . setViewport ( { width : 1024 , height : 768 } )
122122
123123 const filename = Date . now ( ) + '.png'
@@ -148,6 +148,7 @@ async function sendStatus(account, status, edit) {
148148
149149 if ( ! argv . noop && ( ! account . throttle || ! isRepeat ( edit ) ) ) {
150150
151+ // get a screenshot of the diff
151152 const screenshot = await takeScreenshot ( edit . url )
152153
153154 // Mastodon
@@ -162,7 +163,11 @@ async function sendStatus(account, status, edit) {
162163 await mastodon . post (
163164 'statuses' ,
164165 { 'status' : status , media_ids : [ response . data . id ] } ,
165- err => console . log ( `mastodon post failed: ${ err } ` )
166+ err => {
167+ if ( err ) {
168+ console . log ( `mastodon post failed: ${ err } ` )
169+ }
170+ }
166171 )
167172 }
168173
@@ -196,10 +201,12 @@ async function sendStatus(account, status, edit) {
196201 console . log ( err )
197202 }
198203 } )
199- fs . unlinkSync ( screenshot )
200204 } )
201205 } )
202206 }
207+
208+ // screenshot no longer needed
209+ fs . unlinkSync ( screenshot )
203210 }
204211}
205212
0 commit comments