Amazon

From Makers Local 256
Revision as of 09:23, 6 April 2012 by Jimshoe (Talk | contribs)

Jump to: navigation, search

Found a userscript that does the same thing I think. I modified it with our affiliate code. It should work on Firefox, Chrome and any other browser that supports user scripts. With Firefox you need greasemonkey but with Chrome is should just install. Also check out userscripts.org for other useful scripts.

Resources

Firefox

Chrome

Instructions

Firefox

  1. Go here, install greasemonkey. Restart Firefox.
  2. Click on this link. If greasemonkey is correctly installed, it will ask you if you want to install the script. Restart Firefox browser.
  3. Go here, this will tell you if its working or not.
  4. Shop amazon.com normally
  5. You should see "makeloca256-20" in the url of the Amazon product you are looking at.

Chromium

  1. Click on this link.
  2. This doesn't actually need need your data on all sites, don't worry about that.
  3. Confirm install.
  4. Go here, this will tell you if its working or not.
  5. Shop amazon.com normally
  6. You should see "makeloca256-20" in the url of the Amazon product you are looking at

Source

// ==UserScript==
// @name           Makers Local 256 Amazon Affiliate script
// @namespace      
// @description   Support Makers Local 256 via an easy Chrome Amazon Affiliate script.

// This is just a modification of Kelly Nielsen's script at http://userscripts.org/scripts/show/74583

// @include       *

// @author JimShoe
// ==/UserScript==


var associateID = 'makeloca256-20';

function getASIN(href) {
  var asinMatch;
  asinMatch = href.match(/\/exec\/obidos\/ASIN\/(\w{10})/i);
  if (!asinMatch) { asinMatch = href.match(/\/gp\/product\/(\w{10})/i); }
  if (!asinMatch) { asinMatch = href.match(/\/exec\/obidos\/tg\/detail\/\-\/(\w{10})/i); }
  if (!asinMatch) { asinMatch = href.match(/\/dp\/(\w{10})/i); }
  if (!asinMatch) { return null; }
  return asinMatch[1];
}

function getDomain() {
        if (document.location.hostname.substr(0,4) == 'www.')
                return document.location.hostname.substr(4) ;
        return document.location.hostname ;
}

(function() {
        var allLinks = document.getElementsByTagName("a");

        var asin = '';
        var currentDomain = getDomain();
        var linkDomain = (currentDomain.match(/amazon\./i) ? currentDomain : "amazon.com");
        for (i = 0; i < allLinks.length; i++) {
           var href = allLinks[i].href;
           if (href.match(/amazon\./i)) {
                   asin = getASIN(href);
                   if (asin != null) {
                                allLinks[i].setAttribute("href", "http://"+linkDomain+"/o/ASIN/" + asin + "/ref=nosim/"+associateID);
                        }
                }
        }
})();