I'm trying to combine two bookmarklets into one so that it
Removes all url parameters (if any)
Redirects from one url to a sub domain.
Example:
From
http://www.justsomeurl.com/cat/article123?umt=sometimes-theres-a-parameter
To
http://cms.justsomeurl.com/.admin/something/cat/article123
I have two separate bookmarklets that does this but I haven't managed to combine them.
javascript:location.href = location.href.substring(0,location.href.lastIndexOf("?"));
and
javascript:(function() {window.location=window.location.toString().replace(/^https:\/\/www\.justsomeurl.com/,'http://cms.justsomeurl.com/.admin/');})()
I suspect a delay is needed between step 1 and 2.
I have tried this (and many combos) but it seems only the second function is picked up:
javascript:
function removeParameter(){ location.href = location.href.substring(0,location.href.lastIndexOf("?"));} ;
(function replace() {window.location=window.location.toString().replace(/^https:\/\/www\.justsomeurl.com/,'http://cms.justsomeurl.com/.admin/');})();
Any help is appreciated! Thanks!
I hope the following bookmarklet must work as needed:
javascript:(function() {
var url = location.href;
url = url.split("?")[0].replace("www.justsomeurl.com", "cms.justsomeurl.com/.admin/something");
location.href = url;
})();