From 8bed009c849aec970b92566936e9dccdd8c93181 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Sat, 31 May 2014 11:16:12 -0700 Subject: [PATCH] browser: add Firebug color support --- browser.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/browser.js b/browser.js index 4ce55cb..96a2985 100644 --- a/browser.js +++ b/browser.js @@ -30,11 +30,19 @@ var colors = [ var prevColor = 0; /** - * Currently only WebKit-based Web Inspectors are known - * to support "%c" CSS customizations. + * Currently only WebKit-based Web Inspectors and the Firebug + * extension (*not* the built-in Firefox web inpector) are + * known to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors */ -var useColors = 'WebkitAppearance' in document.documentElement.style; +var useColors = + // is webkit? http://stackoverflow.com/a/16459606/376773 + ('WebkitAppearance' in document.documentElement.style) || + // is firebug? http://stackoverflow.com/a/398120/376773 + (window.console && (console.firebug || (console.exception && console.table))); + /** * Select a color.