diff options
author | makefu <github@syntax-fehler.de> | 2013-01-14 14:46:22 +0100 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2013-01-14 14:46:22 +0100 |
commit | dbe2d838ba6834788265029162b2dd7d82473335 (patch) | |
tree | a4eb38f7fc91d91269b6f83453de62242c6ddc23 /gold | |
parent | 5a782f6c8f7923f9f415afd504ce6e71acbc7fef (diff) | |
parent | abf9916bc1add17888308877fa4eb9da330297ef (diff) |
Merge branch 'master' of github.com:krebscode/painload
Conflicts:
god/temper/Makefile
god/temper/collectd-temper.sh
Diffstat (limited to 'gold')
-rw-r--r-- | gold/affiliate/README.md | 9 | ||||
-rw-r--r-- | gold/affiliate/affiliate.user.js | 96 |
2 files changed, 105 insertions, 0 deletions
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 diff --git a/gold/affiliate/affiliate.user.js b/gold/affiliate/affiliate.user.js new file mode 100644 index 00000000..57d51f1f --- /dev/null +++ b/gold/affiliate/affiliate.user.js @@ -0,0 +1,96 @@ +// ==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.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 +// @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); + } + } + + } +})(); |