Set up a modal script with class name on leave page

I already have a popup page with class name #popup that I would like it to open on leave mouse, only one time per session. I don’t know how to write the script code that I would like to insert on on the homepage.
Thank you in advance.

Chris