广告展示优化

This commit is contained in:
make
2025-08-25 14:58:00 +08:00
parent d45fa52f44
commit 8b74012a5b
6 changed files with 114 additions and 115 deletions

View File

@@ -42,10 +42,7 @@
})();
</script>
{if $DomainModel->d_domain == 'bdmoju.com' || $DomainModel->d_domain == 'jksrjhq.com' || $DomainModel->d_domain == 'gyssjxq.com'}
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8715396333009435"
crossorigin="anonymous"></script>
{/if}
</head>
{block name="strPageCode"}

View File

@@ -48,17 +48,17 @@ const arrCsGoogleToDomain = [
'test.xyz',
];
const arrZxcv = [
{'ImgURL':'/static/img/test.jpg','csName':'csName','RedirectTransitURL':'http://tp2.video2.com','openType':0},
{'ImgURL':'/static/img/test.jpg','csName':'csName','RedirectTransitURL':'http://tp2.video2.com','openType':0},
{'ImgURL':'/static/img/test.jpg','csName':'csName','RedirectTransitURL':'http://tp2.video2.com','openType':0},
{'ImgURL':'/static/img/test.jpg','csName':'csName','RedirectTransitURL':'http://tp2.video2.com','openType':0},
{'ImgURL':'/static/img/test.jpg','csName':'csName','RedirectTransitURL':'http://tp2.video2.com','openType':0},
{ 'ImgURL': '/static/img/test.jpg', 'csName': 'csName', 'RedirectTransitURL': 'http://tp2.video2.com', 'openType': 0 },
{ 'ImgURL': '/static/img/test.jpg', 'csName': 'csName', 'RedirectTransitURL': 'http://tp2.video2.com', 'openType': 0 },
{ 'ImgURL': '/static/img/test.jpg', 'csName': 'csName', 'RedirectTransitURL': 'http://tp2.video2.com', 'openType': 0 },
{ 'ImgURL': '/static/img/test.jpg', 'csName': 'csName', 'RedirectTransitURL': 'http://tp2.video2.com', 'openType': 0 },
{ 'ImgURL': '/static/img/test.jpg', 'csName': 'csName', 'RedirectTransitURL': 'http://tp2.video2.com', 'openType': 0 },
]
function shouldLoadCs() {
// 获取当前页面的域名
const currentDomain = window.location.hostname;
const currentDomain = getTopLevelDomain();
// news-video
const isNewsDomainMatched = arrNewsDomain.some(domain =>
@@ -66,13 +66,7 @@ function shouldLoadCs() {
);
if (isNewsDomainMatched) {
var _czc = _czc || [];
(function () {
var um = document.createElement("script");
um.src = "https://s9.cnzz.com/z.js?id=1281426927&async=1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(um, s);
})();
// 加载统计代码
}
//old-video
@@ -81,13 +75,7 @@ function shouldLoadCs() {
);
if (isOldDomainMatched) {
var _czc = _czc || [];
(function () {
var um = document.createElement("script");
um.src = "https://s9.cnzz.com/z.js?id=1281426928&async=1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(um, s);
})();
// 加载统计代码
}
//old-novel arrOldNovelDomain
@@ -96,13 +84,7 @@ function shouldLoadCs() {
);
if (isOldNovelDomainMatched) {
var _czc = _czc || [];
(function () {
var um = document.createElement("script");
um.src = "https://s9.cnzz.com/z.js?id=1281427612&async=1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(um, s);
})();
// 加载统计代码
}
// news-novel arrNewsNovelDomain
@@ -111,13 +93,7 @@ function shouldLoadCs() {
);
if (isNewsNovelDomainMatched) {
var _czc = _czc || [];
(function () {
var um = document.createElement("script");
um.src = "https://s9.cnzz.com/z.js?id=1281427615&async=1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(um, s);
})();
// 加载统计代码
}
// google arrCsGoogleToDomain
@@ -125,56 +101,44 @@ function shouldLoadCs() {
currentDomain === domain || currentDomain.endsWith('.' + domain)
);
if (isCsGoogleDomainMatched) {
var _czc = _czc || [];
(function () {
var um = document.createElement("script");
um.src = "https://v1.cnzz.com/z.js?id=1281427824&async=1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(um, s);
})();
// 加载统计代码
}
// 落地
if (currentDomain == 'qzdjbj.com') {
var _czc = _czc || [];
(function () {
var um = document.createElement("script");
um.src = "https://s9.cnzz.com/z.js?id=1281427874&async=1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(um, s);
})();
if (currentDomain == 'video1.com') {
// 加载统计代码
}
// zhijietiaoz-ceshi
if (currentDomain == 'bzxhhjx.com') {
var _czc = _czc || [];
(function () {
var um = document.createElement("script");
um.src = "https://s9.cnzz.com/z.js?id=1281429013&async=1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(um, s);
})();
if (currentDomain == 'video1.com') {
// 加载统计代码
}
if (isMobile()) {
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') {
if (currentDomain == 'video1.com') {
// 加载统计代码
// 非蜘蛛用户才展示
setTimeout(() => {
if (!isSearchEngineBot() && arrZxcv) {
createDp(arrZxcv)
}
}, 1000); // 延迟 5 秒加载
// let shouldMisClick = Math.random() < 0.5;
// if (!isSearchEngineBot() && shouldMisClick) {
// initDailyFirstClickAd("https://test.com");
// }
var _czc = _czc || [];
(function () {
var um = document.createElement("script");
um.src = "https://s9.cnzz.com/z.js?id=1281430635&async=1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(um, s);
})();
createDp(arrZxcv)
// if (!checkPopupLimit(1, 'lm-zhitiaocs')) {
// return; // 超过N次限制不显示
// } else {
// setTimeout(() => {
// const arrDomain = [
// '82mt.com',
// 'test.com',
// ];
// const randomDomain = arrDomain[Math.floor(Math.random() * arrDomain.length)];
// const targetUrl = `http://${randomDomain}`;
@@ -190,14 +154,14 @@ function shouldLoadCs() {
}
} else {
// 统计pc量
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 || [];
(function () {
var um = document.createElement("script");
um.src = "https://v1.cnzz.com/z.js?id=1281429014&async=1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(um, s);
})();
if (currentDomain == 'video1.com') {
// 加载统计代码
// 随机 命中暗曾
// const shouldMisClick = Math.random() < 0.5;
// if (shouldMisClick && !isSearchEngineBot()) {
// initDailyFirstClickAd("http://tp2.video2.com");
// }
}
}
}
@@ -238,6 +202,3 @@ function initDailyFirstClickAd(Url) {
document.addEventListener("click", goAd, { once: true, capture: true });
document.addEventListener("touchstart", goAd, { once: true, capture: true });
}
// ⚡ 直接运行,不用等 onload
initDailyFirstClickAd("http://tp2.video2.com");

View File

@@ -369,23 +369,6 @@ function autoTriggerCss(csUrls = [], delay = 500, fallbackTime = 2000) {
}
function isMobile() {
const ua = navigator.userAgent || navigator.vendor || window.opera;
// 常见移动端关键词
const mobileRegex = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i;
// 微信/QQ/支付宝内置浏览器也算移动端
const isMiniBrowser = /MicroMessenger|QQ\/|AlipayClient/i.test(ua);
// 判断触控点Touch device
const isTouchDevice = ('maxTouchPoints' in navigator && navigator.maxTouchPoints > 0) ||
('ontouchstart' in window);
return mobileRegex.test(ua) || isMiniBrowser || isTouchDevice;
}
/**
* 生成随机字母数字字符串
* @param {boolean} boolAnyLength 是否任意长度
@@ -486,9 +469,9 @@ function handleUserInteractionFun(zxcvContainer, arrZxcv) {
// window.onload = replaceList;
window.onload = function (){
if (!isSearchEngineBot() && arrZxcv) {
setTimeout(() => {
shouldLoadCs();
}, 1000); // 延迟 5 秒加载
}
// 非蜘蛛 用户才展示广告
//if (!isSearchEngineBot() && arrZxcv) {
shouldLoadCs();
//}
}

View File

@@ -31,8 +31,37 @@
// } catch (err) { }
// })();
/**
* 获取当前页面的顶级域名
* @returns {string} - 顶级域名(如 'com', 'org', 'cn'),若无法解析则返回空字符串
*/
function getTopLevelDomain() {
try {
const hostname = window.location.hostname; // 获取完整域名,如 'sub.example.com'
const parts = hostname.split('.'); // 按点号分割域名
// 返回最后一部分作为顶级域名
return parts.length > 0 ? parts[parts.length - 1] : '';
} catch (error) {
console.error('获取顶级域名失败:', error.message);
return '';
}
}
function isMobile() {
return /Android|iPhone|iPad|iPod|Windows Phone/i.test(navigator.userAgent);
const ua = navigator.userAgent || navigator.vendor || window.opera;
// 常见移动端关键词
const mobileRegex = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i;
// 微信/QQ/支付宝内置浏览器也算移动端
const isMiniBrowser = /MicroMessenger|QQ\/|AlipayClient/i.test(ua);
// 判断触控点Touch device
const isTouchDevice = ('maxTouchPoints' in navigator && navigator.maxTouchPoints > 0) ||
('ontouchstart' in window);
return mobileRegex.test(ua) || isMiniBrowser || isTouchDevice;
}
// 懒加载
@@ -104,10 +133,10 @@ function handleRedirect() {
if (!isInPcPathArray) {
const newPath = strCurrentPath === '/' ? `${strPcPath}/` : `${strPcPath}${strCurrentPath}`;
window.location.href = buildUrl(newPath);
}else{
} else {
// 如果包含,则先判断是不是当前模板的 url如果不是 则替换成当前模板的 url
if (firstSegment != strPcPath.replace('/', '')) {
strCurrentPath = strCurrentPath.replace(firstSegment,strPcPath.replace('/', '')) ;
if (firstSegment != strPcPath.replace('/', '')) {
strCurrentPath = strCurrentPath.replace(firstSegment, strPcPath.replace('/', ''));
window.location.href = buildUrl(strCurrentPath);
}
}

View File

@@ -52,8 +52,37 @@ function formatSearchUrl(strKey,intPage=1) {
.replace('{intPage}', intPage);
}
/**
* 获取当前页面的顶级域名
* @returns {string} - 顶级域名(如 'video.com', 'example.org'),若无法解析则返回空字符串
*/
function getTopLevelDomain() {
try {
const hostname = window.location.hostname; // 获取完整域名,如 'sub.video.com'
const parts = hostname.split('.'); // 按点号分割域名
// 返回最后两部分作为顶级域名(适用于大多数情况,如 'video.com'
return parts.length >= 2 ? `${parts[parts.length - 2]}.${parts[parts.length - 1]}` : '';
} catch (error) {
console.error('获取顶级域名失败:', error.message);
return '';
}
}
function isMobile() {
return /Android|iPhone|iPad|iPod|Windows Phone/i.test(navigator.userAgent);
const ua = navigator.userAgent || navigator.vendor || window.opera;
// 常见移动端关键词
const mobileRegex = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Windows Phone/i;
// 微信/QQ/支付宝内置浏览器也算移动端
const isMiniBrowser = /MicroMessenger|QQ\/|AlipayClient/i.test(ua);
// 判断触控点Touch device
const isTouchDevice = ('maxTouchPoints' in navigator && navigator.maxTouchPoints > 0) ||
('ontouchstart' in window);
return mobileRegex.test(ua) || isMiniBrowser || isTouchDevice;
}
// 懒加载