From 5176621efd96a793a5d67fcfc4136cc5301405d2 Mon Sep 17 00:00:00 2001 From: euer Date: Sat, 22 Dec 2012 03:07:52 +0100 Subject: add affiliate userscript --- gold/affiliate/affiliate.user.js | 95 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 gold/affiliate/affiliate.user.js (limited to 'gold') diff --git a/gold/affiliate/affiliate.user.js b/gold/affiliate/affiliate.user.js new file mode 100644 index 00000000..17e2ccfe --- /dev/null +++ b/gold/affiliate/affiliate.user.js @@ -0,0 +1,95 @@ +// ==UserScript== +// @name Krebs Affiliate Programs + extras (auto-SSL...) +// @namespace https://blogs.fsfe.org/h2/userscripts/ +// @description Modify Amazon to support Krebs, always use SSL and shorten links (only Amazon) + +// Contains the getASIN()-function from: +// http://userscripts.org/scripts/review/3284 by Jim Biancolo + +// shamelessly stolen from +// http://userscripts.org/scripts/show/129547 +// + +// @version 0.321 +// @include * +// @license CC0 / Do what the fuck you want to license +// see http://creativecommons.org/publicdomain/zero/1.0/ + +// @author Hannes Hauswedell +// @author makefu +// @homepage http://euer.krebsco.de +// ==/UserScript== + + + +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() +{ + var links = document.getElementsByTagName("a"); + + for (i = 0; i < links.length; i++) + { + var curLink = links[i].href; + + // AMAZON + if (curLink.match(/https?\:\/\/(www\.)?amazon\./i)) + { + var affiliateID = ''; + var host = ''; + if (curLink.match(/amazon\.de/i)) + { + host = 'amazon.de'; + affiliateID = 'krebsco-21'; + } + else if (curLink.match(/amazon\.co\.uk/i)) + { + host = 'amazon.co.uk'; + affiliateID = 'krebscode-21'; + } + else if (curLink.match(/amazon\.ca/i)) + { + host = 'amazon.ca'; + affiliateID = 'krebscoca-20'; + } + else if (curLink.match(/amazon\.fr/i)) + { + host = 'amazon.fr'; + affiliateID = 'krebscode01-21'; + } + else if (curLink.match(/amazon\.es/i)) + { + host = 'amazon.es'; + affiliateID = 'krebscode0f-21'; + } + else if (curLink.match(/amazon\.it/i)) + { + host = 'amazon.it'; + affiliateID = 'krebscode04-21'; + } + else if (curLink.match(/amazon\.com/i)) + { + host = 'amazon.com'; + affiliateID = 'krebsco-20'; + } + + var asin = getASIN(curLink); + if (affiliateID != '') + { + if (asin != null) + links[i].setAttribute("href", "https://www."+host+"/dp/" + asin + "/?tag="+affiliateID); +// else +// links[i].setAttribute("href", curLink + "?tag="+affiliateID); + } + } + + } +})(); -- cgit v1.2.3 From 3649aff46c8bace238c3cf22abcfbfe8be9dce8a Mon Sep 17 00:00:00 2001 From: euer Date: Sat, 22 Dec 2012 03:17:40 +0100 Subject: affiliate.user.js: update license, version --- gold/affiliate/affiliate.user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gold') diff --git a/gold/affiliate/affiliate.user.js b/gold/affiliate/affiliate.user.js index 17e2ccfe..57d51f1f 100644 --- a/gold/affiliate/affiliate.user.js +++ b/gold/affiliate/affiliate.user.js @@ -10,9 +10,10 @@ // http://userscripts.org/scripts/show/129547 // -// @version 0.321 +// @version 0.42 // @include * // @license CC0 / Do what the fuck you want to license +// see http://sam.zoy.org/wtfpl/ // see http://creativecommons.org/publicdomain/zero/1.0/ // @author Hannes Hauswedell -- cgit v1.2.3 From b2df392966df95102bb8cf4ee3f043d4b6ed633f Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 6 Jan 2013 04:58:06 +0000 Subject: add README for affiliate --- gold/affiliate/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 gold/affiliate/README.md (limited to 'gold') diff --git a/gold/affiliate/README.md b/gold/affiliate/README.md new file mode 100644 index 00000000..81a3d52c --- /dev/null +++ b/gold/affiliate/README.md @@ -0,0 +1,9 @@ +# Installation + +# Firefox +Step 1: [Install Greasemonkey](https://addons.mozilla.org/de/firefox/addon/greasemonkey/) +Step 2: Click on affiliate.user.js + +# Chrome +Step 1: download affiliate.user.js onto your desktop +Step 2: Open chrome->tools->extensions and drag affiliate.user.js into chrome window -- cgit v1.2.3