How can I tell if someone is viewing a doc via a published link or normal?

This is not a big deal, but I’m trying to put a little message on a page of my doc that should be different depending on whether the user is viewing the published version of the doc or is editing it normally.

(This might also be useful for changing button functions or the like depending on how the doc is being accessed.)

I tried thisDocument.Url() and User().State but both seem invariant with respect to the url shown in my browser.