Last active
April 4, 2024 08:25
-
-
Save jdelamater99/92ef1373a82d17556fd2 to your computer and use it in GitHub Desktop.
AmazonSmile Redirect (Greasemonkey Script)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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); | |
} |
Adding // @run-at document-start
may also help speed up the redirection by not waiting until the page has loaded.
Thanks for the recommendation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.