Macro to toggle default browser between Safari, Chrome and Firefox

thanks very much for your input.
1- pardon my ignorance and with all due respect: how would I know that a script taken off the Internet is safe ? My question applies to to Github and other scripts in general. It's always an issue that troubles me.
2- I would run it as a shell script ?
3- what is your preferred action to get user input of the type: s for safari (which would run defaultbrowser safari, f for firefox, c for chrome.