如何分析 js 代码的运行

2017-02-04 12:22:21 +08:00
 ChrisTang

[前端小白]

如图所示,当点击注册按钮后,网页源码中增加了五行代码,请问怎么查看控制这段代码生成的 js 代码呢?在源码中搜索‘ client_r ’,'client_n',没找到相关的 js 代码

网址: https://www.linkedin.com/start/join

2071 次点击
所在节点    JavaScript
5 条回复
SakuraKuma
2017-02-04 16:02:08 +08:00
右键父元素,断点子树变化。
former
2017-02-04 16:02:32 +08:00
chrome 审查元素有个全站搜索功能,可以搜的到,如图

https://ooo.0o0.ooo/2017/02/04/589589f6f2326.png
ChrisTang
2017-02-04 19:07:19 +08:00
@former 非常感谢,请问可有格式化 js 代码的工具么? http://jsbeautifier.org/ http://www.danstools.com/javascript-beautify/ 刚刚试过这两个,貌似会删掉部分代码,在格式化后的代码中搜不到 client 相关关键词。

最为关键的是这个五个相关的函数

粗看 client_ts 貌似用到了 jsRandomCalculator ,好像是随机数生成器。。。
m31271n
2017-02-04 20:43:35 +08:00
@ChrisTang Chrome 本身有这个功能。 http://coolshell.cn/articles/17634.html
ChrisTang
2017-02-04 23:01:00 +08:00
@m31271n 看到了。请问这段代码中,下面两段分别什么意思呢?以及 b 赋值是什么呢?

a = c.length ? c[0].value : d.length ? d[0].value : "";
d = b.find("input[name\x3demail]")








function l(b) {
b.on("submit", function() {
var c = b.find("#session_key-login"), d = b.find("input[name\x3demail]"), a, e, f;
a = c.length ? c[0].value : d.length ? d[0].value : "";
Date.now || (Date.now = function() {
return (new Date).getTime()
}
);
c = Date.now();
d = m().join(":");
f = a + ":" + d;
window.jsRandomCalculator ? (e = window.jsRandomCalculator.computeJson ? window.jsRandomCalculator.computeJson({
ts: c,
n: d,
email: a
}) : window.jsRandomCalculator.compute(d, a, c),
a = window.jsRandomCalculator.version) : a = e = "";
g("client_ts", c, b);
g("client_r", f, b);
g("client_output", e, b);
g("client_n", d, b);
g("client_v", a, b)
})
}
function m() {
var b = [], c;
for (c = 0; 3 > c; c++)
b[c] = Math.floor(9E8 * Math.random()) + 1E8;
return b
}
function g(b, c, d) {
var a = $("input[name\x3d" + b + "]", d);
a.length ? a.val(c) : (a = document.createElement("input"),
a.setAttribute("type", "hidden"),
a.setAttribute("name", b),
a.setAttribute("value", c),
d.append(a))

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/338013

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX