I want to use chrome snippet to run a javascript code to autofill a series of pages.
The problem is after another page was opened, the code seems stopped.
Instead, I need it run continually. Like this:
//Page 1 form
document.getElementById('page1Radiobutton').click()
//Click Next
document.getElementById('page1Next').click()
//Page 2 form (need run continually after page 1 was submitted, but now stop at here...)
document.getElementById('page2Radiobutton').click()
document.getElementById('page2Next').click()
I would look into browser extensions such as Tampermonkey (for Chrome) or Greasemonkey (for Firefox)
With either of these monkeys, you can create snippets of arbitrary javascript that will run on any page on the internet automatically.
If you are going to create a script that runs on every page, make sure it exits gracefully if it can't find the elements you're looking for. Otherwise you'll end up with javascript errors when you go to other pages.