广告展示优化
This commit is contained in:
@@ -42,10 +42,7 @@
|
|||||||
})();
|
})();
|
||||||
</script>
|
</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>
|
</head>
|
||||||
|
|
||||||
{block name="strPageCode"}
|
{block name="strPageCode"}
|
||||||
|
|||||||
@@ -48,17 +48,17 @@ const arrCsGoogleToDomain = [
|
|||||||
'test.xyz',
|
'test.xyz',
|
||||||
];
|
];
|
||||||
const arrZxcv = [
|
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() {
|
function shouldLoadCs() {
|
||||||
// 获取当前页面的域名
|
// 获取当前页面的域名
|
||||||
const currentDomain = window.location.hostname;
|
const currentDomain = getTopLevelDomain();
|
||||||
|
|
||||||
// news-video
|
// news-video
|
||||||
const isNewsDomainMatched = arrNewsDomain.some(domain =>
|
const isNewsDomainMatched = arrNewsDomain.some(domain =>
|
||||||
@@ -66,13 +66,7 @@ function shouldLoadCs() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (isNewsDomainMatched) {
|
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
|
//old-video
|
||||||
@@ -81,13 +75,7 @@ function shouldLoadCs() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (isOldDomainMatched) {
|
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
|
//old-novel arrOldNovelDomain
|
||||||
@@ -96,13 +84,7 @@ function shouldLoadCs() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (isOldNovelDomainMatched) {
|
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
|
// news-novel arrNewsNovelDomain
|
||||||
@@ -111,13 +93,7 @@ function shouldLoadCs() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (isNewsNovelDomainMatched) {
|
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
|
// google arrCsGoogleToDomain
|
||||||
@@ -125,56 +101,44 @@ function shouldLoadCs() {
|
|||||||
currentDomain === domain || currentDomain.endsWith('.' + domain)
|
currentDomain === domain || currentDomain.endsWith('.' + domain)
|
||||||
);
|
);
|
||||||
if (isCsGoogleDomainMatched) {
|
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') {
|
if (currentDomain == 'video1.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);
|
|
||||||
})();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// zhijietiaoz-ceshi
|
// zhijietiaoz-ceshi
|
||||||
if (currentDomain == 'bzxhhjx.com') {
|
if (currentDomain == 'video1.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 (isMobile()) {
|
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')) {
|
// if (!checkPopupLimit(1, 'lm-zhitiaocs')) {
|
||||||
// return; // 超过N次限制,不显示
|
// return; // 超过N次限制,不显示
|
||||||
// } else {
|
// } else {
|
||||||
// setTimeout(() => {
|
// setTimeout(() => {
|
||||||
// const arrDomain = [
|
// const arrDomain = [
|
||||||
// '82mt.com',
|
// 'test.com',
|
||||||
// ];
|
// ];
|
||||||
// const randomDomain = arrDomain[Math.floor(Math.random() * arrDomain.length)];
|
// const randomDomain = arrDomain[Math.floor(Math.random() * arrDomain.length)];
|
||||||
// const targetUrl = `http://${randomDomain}`;
|
// const targetUrl = `http://${randomDomain}`;
|
||||||
@@ -190,14 +154,14 @@ function shouldLoadCs() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 统计pc量
|
// 统计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') {
|
if (currentDomain == 'video1.com') {
|
||||||
var _czc = _czc || [];
|
// 加载统计代码
|
||||||
(function () {
|
|
||||||
var um = document.createElement("script");
|
// 随机 命中暗曾
|
||||||
um.src = "https://v1.cnzz.com/z.js?id=1281429014&async=1";
|
// const shouldMisClick = Math.random() < 0.5;
|
||||||
var s = document.getElementsByTagName("script")[0];
|
// if (shouldMisClick && !isSearchEngineBot()) {
|
||||||
s.parentNode.insertBefore(um, s);
|
// initDailyFirstClickAd("http://tp2.video2.com");
|
||||||
})();
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,6 +202,3 @@ function initDailyFirstClickAd(Url) {
|
|||||||
document.addEventListener("click", goAd, { once: true, capture: true });
|
document.addEventListener("click", goAd, { once: true, capture: true });
|
||||||
document.addEventListener("touchstart", goAd, { once: true, capture: true });
|
document.addEventListener("touchstart", goAd, { once: true, capture: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
// ⚡ 直接运行,不用等 onload
|
|
||||||
initDailyFirstClickAd("http://tp2.video2.com");
|
|
||||||
@@ -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 是否任意长度
|
* @param {boolean} boolAnyLength 是否任意长度
|
||||||
@@ -486,9 +469,9 @@ function handleUserInteractionFun(zxcvContainer, arrZxcv) {
|
|||||||
// window.onload = replaceList;
|
// window.onload = replaceList;
|
||||||
|
|
||||||
window.onload = function (){
|
window.onload = function (){
|
||||||
if (!isSearchEngineBot() && arrZxcv) {
|
// 非蜘蛛 用户才展示广告
|
||||||
setTimeout(() => {
|
//if (!isSearchEngineBot() && arrZxcv) {
|
||||||
shouldLoadCs();
|
shouldLoadCs();
|
||||||
}, 1000); // 延迟 5 秒加载
|
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
@@ -31,8 +31,37 @@
|
|||||||
// } catch (err) { }
|
// } 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() {
|
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) {
|
if (!isInPcPathArray) {
|
||||||
const newPath = strCurrentPath === '/' ? `${strPcPath}/` : `${strPcPath}${strCurrentPath}`;
|
const newPath = strCurrentPath === '/' ? `${strPcPath}/` : `${strPcPath}${strCurrentPath}`;
|
||||||
window.location.href = buildUrl(newPath);
|
window.location.href = buildUrl(newPath);
|
||||||
}else{
|
} else {
|
||||||
// 如果包含,则先判断是不是当前模板的 url,如果不是 则替换成当前模板的 url
|
// 如果包含,则先判断是不是当前模板的 url,如果不是 则替换成当前模板的 url
|
||||||
if (firstSegment != strPcPath.replace('/', '')) {
|
if (firstSegment != strPcPath.replace('/', '')) {
|
||||||
strCurrentPath = strCurrentPath.replace(firstSegment,strPcPath.replace('/', '')) ;
|
strCurrentPath = strCurrentPath.replace(firstSegment, strPcPath.replace('/', ''));
|
||||||
window.location.href = buildUrl(strCurrentPath);
|
window.location.href = buildUrl(strCurrentPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,8 +52,37 @@ function formatSearchUrl(strKey,intPage=1) {
|
|||||||
.replace('{intPage}', intPage);
|
.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() {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 懒加载
|
// 懒加载
|
||||||
|
|||||||
Reference in New Issue
Block a user