This is basically a variant of Combining Bookmarklets to create a toggle between HTTP and HTTPS?
I would like to combine the following two bookmarklets into one:
javascript:q=(document.location.href);location=location.href.replace('dp','gp/aw/d')
javascript:q=(document.location.href);location=location.href.replace('gp/aw/d','dp')
i.e. basically switch between two directories on a server.
This does not work (or only for one of the cases, i.e. it does not switch the 'dp' case).
javascript:q=(document.location.href);location=location.href.replace('dp','gp/aw/d').replace('gp/aw/d','dp');
Any (regex) improvements, e.g. so that the toggle will only catch the first occurrence of 'dp' in the url are welcome.
Do you mean