I have to test a web site, and I have wrote a tampermonkey
script that surf randomly the site and change parameters, sometimes I need to change page and if I change page with window.location.replace(URL)
or by pressing button with the script, for example document.getElementById('button_that_redirects').click()
the script stop to works after the new page is loaded.
How can I do to run a javascript
script that allow to change page during the execution? Have I to use an other program instead tampermonkey?
Asked
Active
Viewed 260 times
0

Andrea993
- 663
- 1
- 10
- 23
-
tampermonkey scripts are created to run on particular pages (exact match, or pattern match) - if you are not on a page that matches one of the `include` patterns in the script, the script wont run – Jaromanda X Nov 07 '15 at 16:07
-
And which program can I use to do this? – Andrea993 Nov 07 '15 at 16:08
-
@Andrea993 - write an web extension / chrome add-on / whatever google call it – Jaromanda X Nov 07 '15 at 16:11
1 Answers
0
If you have redirections happening on the same domain, you could let your script create a cookie with all necessary state information, so that when the script gets launched on the redirected page, your script can detect the cookie, get the necessary context from it, and continue with whatever it needs to do. You could for instance include js_cookie for this.
An alternative to using cookies would be an html5
local database.

trincot
- 317,000
- 35
- 244
- 286