How to know if you are in confluence page edit mode through javascript

I am trying to run a piece of code in Confluence page edit mode, I haven’t found any param or method or context indicating that user is in edit mode. Any help appreciated thanks.