0

So I want to make a script like this:

window.location = "http://m.roblox.com/Catalog/VerifyPurchase?assetid=122174821&type=robux&expectedPrice=1"
document.getElementsByClassName('buyButtonClass')[1].click()

but I don't know how to make the page refresh and the code start over without it having to manually be entered again Thanks

By the way it will be running in Google Chrome Dev. tools Console

I tried

function blah() {
// window.location = "http://m.roblox.com/Catalog/VerifyPurchase?
assetid=122174821&type=robux&expectedPrice=1"
document.getElementsByClassName('buyButtonClass')[1].click()
if (some_condition) {
blah() // rerun the code
}
}

Output was "undefined", the script did nothing.

The script goes to a link, clicks a button (currently it doesn't click for some reason) then restarts the script (not working)

11
  • are you trying to call the blah() function on button click? Commented Jul 27, 2013 at 5:14
  • No I am trying to make it click a button Commented Jul 27, 2013 at 5:16
  • 3
    Sounds strange, tell us your purpose instead. Commented Jul 27, 2013 at 5:18
  • Please give us the big picture, why are you refreshing the page? why do you need to click the button? Commented Jul 27, 2013 at 5:20
  • I agree, let's see what your purpose is first. May want to reconsider the approach / flow. Commented Jul 27, 2013 at 5:20

1 Answer 1

1

setting window.location = ... will refresh the page, but stuff after that will not trigger, because you just refreshed the page including all the javascript. You can put the code you want to trigger in a $(document).ready(function(){your_code_here}); call and when the page refreshes, it will set up your click event.

Sign up to request clarification or add additional context in comments.

3 Comments

What would the completed script look like?
Let's focus on the big picture like @Anderson suggested first in the comments to your question above.
It is a bot that presses a buy button on the page, and it refreshes because the buy button might not be there – Notheir 1 min ago edit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.