如何在autoddl.com网站上使用JavaScript生成生成器链接

I want make generator link with JavaScript, similar to what this site did: autoddl.com.

I just want to change the domain only, for example:

www.qwerty.com/detail/dsa8e2w2a1 to www.download.com/detail/dsa8e2w2a1 ~

/detail/dsa8e2w2a1 < is unchanged, only the primary domain being changed.

Please help, I've tried searching it up but dont know the keyword.

Split the url using split method, which will create an array , now replace the the first value of the array with the new host name and then use array#join method to form the new string.

var originalAdd = "www.qwerty.com/detail/dsa8e2w2a1";
var newDomainName = "www.download.com";
var x = originalAdd.split("/");
x[0] = newDomainName;
console.log(x.join('/'));

Alternatively you can also location.host which will give "www.qwerty.com" & location.pathname which will give "/detail/dsa8e2w2a1" & replace location.host with the new host

</div>