As a web developer I'm constantly working on projects in different environments (local, staging, testing, production). I mostly work on Drupal projects. I can't tell you the number of times I've been led from local to production by just browsing the site. And then accidentally changing a setting on production that was really only supposed to be changed on my local environment.
So here's an idea: A Chrome theme that changes color depending on the sub domain of a site.
For example: on local.mysite.com* the browser chrome should be green, on staging.mysite.com* it should be blue, and on mysite.com* the color should be standard chrome grey.
This could avoid a lot of confusion for a lot of people working in different environments. Not only for developers, also for "content" people.
Sadly, I have no idea how to code a Chrome theme with that kind of behavior.
Chrome themes are great for changing the overall appearance of the UI, but if you want a more dynamic look, then you should go for New Tab extensions. It lets you customize the appearance with custom toolbars, live wallpapers, etc and brings some cool features to the new tab.
Green Eye Green Eye is a simple and efficient Google Chrome extension that keeps your eyes healthy by changing the background and foreground colors of web pages. It comes with three preset themes, but you can personalize it even more by choosing the text, background, and border color.
Navigate to chrome://flags and enable the #darken-websites-checkbox-in-theme-setting experiment. Then, tap the three dots menu, select Settings then Theme, and check the box with Apply Dark themes to sites, when possible.
Themes are not dynamic, so the solution is not straightforward.
It's possible to create the feature using the management API. At least three extension are needed:
chrome.tabs.onUpdated
event to listen for tab changes, and possibly save the state of known "theme-tabs" in a hash (by tabId). Don't forget to remove the tabId when the tab's URI is not "special" any more, using the delete
operator.chrome.tabs.onActivated
Warning: See below event, to listen for tab changes. This event is passed a windowId and tabId. Use the hash, created in step 2, to check whether the theme has to be changed or not.chrome.management.setEnabled
method.Alternative approach for step 3-4: Use Content scripts to call a method the background page. The match patterns can then be set in the manifest file, at the "content_scripts"
, "matches"
section.
Warning: The onActivated
event was not supported prior Chrome 18. Before Chrome 18, the event was called onActiveChanged
.
The extension as described in steps 2-4 requires the following permissions:
My solution is to use PHP to detect what server I am connected to and then update Administrative screens of my application (WordPress, Drupal etc.) with a specific color. You could also display a color bar at the top of local and staging sites as well.
Here is what I do for WordPress admin screens:
// determine if this is development, staging or production environment
if (strpos(home_url(),'http://localhost') !== false)
{
define('MY_ENVIRONMENT', 'DEV');
}
else if (strpos(home_url(),'<enter staging URL here>') !== false)
{
define('MY_ENVIRONMENT', 'STAGE');
}
else
{
define('MY_ENVIRONMENT', 'PROD');
}
And then I used this to show specific colors in WordPress admin screen:
function change_admin_color($result) {
return (MY_ENVIRONMENT== 'PROD' ? 'sunrise' : (MY_ENVIRONMENT== 'STAGE' ? 'ocean' : 'fresh'));
}
add_filter('get_user_option_admin_color','change_admin_color');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With