Dragons Hobbies Forum

General Category => General Discussions => Topic started by: Dragon on December 28, 2021, 12:08:11

Title: Greasemonkey Scripts
Post by: Dragon on December 28, 2021, 12:08:11
I'm going to use this thread to keep track of my favorite Greasemonkey Scripts that were written by other people.

Of course, if you're here looking for Greasemonkey Scripts, you might also be interested in one I wrote for the Homeworlds game on SuperDuperGames.org. Go to https://www.dragonshobbies.com/forum/index.php?topic=25845.0 for that one.

Now, back to my list of scripts by other people ...

AmazonSmile Redirect

I like this script because I've been using Amazon Smile to help support my kids' school and I've often forgotten to use the correct URL before, just going to amazon.com instead of smile.amazon.com. This takes care of the redirect, so that even when I go to make a quick purchase from Amazon, the school is still getting credit.

Source: https://gist.github.com/jdelamater99/92ef1373a82d17556fd2

Code: [Select]
// ==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 {