Forked from jonathanagosto/targetBlankVulnerabilityPatch.js
Created
December 5, 2016 18:36
-
-
Save jasonco-dev/dbb9f1edf1775b8bd9c547567c08d985 to your computer and use it in GitHub Desktop.
Find all tags using target="_blank" and inject rel="noreferrer noopener"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var aTags = document.querySelectorAll('[target]'); | |
var att = document.createAttribute('rel'); | |
att.value = 'noopener noreferrer'; | |
aTags.forEach(function (tag) { | |
var nodeClone = att.cloneNode(true); | |
tag.setAttributeNode(nodeClone); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment