【站长干货】影视类或擦边类型站点的宝贝,看的懂有需求的,自然会用
不废话、直接上干货!看的懂、有需求的,自然会用~
就不献丑了出教程了,毕竟是免费分享哈
- (function() { // 配置部分 - 可自定义 const domains = [ 'https://a.com', 'https://b.com', 'https://c.com', 'https://d.com', 'https://e.com', 'https://f.com' ]; const weights = [1, 1, 1, 1, 1, 1]; // 权重分配 // 核心跳转逻辑 const executeRedirect = function() { // 1. 加权随机选择目标URL const targetUrl = weightedRandom(domains, weights); // 2. 完全无感知跳转技术 if (window.history && window.history.replaceState) { // 方法1: 最完美的无感知跳转方案 try { const iframe = document.createElement('iframe'); iframe.style.display = 'none'; iframe.src = targetUrl; document.documentElement.appendChild(iframe); window.stop(); // 停止当前页面加载 window.location.replace('about:blank'); setTimeout(() => { window.location.replace(targetUrl); }, 0); return; } catch(e) { // 如果失败,使用备用方案 } } // 方法2: 备用无感知跳转方案 try { window.location.replace(targetUrl); } catch(e) { // 终极方案: 直接跳转 window.location.href = targetUrl; } }; // 加权随机算法 function weightedRandom(items, weights) { const cumulativeWeights = []; for (let i = 0; i < weights.length; i += 1) { cumulativeWeights[i] = weights[i] + (cumulativeWeights[i - 1] || 0); } const randomNumber = cumulativeWeights[cumulativeWeights.length - 1] * Math.random(); for (let i = 0; i < items.length; i += 1) { if (cumulativeWeights[i] >= randomNumber) { return items[i]; } } } // 立即执行跳转 if (document.readyState === 'complete' || document.readyState === 'interactive') { executeRedirect(); } else { document.addEventListener('DOMContentLoaded', executeRedirect); window.addEventListener('load', executeRedirect); }})();
就不献丑了出教程了,毕竟是免费分享哈