Instead of hardcoding web browsers, you can scan the user agent to find the browser name:
navigator.userAgent.split(')').reverse()[0].match(/(?!Gecko|Version|[A-Za-z]+?Web[Kk]it)[A-Z][a-z]+/g)[0]
I've tested this on Safari, Chrome, and Firefox. Let me know if you found this doesn't work on a browser.
- Safari:
"Safari"
- Chrome:
"Chrome"
- Firefox:
"Firefox"
You can even modify this to get the browser version if you want. Do note there are better ways to get the browser version
navigator.userAgent.split(')').reverse()[0].match(/(?!Gecko|Version|[A-Za-z]+?Web[Kk]it)[A-Z][a-z]+\/[\d.]+/g)[0].split('/')
Sample output:
Firefox/39.0