0

Im trying to make a script for a game. Where I have to make just 2 clicks, but they are on different pages.

On page 1 I click on "Send"

javascript:document.getElementById('send').click();

When i click on that button, my page redirect to a "confirm" page. Where i need to click "Ok" button.

How can i do to click my first button and after redirect "auto click" the "Ok" button from the new page?

Federico Ribero
  • 309
  • 4
  • 20
  • 2
    Lol sounds like a malware author's dream – theonlygusti Oct 18 '16 at 23:50
  • You'll want to do it on document.ready, see the following: http://stackoverflow.com/questions/9899372/pure-javascript-equivalent-to-jquerys-ready-how-to-call-a-function-when-the – James111 Oct 18 '16 at 23:51

1 Answers1

0

If you also own the second page, you can have the window.onload method check against the url, for example look for the query string ?clickthrough=true (which your first page redirects to) and if it exists simulate a click of the button.

E.g., first page redirects to /second?clickthrough=true, and your javascript on the second page checks the url like this:

if (window.location.href.split("?").slice(-1)[0] == "clickthrough=true")
  // click the button

If you do not own the second page, then I'd hope there is no way to do this as it would suddenly open users to a whole host of vulnerabilities.

theonlygusti
  • 11,032
  • 11
  • 64
  • 119