原因是我网站一直有一些来路不明的恶心广告刷 CNZZ 统计。
忍了很久,今天不想忍了。
直接写几行代码屏蔽他们。
他们一般是通过程序恶意刷的访问,应该是通过 python 的 chromium 浏览器刷的访问,把带有他们恶心的广告刷进来。
图片(按住 CTRL 点击可在新窗口打开访问):
https://s1.ax1x.com/2022/03/27/q0SDjU.png
https://s1.ax1x.com/2022/03/27/q0S03V.png
https://s1.ax1x.com/2022/03/27/q0pSKS.png
https://s1.ax1x.com/2022/03/27/q0SBcT.png
本技术帖由 V2EX 用户 lizhiqing 用户 ID560762 原创分享,未经允许请勿盗版转载!
把这段 JS 代码放到 JS 最开始的地方,有效防止垃圾网站刷你 CNZZ 统计。
代码:
// 过滤垃圾
let laji_referer_array = [
"kansha.vip",
"vpsduoduo.com"
];
for(let i=0;i<laji_referer_array.length;i++){
let item = laji_referer_array[i];
if(
window.location.href.indexOf(item)!=-1
||
window.document.referrer.indexOf(item)!=-1
){
let laji_referer_uri = window.location.href.split('.com')[1];
window.location.href = "https://www.gov.cn" + laji_referer_uri;
}
}