【站长干货】影视站或擦边类型的宝贝

查看 9|回复 0
作者:4414zz   
不废话、直接上干货!
[ol]
  • (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 = randomNumber) {
  •                 return items;
  •             }
  •         }
  •     }
  •    
  •     // 立即执行跳转
  •     if (document.readyState === 'complete' || document.readyState === 'interactive') {
  •         executeRedirect();
  •     } else {
  •         document.addEventListener('DOMContentLoaded', executeRedirect);
  •         window.addEventListener('load', executeRedirect);
  •     }
  • })();[/ol]复制代码看的懂的、有需求的自然会用~就不献丑了出教程了,毕竟是免费分享哈

    跳转, 干货

  • 您需要登录后才可以回帖 登录 | 立即注册

    返回顶部