Author Topic: Greasemonkey Scripts  (Read 60 times)

Dragon

  • Administrator
  • Platinum Level
  • *****
  • Posts: 4696
  • Have you played my board game?
    • Rival Troops
Greasemonkey Scripts
« 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 {
    return;
    }
   
    console.log(url);
    window.location.replace(url);
}
"Hello IT. Have you tried turning it off and on again? ... OK, well, the button on the side. Is it glowing?... Yeah, you need to turn it on. Err, the button turns it on. Yeah, you do know how a button works, don't you? No, not on clothes." - Roy (The IT Crowd)