Difference between revisions of "Amazon"

From Makers Local 256
Jump to: navigation, search
m (added link to example page to verify if the script is working.)
(Firefox: added new step for enabling grease monkey)
Line 13: Line 13:
 
== Firefox ==
 
== Firefox ==
 
# Go [https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/ here], install greasemonkey.  Restart Firefox.
 
# Go [https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/ here], install greasemonkey.  Restart Firefox.
 +
# Sometimes greasemonkey installs in disabled mode.  look for the monkey icon in the toolbar.  If it is grayed out, you need to click it to enable greasemonkey.  The icon should be full color now. 
 
# Click on this [https://dev.throwthemind.com/ml256_affiliate/ml256_affiliate.user.js link].  If greasemonkey is correctly installed, it will ask you if you want to install the script.  Restart Firefox browser.
 
# Click on this [https://dev.throwthemind.com/ml256_affiliate/ml256_affiliate.user.js link].  If greasemonkey is correctly installed, it will ask you if you want to install the script.  Restart Firefox browser.
 
# Go [https://dev.throwthemind.com/ml256_affiliate/example here], this will tell you if its working or not.
 
# Go [https://dev.throwthemind.com/ml256_affiliate/example here], this will tell you if its working or not.

Revision as of 17:21, 26 December 2012

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. Sometimes greasemonkey installs in disabled mode. look for the monkey icon in the toolbar. If it is grayed out, you need to click it to enable greasemonkey. The icon should be full color now.
  3. Click on this link. If greasemonkey is correctly installed, it will ask you if you want to install the script. Restart Firefox browser.
  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.

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);
                        }
                }
        }
})();