@@ -117,7 +117,7 @@ function isRepeat(edit) {
117
117
async function takeScreenshot ( url ) {
118
118
const browser = await puppeteer . launch ( { headless : true , defaultViewport : null } )
119
119
const page = await browser . newPage ( )
120
- await page . goto ( url , { waitUntil : 'networkidle2 ' } )
120
+ await page . goto ( url , { waitUntil : 'networkidle0 ' } )
121
121
await page . setViewport ( { width : 1024 , height : 768 } )
122
122
123
123
const filename = Date . now ( ) + '.png'
@@ -148,6 +148,7 @@ async function sendStatus(account, status, edit) {
148
148
149
149
if ( ! argv . noop && ( ! account . throttle || ! isRepeat ( edit ) ) ) {
150
150
151
+ // get a screenshot of the diff
151
152
const screenshot = await takeScreenshot ( edit . url )
152
153
153
154
// Mastodon
@@ -162,7 +163,11 @@ async function sendStatus(account, status, edit) {
162
163
await mastodon . post (
163
164
'statuses' ,
164
165
{ '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
+ }
166
171
)
167
172
}
168
173
@@ -196,10 +201,12 @@ async function sendStatus(account, status, edit) {
196
201
console . log ( err )
197
202
}
198
203
} )
199
- fs . unlinkSync ( screenshot )
200
204
} )
201
205
} )
202
206
}
207
+
208
+ // screenshot no longer needed
209
+ fs . unlinkSync ( screenshot )
203
210
}
204
211
}
205
212
0 commit comments