I am relatively new to javascript and I want to code a javascript-bookmarklet which is able to rewrite a URL from
http://www.xyz.com/test/stuff/video129852_zc-7931f8bf_zs-2d7967f4.html
to
http://www.xyz.com/other-directory-thing/video129852.html
in the browser.
I want to replace the two directories "test/stuff" with one "other-directory-thing" and erase everything in the URL from the "_" to the .html at the end.
Can anyone help me? Thanks a lot! :)
javascript:(function() {window.location=window.location.toString().replace(/^http://www.xyz.com/test/stuff/,'http://www.xyz.com/other-directory-thing');})()
I can at least manipulate the first part of the URL. Any ideas how I can erase the part from the "_" to ".html"?
– Martin Jun 18 '13 at 13:51