Difference between revisions of "Amazon"

From Makers Local 256
Jump to: navigation, search
(Firefox: added new step for enabling grease monkey)
(Source: added alternative installation steps)
Line 28: Line 28:
  
 
= Source =
 
= Source =
 +
 +
If the user script file is unavailable, you can open up a text editor and paste this source code in.
 +
Make sure the file has the extension .user.js  (ex:  something.user.js)
 +
Drag the file into your web browser, if greasemonkey is installed correctly it will pop up an installation page.
 +
 +
 
<pre>
 
<pre>
 
// ==UserScript==
 
// ==UserScript==

Revision as of 13:48, 20 June 2013

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

If the user script file is unavailable, you can open up a text editor and paste this source code in. Make sure the file has the extension .user.js (ex: something.user.js) Drag the file into your web browser, if greasemonkey is installed correctly it will pop up an installation page.


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