Created
May 13, 2015 00:39
-
-
Save mediaupstream/8b18d1986a5dc57010b7 to your computer and use it in GitHub Desktop.
console.rainbow.js
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
var _original_unmodified_console_log_thingy = console.log; | |
console.log = function(){ | |
var args = Array.prototype.slice.call(arguments); | |
var rainbow = ['red','orange','yellow','green','cyan','blue','purple','pink']; | |
var cindex = 0; | |
var style = 'font-family: "Comic Sans MS", "Comic Sans", cursive; font-size:18px;'; | |
var styles = []; | |
for(var i=0; i<args.length; i++){ | |
if (typeof args[i] == 'string'){ | |
var a = args[i].split('') | |
for(var j=0; j<a.length; j++){ | |
a[j] = '%c'+a[j]; | |
if (cindex >= rainbow.length) cindex = 0; | |
styles.push(style + 'color:'+ rainbow[cindex]); | |
cindex++; | |
} | |
args[i] = a.join('') | |
} | |
} | |
for(var i=0; i<styles.length; i++){ | |
args.push(styles[i]); | |
} | |
_original_unmodified_console_log_thingy.apply(this, args); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
copy / paste this into your chrome javascript console and you should then get much more enjoyable console.log output 🎉