Created
April 22, 2015 02:52
Revisions
-
cshtdd created this gist
Apr 22, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ javascript: var affiliateId = "YOUR_AFFILIATE_ID"; var l = window.location.href; var urlPieces = l.split("/"); var productId = getProductId("dp"); if (!productId){ productId = getProductId("product"); } if (productId){ var newurl = "http://www.amazon.com/dp/" + productId + "/?tag=" + affiliateId; alert(newurl); } function getProductId(prevKey){ for (var i = 0; i < urlPieces.length - 1; i++){ if (urlPieces[i].toLowerCase() == prevKey){ return urlPieces[i + 1]; } } }