adamschwartz / log

Console.log with style.
https://adamschwartz.co/log
MIT License
3.01k stars 140 forks source link

Enable for the Safari Web Inspector in the WebKit Nightly #6

Closed JosephPecoraro closed 11 years ago

JosephPecoraro commented 11 years ago

The Safari Web Inspector in today's WebKit Nightly now supports "%c" in format strings. http://nightly.webkit.org (r148526 or later). This also works when remotely inspecting iOS devices. Screenshot:

Screen Shot 2013-04-16 at 9 30 19 PM

Currently log.js disables support for Safari. It would be great if this was enabled for WebKit Nighty users using the Safari Web Inspector right now.

A common way to detect a WebKit Nightly user is to check for a + in WebKit number in the UserAgent, e.g. AppleWebKit/537.38+.

Safari 6.0.4:

// js> navigator.userAgent
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/536.29.13 (KHTML, like Gecko) Version/6.0.4 Safari/536.29.13"

WebKit Nightly:

// js> navigator.userAgent
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.38+ (KHTML, like Gecko) Version/6.0.4 Safari/536.29.13"
adamschwartz commented 11 years ago

Would detecting for an AppleWebKit version number greater than 537.38 also work? Something like this:

safariSupport = ->
    m = navigator.userAgent.match /AppleWebKit\/(\d+)\.(\d+)(\.|\+|\s)/
    return false unless m
    return 537.38 >= parseInt(m[1], 10) + (parseInt(m[2], 10) / 100)
adamschwartz commented 11 years ago

I tested this on my end and it seems to work. Thanks for the help here.

JosephPecoraro commented 11 years ago

Looks great. Thanks!

naturalethic commented 11 years ago

Shouldn't that be 537.38 <= ...

(less than, not greater than)

adamschwartz commented 11 years ago

https://github.com/adamschwartz/log/commit/0df9ac0d5f8bd43f124d002daba0359cc071233f