Skip to content

Instantly share code, notes, and snippets.

@zismailov
Created September 20, 2017 17:18
Show Gist options
  • Save zismailov/e606d6527563092cd5e2738a57397517 to your computer and use it in GitHub Desktop.
Save zismailov/e606d6527563092cd5e2738a57397517 to your computer and use it in GitHub Desktop.
Получить все внешние ссылки на веб странице
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