查找网站引用的第三方js资源文件

时间:2014-11-08 16:51:58   收藏:0   阅读:295
for(var i=0,tags=document.querySelectorAll(‘iframe[src],frame[src],script[src],link[rel=stylesheet],object[data],embed[src]‘),tag;tag=tags[i];i++){
    var a = document.createElement(‘a‘);
     a.href = tag.src||tag.href||tag.data;
    if(a.hostname!=location.hostname){
        console.warn(location.hostname+‘ 发现第三方资源[‘+tag.localName+‘]:‘+a.href);
     }
}


原文:http://my.oschina.net/backtract/blog/342255

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!