Skip to content

Commit

Permalink
wait a bit longer for screen to render
Browse files Browse the repository at this point in the history
  • Loading branch information
edsu committed Mar 18, 2021
1 parent 8cf8267 commit 95d886e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions anon.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function isRepeat(edit) {
async function takeScreenshot(url) {
const browser = await puppeteer.launch({headless: true, defaultViewport: null})
const page = await browser.newPage()
await page.goto(url, {waitUntil: 'networkidle2'})
await page.goto(url, {waitUntil: 'networkidle0'})
await page.setViewport({width: 1024, height: 768})

const filename = Date.now() + '.png'
Expand Down Expand Up @@ -148,6 +148,7 @@ async function sendStatus(account, status, edit) {

if (!argv.noop && (!account.throttle || !isRepeat(edit))) {

// get a screenshot of the diff
const screenshot = await takeScreenshot(edit.url)

// Mastodon
Expand All @@ -162,7 +163,11 @@ async function sendStatus(account, status, edit) {
await mastodon.post(
'statuses',
{'status': status, media_ids: [response.data.id]},
err => console.log(`mastodon post failed: ${err}`)
err => {
if (err) {
console.log(`mastodon post failed: ${err}`)
}
}
)
}

Expand Down Expand Up @@ -196,10 +201,12 @@ async function sendStatus(account, status, edit) {
console.log(err)
}
})
fs.unlinkSync(screenshot)
})
})
}

// screenshot no longer needed
fs.unlinkSync(screenshot)
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Tweet anonymous edits to Wikipedia from IP ranges.",
"homepage": "http://github.com/edsu/anon",
"license": "CC0-1.0",
"version": "0.1.0",
"version": "0.1.1",
"dependencies": {
"async": "^2.6.3",
"ip-address": "^5.9.4",
Expand Down

0 comments on commit 95d886e

Please sign in to comment.