Skip to content

Commit 95d886e

Browse files
committed
wait a bit longer for screen to render
1 parent 8cf8267 commit 95d886e

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

anon.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function isRepeat(edit) {
117117
async 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

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Tweet anonymous edits to Wikipedia from IP ranges.",
44
"homepage": "https://github.com/edsu/anon",
55
"license": "CC0-1.0",
6-
"version": "0.1.0",
6+
"version": "0.1.1",
77
"dependencies": {
88
"async": "^2.6.3",
99
"ip-address": "^5.9.4",

0 commit comments

Comments
 (0)