Generally you can inspect the cast of characters in the global name-space.
If what you mean there is that the JS code is being evaluated from one of Keyboard Maestro's Execute JavaScript in Browser actions, then you can look for document.kmvars (though this document property persists, by default, after the action run is terminated).
This expression, for example, evaluates to a boolean value:
If the context which you wish to detect is that of a Custom HTML prompt, then this would suffice for a Bool on which your conditional evaluations could turn:
Boolean(KeyboardMaestro)
(though the previous expressions should also work, I think)