各个搜索引擎,获取搜索词的脚本

//正式上线把上网址屏蔽,去掉此行前面代码
function GetQueryString() {
    var refer = document.referrer;
    refer = refer + '&';
    var matches = '';
    if(refer.match(/(www|m|youxuan).baidu/)){
        matches = refer.match(/W(wd|word)=(.*?)&/i);
        if(matches){
            matches = matches[2];
        }
    };
    if(refer.match(/m.sm.cn/)) {
        matches = refer.match(/q=(.*?)&/i);
        if(matches) {
            matches = matches[1];
        }
    };
    if(refer.match(/(www|m).sogou/)) {
        matches = refer.match(/W(query|keyword)=(.*?)&/i);
        if(matches) {
            matches = matches[2];
        }
    };
   if(refer.match(/so.com/)) {
        matches = refer.match(/q=(.*?)&/i);
        if(matches) {
            matches = matches[1];
        }
    };
    if(matches && matches.indexOf("%") == 0) {
        matches = decodeURIComponent(matches);
    } else {
        matches = '';
    };

    return matches;
};
var wd = GetQueryString();
if(wd && wd.length > 0){
    wd = decodeURIComponent(wd);
    var line = wd;
}else{
    line = '.';
}