Skip to content

Instantly share code, notes, and snippets.

@avescodes
Created May 18, 2010 14:27
Show Gist options
  • Save avescodes/405062 to your computer and use it in GitHub Desktop.
Save avescodes/405062 to your computer and use it in GitHub Desktop.
// ==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