Last active
August 29, 2015 14:23
-
-
Save Fedcomp/b6d542091db455ee830f to your computer and use it in GitHub Desktop.
Получить все внешние ссылки на веб странице
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 curr_domain = window.location.href.split('//')[1].split('/')[0]; | |
var outside_links = []; | |
var links = document.getElementsByTagName("a"); | |
for(var i=0; i<links.length; i++) { | |
var res = links[i].href.split('//')[1]; | |
if(typeof res == 'undefined') continue; | |
if(res.split('/')[0] == curr_domain) continue; | |
outside_links.push('http://' + res); | |
} | |
console.log(outside_links); | |
console.log('Внешних ссылок (включая поддомены): ' + outside_links.length); | |
javascript:for(var curr_domain=window.location.href.split("//")[1].split("/")[0],outside_links=[],links=document.getElementsByTagName("a"),i=0;i<links.length;i++){var res=links[i].href.split("//")[1];"undefined"!=typeof res&&res.split("/")[0]!=curr_domain&&outside_links.push("http://"+res)}console.log(outside_links),console.log("Внешних ссылок (включая поддомены): "+outside_links.length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment