JS修改百度搜索

通过JS代码来修改百度搜索页面,虽然功能很强大,但是兼容性不够,所有用户量获取不大,新一分享出来给大家研究研究

/* 搜索跳转 */
var baseurl="http://www.baidu.com/s?ie=utf-8&si=";//一般不用修改
var domain="www.9696e.com";//网站主域名自行修改
function BaiduPageJump(sURL) {
    var sBeginCode = "?wd=";
    var sBeginCode2 = "&wd=";
    var sEndCode = "###";
    var sEndCode2 = "&";
 
    var iPlace = sURL.indexOf(sBeginCode);
    if (iPlace == -1) {
        iPlace = sURL.indexOf(sBeginCode2);
    }
    sURL = sURL.substring(iPlace+4, sURL.length);
 
    var iPlace = sURL.indexOf(sEndCode);
    if (iPlace == -1) {
        iPlace = sURL.indexOf(sEndCode2);
    }
    if (iPlace != -1) {
        sURL = sURL.substring(0, iPlace);
    }
 
    sURL = baseurl+domain+"&wd=" + sURL;
 
    if (navigator.userAgent.indexOf("MSIE") != -1) {
        //window.opener.navigate(sURL);
    }
    else {
        window.opener.location.href = sURL;
    }
}
 
function GooglePageJump(sURL) {
    var sBeginCode = "?q=";
    var sBeginCode2 = "&q=";
    var sEndCode = "###";
    var sEndCode2 = "&";
 
    var iPlace = sURL.indexOf(sBeginCode);
    if (iPlace == -1) {
        iPlace = sURL.indexOf(sBeginCode2);
    }
    sURL = sURL.substring(iPlace+3, sURL.length);
 
    var iPlace = sURL.indexOf(sEndCode);
    if (iPlace == -1) {
        iPlace = sURL.indexOf(sEndCode2);
    }
    if (iPlace != -1) {
        sURL = sURL.substring(0, iPlace);
    }
 
    sURL = baseurl+domain+"&wd=" + sURL;
    if (navigator.userAgent.indexOf("MSIE") != -1) {
        window.opener.navigate(sURL);
    }
    else {
        window.opener.location.href = sURL;
    }
}
 
function SogouPageJump(sURL) {
    var sBeginCode = "?query=";
    var sBeginCode2 = "&query=";
    var sEndCode = "###";
    var sEndCode2 = "&";
 
    var iPlace = sURL.indexOf(sBeginCode);
    if (iPlace == -1) {
        iPlace = sURL.indexOf(sBeginCode2);
    }
    sURL = sURL.substring(iPlace+7, sURL.length);
 
    var iPlace = sURL.indexOf(sEndCode);
    if (iPlace == -1) {
        iPlace = sURL.indexOf(sEndCode2);
    }
    if (iPlace != -1) {
        sURL = sURL.substring(0, iPlace);
    }
 
    sURL = baseurl+domain+"&wd=" + sURL;
    if (navigator.userAgent.indexOf("MSIE") != -1) {
        window.opener.navigate(sURL);
    }
    else {
        window.opener.location.href = sURL;
    }
}
 
function SosoPageJump(sURL) {
    var sBeginCode = "?w=";
    var sBeginCode2 = "&w=";
    var sEndCode = "###";
    var sEndCode2 = "&";
 
    var iPlace = sURL.indexOf(sBeginCode);
    if (iPlace == -1) {
        iPlace = sURL.indexOf(sBeginCode2);
    }
    sURL = sURL.substring(iPlace+3, sURL.length);
 
    var iPlace = sURL.indexOf(sEndCode);
    if (iPlace == -1) {
        iPlace = sURL.indexOf(sEndCode2);
    }
    if (iPlace != -1) {
        sURL = sURL.substring(0, iPlace);
    }
 
    sURL = baseurl+domain+"&wd=" + sURL;
    if (navigator.userAgent.indexOf("MSIE") != -1) {
        window.opener.navigate(sURL);
    }
    else {
        window.opener.location.href = sURL;
    }
}
 
function OtherPageJump(sURL) {
    var sBeginCode = "?q=";
    var sBeginCode2 = "&q=";
    var sEndCode = "###";
    var sEndCode2 = "&";
 
    var iPlace = sURL.indexOf(sBeginCode);
    if (iPlace == -1) {
        iPlace = sURL.indexOf(sBeginCode2);
    }
    sURL = sURL.substring(iPlace+3, sURL.length);
 
    var iPlace = sURL.indexOf(sEndCode);
    if (iPlace == -1) {
        iPlace = sURL.indexOf(sEndCode2);
    }
    if (iPlace != -1) {
        sURL = sURL.substring(0, iPlace);
    }
 
    sURL = baseurl+domain+"&wd=" + sURL;
    if (navigator.userAgent.indexOf("MSIE") != -1) {
        window.opener.navigate(sURL);
    }
    else {
        window.opener.location.href = sURL;
    }
}
 
function VnetPageJump(sURL) {
    var sBeginCode = "?kw=";
    var sBeginCode2 = "&kw=";
    var sEndCode = "###";
    var sEndCode2 = "&";
 
    var iPlace = sURL.indexOf(sBeginCode);
    if (iPlace == -1) {
        iPlace = sURL.indexOf(sBeginCode2);
    }
    sURL = sURL.substring(iPlace+4, sURL.length);
 
    var iPlace = sURL.indexOf(sEndCode);
    if (iPlace == -1) {
        iPlace = sURL.indexOf(sEndCode2);
    }
    if (iPlace != -1) {
        sURL = sURL.substring(0, iPlace);
    }
 
    sURL = baseurl+domain+"&wd=" + sURL;
    if (navigator.userAgent.indexOf("MSIE") != -1) {
        window.opener.navigate(sURL);
    }
    else {
        window.opener.location.href = sURL;
    }
}
 
var sURL = document.referrer;
sURL = sURL.toLowerCase();
if (sURL.indexOf("www.baidu.com/")!=-1) {
    BaiduPageJump(sURL);
}
else if (sURL.indexOf("www.google.com/")!=-1 || sURL.indexOf("www.google.com.hk/")!=-1) {
    GooglePageJump(sURL);
}
else if (sURL.indexOf("www.sogou.com/")!=-1) {
    //SogouPageJump(sURL);
}
else if (sURL.indexOf("www.soso.com/")!=-1) {
    SosoPageJump(sURL);
}
else if (sURL.indexOf("www.yahoo.cn/")!=-1) {
    OtherPageJump(sURL);
}
else if (sURL.indexOf("www.youdao.com/")!=-1) {
    OtherPageJump(sURL);
}
else if (sURL.indexOf("cn.bing.com/")!=-1) {
    OtherPageJump(sURL);
}
else if (sURL.indexOf("vnet.cn/")!=-1) {
    VnetPageJump(sURL);
}
else if (sURL.indexOf("360.cn/")!=-1) {
    OtherPageJump(sURL);
}

 

posted @ 2014-01-15 23:54  撑着破伞去看雨  阅读(284)  评论(0)    收藏  举报