Created
December 25, 2017 06:39
-
-
Save lushijie/4c96996878e5d56b138e66f5cb4c914a 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
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