Created
May 18, 2010 14:27
-
-
Save avescodes/405062 to your computer and use it in GitHub Desktop.
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 Panda Environment Reminder | |
// @namespace http://panda-build | |
// @description Color the user bar based on environment and remove annoying flash message | |
// @include http://localhost:3000/* | |
// @include http://panda-build/* | |
// @include https://panda-staging/* | |
// @include http://panda-*/* | |
// ==/UserScript== | |
(function() { | |
function setColor(color) { | |
document.getElementsByClassName("trigger")[0].style.backgroundColor = color; | |
} | |
switch(location.hostname) { | |
case "localhost": | |
setColor("green"); | |
break; | |
case "panda-build": | |
setColor("blue"); | |
break; | |
case "panda-staging": | |
setColor("red"); | |
break; | |
} | |
var envDiv = document.getElementById("environment"); | |
var env = envDiv.textContent.match(/Panda-(\w*)/)[1]; | |
switch(env) { | |
case "Development": | |
env = "dev"; | |
break; | |
case "Production": | |
env = "prd"; | |
break; | |
case "Staging": | |
env = "stg"; | |
break; | |
default: | |
if(env.length > 5) { | |
env = env.slice(0,5); | |
} | |
} | |
document.title = env + ": " + document.title; | |
envDiv.parentElement.removeChild(envDiv); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment