The above can be copy-pasted into a terminal or save it as a bookmarklet by saving the following as the URL (sorry, GitHub's markdown won't let me directly link a bookmarklet)
javascript:(function openLinksInNewTab(){new Set(Array.prototype.reduce(document.querySelectorAll('a[href],area[href]'),function(a,e){ e.href[0]!=='#'&&a.push(e);return a},[])).forEach(function(a){window.open(a,'_blank')})}());
Updated to be more efficient. I wrote this 6 years ago with very little JavaScript experience at the time.