Created
November 2, 2016 17:58
-
-
Save jakzale/aff5e62b5119f8ce6d0fcabd943b374e to your computer and use it in GitHub Desktop.
List All links on a web page
This file contains hidden or 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
(function (){ | |
var aTags = document.getElementsByTagName("a"); | |
var aTagsArray = [].slice.call(aTags); | |
aTagsArray.map(function (a) { | |
var result = "#"; | |
if (a.getAttribute) { | |
result = a.getAttribute("href") || result; | |
} | |
return result; | |
}).filter(function (link) { | |
return link.startsWith("http"); | |
}).forEach(function (link) { | |
console.log(link); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment