Created
June 9, 2016 15:55
-
-
Save CosmicWebServices/02b06f3325783b0cc43e58febbb10232 to your computer and use it in GitHub Desktop.
scratchredirect
This file contains hidden or 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 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