Skip to content

Instantly share code, notes, and snippets.

@lushijie
Created December 25, 2017 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lushijie/4c96996878e5d56b138e66f5cb4c914a to your computer and use it in GitHub Desktop.
Save lushijie/4c96996878e5d56b138e66f5cb4c914a to your computer and use it in GitHub Desktop.
获取本网站引用的第三方资源
function getThirdResoure() {
var resp = null;
var tags = document.querySelectorAll('iframe[src],frame[src],script[src],link[rel=stylesheet],object[data],embed[src]');
for(var i = 0; i < tags.length; i++){
var tag = tags[i];
var a = document.createElement('a');
a.href = tag.src||tag.href||tag.data;
if(a.hostname != location.hostname){
resp = resp || [];
resp.push({name: tag.localName, href: a.href});
}
}
return resp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment