Amazon Code Snippet

This page has been deleted, most likely because it does not belong on the snippets wiki.
View Source | Edit Page


Creator: kiddohkiddoh

I use this code that searches for amazon affiliate links on a page and automatically complete the alt attributes

Instead of manually searching through links and manually adding the Alt attributes yourself, using this code will automate this process.

// In Javascript For multiple pages
<script>
var altAttr = document.getElementsByTagName("img");
var affiliateLinks = ["//ws-na.amazon-adsystem.com", "https://ir-na.amazon-adsystem.com"];
for(let i = 0; i < altAttr.length; i++) {

  var item = altAttr.item(i);
  if (item.alt == "" || altAttr.src == affiliateLinks){
    altAttr[i].alt = "Amazon Affiliate Link";
    console.log(altAttr.src);
  }
}
</script>

In action

link to the implemented solution on a Wikidot site or put a working example here

www.feenixbloom.com
Code Implemented on Website Affiliate Pages
Homepage, Products, News, Gaming and Updates Best For you! | Affiliate Product Reviews and Best Suggestions

Comments

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License