Just open up any Dynamics CRM page or record and hit f12. Then, if there are more than one frames, select one of the frames that contains CustomScriptsFrame text in it.

Then, you will be able to use XRM framework that Dynamics CRM exposes.
Xrm.Page.data.entity.getEntityReference();
It will return the entity reference of the record that you just opened.
Xrm.LookupObject {entityType: “lead”, id: “{E9975EA3-531C-E511-80D8-3863BB3CE2C8}”, name: “Allison Brown”}
CustomScriptsFrame is the frame that all Javascript or HTML codes run at.
See you in another topic.