Run scripts in safari

Hi iam able to run scripts in safari but one real problem is everytime my script starts it opens in a new tab.

Safari is piled up with tabs,if i run 10 scripts 10 news tabs are opened everytime.

Is there any way to launch safari fresh all time or any programmatic ways to clear history.

This is really blocking me in many aspects.

Thanks for your help