Skip to content

Commit 165e937

Browse files
committed
browser: add colors support for Firefox >= v31
Part of debug-js#116.
1 parent e5a4ef2 commit 165e937

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

browser.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ exports.colors = [
2626
];
2727

2828
/**
29-
* Currently only WebKit-based Web Inspectors and the Firebug
30-
* extension (*not* the built-in Firefox web inpector) are
31-
* known to support "%c" CSS customizations.
29+
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
30+
* and the Firebug extension (any Firefox version) are known
31+
* to support "%c" CSS customizations.
3232
*
3333
* TODO: add a `localStorage` variable to explicitly enable/disable colors
3434
*/
@@ -37,7 +37,10 @@ function useColors() {
3737
// is webkit? http://stackoverflow.com/a/16459606/376773
3838
return ('WebkitAppearance' in document.documentElement.style) ||
3939
// is firebug? http://stackoverflow.com/a/398120/376773
40-
(window.console && (console.firebug || (console.exception && console.table)));
40+
(window.console && (console.firebug || (console.exception && console.table))) ||
41+
// is firefox >= v31?
42+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
43+
(navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
4144
}
4245

4346
/**

0 commit comments

Comments
 (0)