document.querySelectorAll('body a').forEach((val) => {
  let linkCheck = new RegExp('/' + window.location.host + '/')
  if (!linkCheck.test(val.href)) {
	let currentRel = val.getAttribute('rel')
    val.setAttribute('target', '_blank')
	if (currentRel) {
		val.setAttribute('rel', 'noreferrer noopener ' + val.getAttribute('rel'))
	} else {
		val.setAttribute('rel', 'noreferrer noopener')
	}
  }
})


//Replace 'body a' with desired selector