// ================== 多格式图片回落工具 ==================
function changeExt(url, ext) {
return url.replace(/\.(jpg|jpeg|png|gif|bmp|webp|avif)(\?.*)?$/i, '.' + ext + '$2');
}
/**
* 创建支持 avif/webp/原图多格式回退的
* @param {string} src 原始图片地址(jpg/png结尾)
* @param {string} alt
* @param {object} [styleObj]
* @returns {HTMLElement} picture 元素
*/
function createSmartPicture(src, alt, styleObj = {}) {
const sources = [
{ type: 'image/avif', srcset: changeExt(src, 'avif') },
{ type: 'image/webp', srcset: changeExt(src, 'webp') },
{ type: '', srcset: src }
];
const picture = document.createElement('picture');
sources.forEach(s => {
if (s.type) {
const source = document.createElement('source');
source.type = s.type;
source.srcset = s.srcset;
picture.appendChild(source);
}
});
const img = document.createElement('img');
img.src = src;
img.alt = alt || '';
img.loading = "lazy";
Object.assign(img.style, styleObj);
let tried = 0;
const tryNextFormat = () => {
tried++;
if (tried === 1) img.src = changeExt(src, 'webp');
else if (tried === 2) img.src = src; // 原图
};
img.onerror = function() {
if (tried < 2) tryNextFormat();
};
picture.appendChild(img);
return picture;
}
/**
* 支持 PC/Mobile 分别回落的多格式 Responsive
*/
function createSmartResponsivePicture(pcSrc, mobileSrc, alt, styleObj = {}) {
const picture = document.createElement('picture');
// Mobile sources
['avif', 'webp', ''].forEach((ext, i) => {
const source = document.createElement('source');
source.media = '(max-width: 768px)';
source.type = ext ? 'image/' + ext : '';
source.srcset = ext ? changeExt(mobileSrc, ext) : mobileSrc;
picture.appendChild(source);
});
// PC sources
['avif', 'webp', ''].forEach((ext, i) => {
const source = document.createElement('source');
source.media = '(min-width: 769px)';
source.type = ext ? 'image/' + ext : '';
source.srcset = ext ? changeExt(pcSrc, ext) : pcSrc;
picture.appendChild(source);
});
// fallback img(pc为主)
const img = document.createElement('img');
img.src = pcSrc;
img.alt = alt || '';
img.loading = "lazy";
Object.assign(img.style, styleObj);
// 404 fallback机制(mobile优先)
let tried = 0;
const tryNext = () => {
tried++;
if (tried === 1) img.src = changeExt(pcSrc, 'webp');
else if (tried === 2) img.src = mobileSrc;
else if (tried === 3) img.src = changeExt(mobileSrc, 'webp');
};
img.onerror = function() {
if (tried < 3) tryNext();
};
picture.appendChild(img);
return picture;
}
// ================== 以下为广告渲染逻辑整合 ==================
// 基础安全
function safeText(t) {
return typeof t === 'string' ? t.replace(/[<>]/g, '') : '';
}
function safeUrl(url) {
return /^(https?:)?\/\/.+|^\//.test(url) ? url : '#';
}
// 文字广告
function renderTextAds(ads) {
const adBlocks = document.querySelectorAll('.nv_blist_text');
const cardMargin = 4;
const cardCount = window.innerWidth >= 1200 ? 10 : 5;
const widthPercent = `calc(${100 / cardCount}% - ${cardMargin * 2}px)`;
const aniInterval = 0.20;
adBlocks.forEach(container => {
container.innerHTML = '';
container.style.cssText = 'display:flex;justify-content:flex-start;flex-wrap:wrap;width:100%;padding:0;margin:0;';
ads.forEach((ad, i) => {
if (!ad || !ad.href || !ad.title) return;
const cell = document.createElement('div');
cell.className = 'nv_blist_cell';
cell.style.cssText = `
display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;
padding:14px 2px;margin:${cardMargin}px;width:${widthPercent};min-width:0;box-sizing:border-box;
border:1px solid #fff;border-radius:12px;background:rgba(255,255,255,0.07);
transition:box-shadow 0.3s, border-color 0.3s, background 0.3s;
animation:nv_blist_card_marquee 1.6s cubic-bezier(.61,-0.05,.36,1.13) infinite;
animation-delay:${i * aniInterval}s;`;
const link = document.createElement('a');
link.href = safeUrl(ad.href);
link.target = '_blank';
link.title = safeText(ad.title);
link.setAttribute('rel', 'noopener noreferrer');
link.onclick = function () { trackAdEvent(ad); };
const span = document.createElement('span');
span.textContent = safeText(ad.title);
span.style.cssText = `
display:inline-block;font-size:12px;color:#fff;font-weight:300;letter-spacing:-0.5px;
padding:0 2px;word-break:break-all;transition:color 0.3s;`;
link.appendChild(span);
cell.appendChild(link);
container.appendChild(cell);
});
});
}
// 图片九宫格广告(支持多格式回落)
function renderImageAds(ads) {
const adBlocks = document.querySelectorAll('.nv_blist');
const widthPercent = window.innerWidth >= 1200 ? '10%' : '20%';
adBlocks.forEach(container => {
container.innerHTML = '';
container.style.cssText = 'display:flex;justify-content:center;flex-wrap:wrap;';
ads.forEach(ad => {
if (!ad || !ad.href || !ad.imgSrc || !ad.title) return;
const cell = document.createElement('div');
cell.className = 'nv_blist_cell';
cell.style.cssText = `display:flex;flex-direction:column;align-items:center;text-align:center;padding:4px;width:${widthPercent};box-sizing:border-box;`;
const link = document.createElement('a');
link.href = safeUrl(ad.href);
link.target = '_blank';
link.title = safeText(ad.title);
link.setAttribute('rel', 'noopener noreferrer');
link.onclick = function () { trackAdEvent(ad); };
// ========== 使用多格式图片 ==========
const picture = createSmartPicture(
safeUrl(ad.imgSrc),
safeText(ad.title),
{ width: '100%', height: 'auto', maxHeight: '200px', objectFit: 'cover', borderRadius: '10px' }
);
link.appendChild(picture);
const span = document.createElement('span');
span.textContent = safeText(ad.title);
span.style.cssText = `display:inline-block;font-size:13px;color:white;margin-top:3px;letter-spacing:-0.5px;`;
link.appendChild(span);
cell.appendChild(link);
container.appendChild(cell);
});
});
}
// 顶部底部广告(多格式回落 PC/Mobile)
function renderAllTPAdBlocks(adConfig) {
if (!adConfig || !adConfig.top || !adConfig.bottom) return;
function getRandomAd(adArray) {
if (!Array.isArray(adArray) || !adArray.length) return null;
return adArray[Math.floor(Math.random() * adArray.length)];
}
function createAd(position, ad) {
if (!ad || !ad.href || !ad.imgPc || !ad.imgMobile) return;
const existingAdLink = document.getElementById(position + 'AdLink');
if (existingAdLink) existingAdLink.remove();
const adLink = document.createElement('a');
adLink.href = safeUrl(ad.href);
adLink.target = '_blank';
adLink.style = `
display:block;position:fixed;${position === 'top' ? 'top:0' : 'bottom:0'};
left:50%;transform:translateX(-50%);
width:100%;max-width:1260px;z-index:9999;text-decoration:none;`;
adLink.id = position + 'AdLink';
adLink.setAttribute('rel', 'noopener noreferrer');
adLink.onclick = function () { trackAdEvent(ad); };
const adContent = document.createElement('div');
adContent.id = position + 'Ad';
adContent.style = `
display:flex;justify-content:center;align-items:center;overflow:hidden;padding:0;
background:transparent;position:relative;`;
// ========== 多格式响应式图片 ==========
const picture = createSmartResponsivePicture(
safeUrl(ad.imgPc),
safeUrl(ad.imgMobile),
position + '广告',
{ maxWidth: '100%', height: 'auto', width: 'auto', display: 'block', lineHeight: 0, margin: 0, padding: 0, border: 0 }
);
adContent.appendChild(picture);
adLink.appendChild(adContent);
let container = document.getElementById('tpads-container');
if (!container) {
container = document.createElement('div');
container.id = 'tpads-container';
document.body.appendChild(container);
}
container.appendChild(adLink);
// 自动高适配
function adjustAdSize() {
const img = adContent.querySelector('img');
if (!img) return;
const maxHeight = window.innerHeight * 0.2;
if (img.naturalHeight > maxHeight) {
img.style.maxHeight = maxHeight + 'px';
}
}
const img = adContent.querySelector('img');
if (img) {
img.onload = adjustAdSize;
setTimeout(adjustAdSize, 600);
}
}
function loadRandomAds() {
createAd('top', getRandomAd(adConfig.top));
createAd('bottom', getRandomAd(adConfig.bottom));
}
loadRandomAds();
setInterval(loadRandomAds, 30000);
window.addEventListener('resize', function () {
['top', 'bottom'].forEach(pos => {
const img = document.getElementById(pos + 'AdLink')?.querySelector('img');
if (!img) return;
const maxHeight = window.innerHeight * 0.2;
if (img.naturalHeight > maxHeight) {
img.style.maxHeight = maxHeight + 'px';
}
});
});
}
// 视频列表广告(多格式图片)
function shuffle(array) {
var m = array.length, t, i;
while (m) {
i = Math.floor(Math.random() * m--);
t = array[m];
array[m] = array[i];
array[i] = t;
}
return array;
}
function renderAllAdvVideoListItems() {
var ads = (window.adData && Array.isArray(window.adData.adsvideolist)) ? window.adData.adsvideolist.slice() : [];
if (!ads.length) return;
shuffle(ads);
var advBoxes = Array.from(document.querySelectorAll('.item.adv-item'));
let shownIndexes = [];
let idx = 0;
while (idx < advBoxes.length) {
shownIndexes.push(idx);
idx += 3 + Math.floor(Math.random() * 3);
}
advBoxes.forEach(function (box, i) {
if (shownIndexes.includes(i)) {
var ad = ads[(shownIndexes.indexOf(i)) % ads.length];
box.innerHTML = '';
box.style.display = '';
var a = document.createElement('a');
a.href = safeUrl(ad.href || '#');
a.title = safeText(ad.title || '');
a.target = '_blank';
a.rel = 'nofollow';
a.dataset.tianjiEvent = ad.trackLabel || '';
a.onclick = function () {
if (window.trackEvent) trackEvent(ad.trackLabel);
if (window._paq) _paq.push(['trackEvent', '广告', '访问广告', ad.trackLabel]);
};
// ========== 多格式广告图片 ==========
const divImg = document.createElement('div');
divImg.className = 'img';
const picture = createSmartPicture(
safeUrl(ad.imgSrc || ''),
safeText(ad.title || ''),
{ width: '100%', height: 'auto', maxHeight: '180px', objectFit: 'cover', borderRadius: '10px' }
);
divImg.appendChild(picture);
a.appendChild(divImg);
var strong = document.createElement('strong');
strong.className = 'title';
strong.textContent = safeText(ad.title || '');
strong.style.display = "flex";
strong.style.alignItems = "center";
strong.style.justifyContent = "center";
strong.style.width = "100%";
strong.style.padding = "0 8px";
strong.style.fontSize = "16px";
strong.style.color = "#2debc1";
strong.style.textAlign = "center";
strong.style.whiteSpace = "normal";
strong.style.wordBreak = "break-all";
strong.style.marginTop = "16px";
a.appendChild(strong);
box.appendChild(a);
} else {
box.style.display = 'none';
}
});
}
// 增强版MutationObserver
function setupAdvVideoMutationObserver() {
var advParent = document.body;
if (!advParent || !window.MutationObserver) return;
var observer = new MutationObserver(function(mutationsList) {
let hasNewAdv = mutationsList.some(function(m) {
return Array.from(m.addedNodes || []).some(node => {
if (node.nodeType !== 1) return false;
if (node.classList && node.classList.contains('adv-item')) return true;
if (node.querySelector && node.querySelector('.adv-item')) return true;
return false;
});
});
if (hasNewAdv) {
renderAllAdvVideoListItems();
}
});
observer.observe(advParent, { childList: true, subtree: true });
}
// ============ 动画样式(仅插入一次) ============
if (!document.getElementById('nv_blist_text')) {
const style = document.createElement('style');
style.id = 'nv_blist_text';
style.textContent = `
@keyframes nv_blist_card_marquee {
0% { transform:scale(1);border-color:#fff;background:rgba(255,255,255,0.07);box-shadow:none;}
20% { transform:scale(1.12);border-color:#2debc1;background:rgba(45,235,193,0.13);box-shadow:0 2px 20px 0 #2debc160;}
40% { transform:scale(1);border-color:#fff;background:rgba(255,255,255,0.07);box-shadow:none;}
100% { transform:scale(1);border-color:#fff;background:rgba(255,255,255,0.07);box-shadow:none;}
}`;
document.head.appendChild(style);
}
// ========== 主控渲染 ==========
function tryRenderAll() {
if (window.adData?.adstext?.length) renderTextAds(window.adData.adstext);
if (window.adData?.ads?.length) renderImageAds(window.adData.ads);
if (window.adData?.adConfig?.top && window.adData?.adConfig?.bottom) renderAllTPAdBlocks(window.adData.adConfig);
if (window.adData?.adsvideolist?.length) renderAllAdvVideoListItems();
}
document.addEventListener('adDataLoaded', tryRenderAll);
if (
window.adData && (
(window.adData.ads && window.adData.ads.length) ||
(window.adData.adstext && window.adData.adstext.length) ||
(window.adData.adConfig && (window.adData.adConfig.top?.length || window.adData.adConfig.bottom?.length)) ||
(window.adData.adsvideolist && window.adData.adsvideolist.length)
)
) {
tryRenderAll();
}
function debounce(fn, delay) {
let timer;
return function () {
clearTimeout(timer);
timer = setTimeout(fn, delay);
}
}
window.addEventListener('resize', debounce(tryRenderAll, 120));
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', setupAdvVideoMutationObserver);
} else {
setupAdvVideoMutationObserver();
}
// 统一广告事件追踪(原有内容不变)
function trackAdEvent(ad) {
if (!ad || !ad.trackLabel) return;
try { tianji.track(ad.trackLabel, {}); } catch (e) { console.log(e); }
try {
if (window.umami && typeof window.umami.track === "function") {
window.umami.track('广告点击', { [ad.trackLabel]: ad.trackLabel });
}
} catch (e) { console.log(e); }
try { window.trackEvent && window.trackEvent(ad.trackLabel); } catch (e) { console.log(e); }
}
骚妇太饥渴操到老公只能戴假屌交差
时长: 40:19
浏览: 110
加入日期: 3周前
用户:
商务合作Telegram:@Lu77com警告:撸趣社在线视频只适合18岁或以上人士观看。本网站内容可能令人反感!切不可将本站的内容出售、出租、交给或借予年龄未满18岁的人士或将本网站内容向未满18岁人士出示、播放或放映。本站内容收录于世界各地,如果您发现本站的某些影片内容不合适,或者某些影片侵犯了您的的版权,请联系我们(发信给lu77dizhi#gmail.com,请将#改为@。获得最新地址)删除影片