var links = document.getElementsByTagName("a"); for (var i = 0; i < links.length; i++) { var href = links[i].href; if (href.startsWith("http://www.example-domain.xy")) links[i].href = "https://www.amazon.com/start-page-with-myRef"; }
<a href="http://www.example-domain.xy/product-a">Product-A</a><br/> <a href="http://www.example-domain.xy/product-b">Product-B</a><br/> <a href="http://www.different-domain.com/product-c">Product-C</a><br/>
Question and answer is powered by AnsPress.io