Basically, in my chrome extension, it creates a redirect on certain pages within a domain. This is indeed the behavior I want it to be doing. I do not want this changed - it is required.
What I want to do instead, is to have it so that when the user presses the back button, it goes back twice when the script is run - hence circumventing the issue.
See below for an example:
1) User visits http://domain.com/page1.html
2) User clicks on the page http://domain.com/page2.html
3) Browser extension script causes it to redirect to http://domain.com/page2.html&aaa immediately.
4a) When user presses back button once, it goes back to http://domain.com/page2.html which then redirects them back to http://domain.com/page2.html&aaa, making them frustrated.
4b) When user presses back button twice in a row, it goes back to http://domain.com/page1.html like they had intended to do.
What I want to do, is add something that causes it so that whatever pages the javascript which causes the redirect is run on, also makes it so that when a user clicks the back button once, it goes back twice.
Update:
Here is what I am working on:
function backTwo()
{
window.history.go(-2)
}
if {
[SOME CODE TO SAY THAT THE STRING &aaa EXISTS IN THE URL]
}
then {
[SOME CODE TO SAY RUN backTwo() FUNCTION]
}
else {
[SOME CODE TO SAY DO NOTHING]
}
I'm not really sure what to do next. I'm not really a javascript coder, I'm just trying to add this feature to the extension.
If you could give me an example, it would help a lot.