Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@CosmicWebServices
Created June 9, 2016 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CosmicWebServices/02b06f3325783b0cc43e58febbb10232 to your computer and use it in GitHub Desktop.
Save CosmicWebServices/02b06f3325783b0cc43e58febbb10232 to your computer and use it in GitHub Desktop.
scratchredirect
// ==UserScript==
// @name Redirect scratch.mit.edu to staging.scratch.mit.edu
// @namespace scratchtostaging
// @description On any web page it will check if the clicked links goes to scratch.mit.edu. If so, the link will be rewritten to point to staging.scratch.mit.edu
// @include http://*.*
// @include https://*.*
// @exclude http://scratch.mit.edu/*
// @exclude https://scratch.mit.edu/*
// @version 1.0
// @grant none
// ==/UserScript==
// This will soon see if scratch is down if so it will redirect.
document.body.addEventListener('mousedown', function(e){
var targ = e.target || e.srcElement;
if ( targ && targ.href && targ.href.match(/https?:\/\/scratch.mit.edu/) ) {
targ.href = targ.href.replace(/https?:\/\/scratch.mit.edu/, 'https://staging.scratch.mit.edu/');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment