enhancement of beforeunload state and prevent duplicate shares