-
-
Save jdelamater99/92ef1373a82d17556fd2 to your computer and use it in GitHub Desktop.
// ==UserScript== | |
// @name AmazonSmile Redirect | |
// @namespace http://jdel.us | |
// @description Redirect Amazon to AmazonSmile | |
// @include http://*.amazon.*/* | |
// @include https://*.amazon.*/* | |
// @version 0.6 | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
var url = window.location.host; | |
if (url.match("smile.amazon") === null) { | |
url = window.location.href; | |
if (url.match("//www.amazon") !== null){ | |
url = url.replace("//www.amazon", "//smile.amazon"); | |
} else if (url.match("//amazon.") !== null){ | |
url = url.replace("//amazon.", "//smile.amazon."); | |
} else { | |
return; | |
} | |
console.log(url); | |
window.location.replace(url); | |
} |
this script includes sites that just include an amazon link in the url
ex: https://www.google.com/imgres?imgurl=http://ecx.images-amazon.com/images/I/41yuOQpV6pL._SX329_BO1,204,203,200_.jpg&imgrefurl=http://www.amazon.com/Trump-Estate-Received-Experts-Strategies/dp/1401605303&h=499&w=331&tbnid=Vpwswc9bwXV1cM:&docid=beMSu6YiYQa5fM&ei=5y_iVp6QO8mIjwPhw4ywAw&tbm=isch
Thanks bigmittens. I've updated the script to address this issue.
This seems not working with global amazon sites. ex: amazon.de
// @include http://*.amazon.*/*
// @include https://*.amazon.*/*
Changed this and it seems to work. At least I am redirected.
But since I am no expert, I don't know if this edit could cause any bugs.
Adding // @run-at document-start
may also help speed up the redirection by not waiting until the page has loaded.
Thanks for the recommendation.
Hi,
I made a couple little changes. I apparently can't submit a "pull request" to your project because it is a "gist" (I am new to git and to the terminology, so I'm not sure if I'm correctly saying what I mean to say), so I figured I'd write you this note in case you want to include my changes in your original project. The changes are:
(1) Stopped it from trying to work on inappropriate URLs (such as aws.amazon.com) - it would just loop trying to redirect to the original page itself over and over.
(2) Set it up to work on https as well as http.
If you'd like to look at my changes, my copy of this project can be found here:
https://gist.github.com/rwv37/3b079e6ec8dd34e6f2c7
Thanks for making this!