//引用的源码网站的js
<script src="https://raw.githack.com/jpgerek/referrer-killer/master/referrer-killer.js"></script>
//页面中所有img都会被加入到iframe中
jQuery("div").find("img").each(function() {
var img = jQuery(this);
var img_src = img.attr("src");
if (img_src != undefined && img_src != '') {
img_src = decodeURI(img_src);
img_src = img_src.split("?")[0];
//图片地址后缀
if (img_src.indexOf("qpic.cn") > 0 || img_src.indexOf("qlogo.cn") > 0 || img_src.indexOf("qq.com") > 0 ||
img_src.indexOf("upaiyun.com") > 0) {
var frameid = 'frameimg' + Math.random();
img.parent().attr("id", frameid);
img.remove();
document.getElementById(frameid).innerHTML = ReferrerKiller.imageHtml(img_src);
console.log("1")
$(document.getElementById(frameid).children).css({
"width": "auto",
"min-width": "-webkit-fill-available",
"height": "450px",
"min-height": "auto"
});
$(document.getElementById(frameid).children).contents().find("img").css({
"width": "auto",
"min-width": "auto",
"height": "450px",
"min-height": "auto"
});
}
}
});
页面例子
<div class="layui-carousel" id="test1">
<div carousel-item>
<div><img src="https://hbimg.b0.upaiyun.com/4b5933e46f9f7b6ef76fdfa5ecc5bfc439303018155304-gjCZyE"></div>
<div><img src="https://hbimg.b0.upaiyun.com/4b5933e46f9f7b6ef76fdfa5ecc5bfc439303018155304-gjCZyE"></div>
<div><img src="https://hbimg.b0.upaiyun.com/361b360c163c5572060bb6c5de7cf7c52204d9bd16cf18-KJBpWH"></div>
<div><img src="https://hbimg.b0.upaiyun.com/40c4c7719f45a1a58a3dbd82b4bbea6b00ffb849d2948-BwV4Fu"></div>
</div>
</div>
突破防盗链Referrer
于 2019-04-11 14:08:49 首次发布