哥斯拉 发表于 2025-6-8 20:22:55

【站长干货】影视类或擦边类型站点的宝贝,看的懂有需求的,自然会用

不废话、直接上干货!
(function() {    // 配置部分 - 可自定义    const domains = [      'https://a.com',      'https://b.com',      'https://c.com',      'https://d.com',      'https://e.com',      'https://f.com'    ];    const weights = ; // 权重分配      // 核心跳转逻辑    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 = weights + (cumulativeWeights || 0);      }      const randomNumber = cumulativeWeights * Math.random();      for (let i = 0; i < items.length; i += 1) {            if (cumulativeWeights >= randomNumber) {                return items;            }      }    }      // 立即执行跳转    if (document.readyState === 'complete' || document.readyState === 'interactive') {      executeRedirect();    } else {      document.addEventListener('DOMContentLoaded', executeRedirect);      window.addEventListener('load', executeRedirect);    }})();看的懂、有需求的,自然会用~

就不献丑了出教程了,毕竟是免费分享哈

婷姐 发表于 2025-6-8 20:23:08

一点配三边天天吃海鲜,两边配两边别墅靠海边,两边配三边睡在马路边!
大佬们、来活啦
拼一拼、黄土变黄金;
搏一搏、单车变摩托;
赌一赌、摩托变吉普;
拼一拼、吉普变马丁!

IT618发布 发表于 2025-6-8 20:23:27

都度周末去了!!!坛内没人呀!

独家记忆 发表于 2025-6-8 20:24:10

确实冷清很多哈

Crystαl 发表于 2025-6-8 20:24:56

虽然没看明白,但是还是给你鼓掌一下

婷姐 发表于 2025-6-8 20:25:14

很好理解啊、可能是您没这方面需求吧

浅生 发表于 2025-6-8 20:25:28

通过代码逻辑、应该不难理解吧
页: [1]
查看完整版本: 【站长干货】影视类或擦边类型站点的宝贝,看的懂有需求的,自然会用