• 请不要在回答技术问题时复制粘贴 AI 生成的内容
yaotian
V2EX  ›  程序员

看到一段奇怪的 javascript 代码?感觉不像是加密。对前端不是很熟悉,这种写法,感觉是符合某种框架,然后被加密,变量名被转变。熟悉的朋友来说说看

  •  
  •   yaotian · Jul 10, 2015 · 3800 views
    This topic created in 3988 days ago, the information mentioned may be changed or developed.
    (function e(t, n, r) {
    function s(o, u) {
    if (!n[o]) {
    if (!t[o]) {
    var a = typeof require == "function" && require;
    if (!u && a) return a(o, !0);
    if (i) return i(o, !0);
    throw new Error("Cannot find module '" + o + "'")
    }
    var f = n[o] = {
    exports: {}
    };
    t[o][0].call(f.exports,
    function(e) {
    var n = t[o][1][e];
    return s(n ? n: e)
    },
    f, f.exports, e, t, n, r)
    }
    return n[o].exports
    }
    var i = typeof require == "function" && require;
    for (var o = 0; o < r.length; o++) s(r[o]);
    return s
    })({
    1 : [function(require, module, exports) {.....
    6 replies    2015-07-12 17:12:31 +08:00
    otakustay
        1
    otakustay  
       Jul 11, 2015
    看上去应该是某个AMD或CMD的加载器来着
    yaotian
        2
    yaotian  
    OP
       Jul 11, 2015
    @otakustay 多谢,我也感觉类似CMD的加载器
    tushiner
        3
    tushiner  
       Jul 11, 2015
    这不叫加密,叫压缩
    wh1100717
        4
    wh1100717  
       Jul 12, 2015
    这代码是压缩过的...
    应该不是加载器,你贴出来的这块应该是进行环境判断,判断当前环境是否存在requirejs啊什么的,根据具体的环境对外暴露不同的变量形式。比如如果require变量存在并且是函数,则返回传入参数n[0].exports(即实际主代码中module.exports或者return的内容)
    wsfxy
        5
    wsfxy  
       Jul 12, 2015
    压缩的来着
    yaotian
        6
    yaotian  
    OP
       Jul 12, 2015
    @tushiner
    @wh1100717
    @wsfxy
    @otakustay
    感谢回复,能看出是用的什么CMD加载器吗?加载器应该有加载用的js才对呀,比如SeaJS在网页中有SeaJs.js,奇怪页面中看不到,只有以下几个:jweixin-1.0.0.js, zepto.min.js, underscore-min.js,iscroll.js。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3498 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 10:36 · PVG 18:36 · LAX 03:36 · JFK 06:36
    ♥ Do have faith in what you're doing.