I'm working on a bookmarklet. I've got both parts working, but I don't know how to put them together.
Here are two URLs to parse:
http://bikes.trekbikes.co.jp/jp/ja/bikes/road/fitness/fx/7_3_fx/#/jp/ja/model/details?url=jp/ja/bikes/road/fitness/fx/7_3_fx
http://bikes.trekbikes.com.cn/cn/zh/bikes/road/fitness/fx/7_3_fx/#/cn/zh/model/details?url=cn/zh/bikes/road/fitness/fx/7_3_fx
I want a bookmarklet that will convert those two URLs into these answers:
http://www.trekbikes.com/nl/nl/bikes/road/fitness/fx/7_3_fx/#/nl/nl/model/details?url=nl/nl/bikes/road/fitness/fx/7_3_fx
http://www.trekbikes.com/nl/nl/bikes/road/fitness/fx/7_3_fx/#/nl/nl/model/details?url=nl/nl/bikes/road/fitness/fx/7_3_fx
Here is the first part of the answer:
javascr1pt:(function() {window.location=window.location.toString().replace(/(bikes.trekbikes.co.jp|bikes.trekbikes.com.cn)/,'www.trekbikes.com');})()
It replaces:
bikes.trekbikes.co.jp
or
bikes.trekbikes.com.cn
...with:
www.trekbikes.com
Here is the second part of the answer:
javascr1pt:(function() {window.location=window.location.toString().replace(/(jp\/ja\/|cn\/zh\/)/g,'nl/nl/');})()
It replaces all instances of:
jp/ja/
or
cn/zh/
...with:
nl/nl/
How can I combine these two parts into one bookmarklet? Many thanks in advance for any help!