Skip to content

Commit

Permalink
* imagebin.org: replaced timeout kludge with a bit more proper callback
Browse files Browse the repository at this point in the history
  • Loading branch information
l29ah committed Nov 23, 2011
1 parent 0ee5821 commit f8805d9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions imagebin.org/imagebin
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ if (phantom.args.length !== 1) {
phantom.exit(); phantom.exit();
} else { } else {
fname = phantom.args[0]; fname = phantom.args[0];
var loads = 0;
page.open("http://imagebin.org/index.php?page=add", function () { page.open("http://imagebin.org/index.php?page=add", function () {
page.uploadFile('input[name=image]', fname); loads++;
page.evaluate(function () { if (loads == 2) {
document.querySelector('input[name=nickname]').value = 'phantom'; page.uploadFile('input[name=image]', fname);
document.querySelector('input[name=disclaimer_agree]').click() page.evaluate(function () {
document.querySelector('form').submit(); document.querySelector('input[name=nickname]').value = 'phantom';
}); document.querySelector('input[name=disclaimer_agree]').click()
window.setTimeout(function () { document.querySelector('form').submit();
});
}
if (loads == 4) {
page.onConsoleMessage = function(msg) { page.onConsoleMessage = function(msg) {
console.log(msg); console.log(msg);
}; };
page.evaluate(function () { page.evaluate(function () {
console.log(document.URL); console.log(document.URL);
}); });
phantom.exit(); phantom.exit();
}, 3000); }
}); });
} }

0 comments on commit f8805d9

Please sign in to comment.