qt5.12调用执行JavaScript文件问题



  • 项目需要调用一个复杂的JS文件,这个JS文件会创建一个url,里面有很多函数和定义,我尝试用QScriptEngine,但是一直未成功,希望你们能够帮助,让我知道该怎么正确调用这个JS文件。

    这是我写的代码
    QScriptEngine engine;
    QScriptValue js = engine.evaluate(jsContents); //jsContents为下面文件里的内容
    QScriptValue result = js.call(QScriptValue(),args);

    这是JS文件
    (function() {
    function Pa() {
    if ( - 1 == G("RAIL_EXPIRATION")) for (var a = 0; 10 > a; a++) H(function() { (new ja).getFingerPrint()
    },
    20 + 2E3 * Math.pow(a, 2));
    else(new ja).getFingerPrint();
    H(function() {
    r.setInterval(function() { (new ja).getFingerPrint()
    },
    3E5)
    },
    3E5)
    }
    function nb(a) {
    this.isTimeout = 0;
    var b = this,
    c = r.RTCPeerConnection || r.webkitRTCPeerConnection || r.mozRTCPeerConnection;
    if ("function" == typeof c) {
    try {
    var d = new c({
    iceServers: []
    });
    d.createDataChannel("", {
    reliable: !1
    })
    } catch(f) {
    if (2 != b.isTimeout) {
    b.isTimeout = 1;
    a();
    return
    }
    }
    var e = !1;
    d.onicecandidate = function(c) {
    var d = /([0-9]{1,3}(.[0-9]{1,3}){3})/,
    f = [];
    "complete" != c.target.iceGatheringState || e || (e = !0, c.target.localDescription.sdp.split("\n").forEach(function(a) { (a = d.exec(a)) && "127.0.0.1" != a[1] && "0.0.0.0" != a[1] && -1 === f.indexOf(a[1]) && f.push(a[1])
    }), 2 != b.isTimeout && (b.isTimeout = 1, a({
    localAddr: 0 < f.length ? f.sort()[0] : ""
    })))
    };
    d.onaddstream = function(a) {
    remoteVideo.src = r.URL.createObjectURL(a.stream)
    };
    d.createOffer(function(a) {
    d.setLocalDescription(a,
    function() {},
    function() {})
    },
    function() {},
    {})
    } else a();
    H(function() {
    0 == b.isTimeout && (b.isTimeout = 2, a())
    },
    500)
    }

    function G(a) {
        var b, c, d, e = u.cookie.split(";");
        for (b = 0; b < e.length; b++) if (c = e[b].substr(0, e[b].indexOf("\x3d")), d = e[b].substr(e[b].indexOf("\x3d") + 1), c = c.replace(/^\s+|\s+$/g, ""), a = a.replace(/^\s+|\s+$/g, ""), c == a) return unescape(d)
    }
    function W(a, b, c, d, e, f) {
        var g = new Date;
        g.setTime(g.getTime()); - 1 != c ? (c *= 864E5, g = new Date(g.getTime() + c), cookieString = a + "\x3d" + escape(b) + (c ? ";expires\x3d" + g.toGMTString() : "") + (d ? ";path\x3d" + d: "") + (e ? ";domain\x3d" + e: "") + (f ? ";secure": "")) : (g = -1, cookieString = a + "\x3d" + escape(b) + (c ? ";expires\x3d" + g: "") + (d ? ";path\x3d" + d: "") + (e ? ";domain\x3d" + e: "") + (f ? ";secure": ""));
        u.cookie = cookieString
    }
    function ob(a) {
        a = a.replace(/\s/g, "");
        if (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(a)) {
            a = a.split(".");
            if (0 == parseInt(parseFloat(a[0])) || 0 == parseInt(parseFloat(a[3]))) return ! 1;
            for (var b = 0; b < a.length; b++) if (255 < parseInt(parseFloat(a[b]))) return ! 1;
            return ! 0
        }
        return ! 1
    }
    function p(a, b) {
        this.key = a;
        this.value = b
    }
    function W(a, b, c) {
        var d = new Date;
        d.setTime(d.getTime() + 864E5 * Number(c));
        u.cookie = a + "\x3d" + b + "; path\x3d/;expires \x3d " + d.toGMTString() + ";domain\x3d" + ya(r.location.host.split(":")[0])
    }
    function Ha() {
        var a = k.userAgent.toLowerCase();
        return 0 <= a.indexOf("windows phone") ? "WindowsPhone": 0 <= a.indexOf("win") ? "Windows": 0 <= a.indexOf("android") ? "Android": 0 <= a.indexOf("linux") ? "Linux": 0 <= a.indexOf("iphone") || 0 <= a.indexOf("ipad") ? "iOS": 0 <= a.indexOf("mac") ? "Mac": "Other"
    }
    function ja() {
        this.ec = new evercookie;
        this.deviceEc = new evercookie;
        this.cfp = new aa;
        this.packageString = "";
        this.moreInfoArray = []
    }
    var u = document,
    r = window,
    k = navigator,
    y = screen,
    H = setTimeout,
    rb = top,
    sb = location,
    tb = parent;
    Array.prototype.indexOf || (Array.prototype.indexOf = function(a, b) {
        var c;
        if (null == this) throw new TypeError("'this' is null or undefined");
        var d = Object(this),
        e = d.length >>> 0;
        if (0 === e) return - 1;
        c = +b || 0;
        Infinity === Math.abs(c) && (c = 0);
        if (c >= e) return - 1;
        for (c = Math.max(0 <= c ? c: e - Math.abs(c), 0); c < e;) {
            if (c in d && d[c] === a) return c;
            c++
        }
        return - 1
    });
    
    var Cb = "appCodeName appMinorVersion appName cpuClass onLine systemLanguage userLanguage historyList hasLiedLanguages hasLiedResolution hasLiedOs hasLiedBrowser".split(" "),
    ca = 8,
    Y,
    J = r,
    q = u,
    O = k,
    hb = !1,
    oa = [function() {
        if (hb) {
            var a = q.getElementsByTagName("body")[0],
            b = q.createElement("object");
            b.setAttribute("type", "application/x-shockwave-flash");
            var c = a.appendChild(b);
            if (c) {
                var d = 0; (function f() {
                    if ("undefined" != typeof c.GetVariable) {
                        var g = c.GetVariable("$version");
                        g && (g = g.split(" ")[1].split(","), n.pv = [parseInt(g[0], 10), parseInt(g[1], 10), parseInt(g[2], 10)])
                    } else if (10 > d) {
                        d++;
                        H(f, 10);
                        return
                    }
                    a.removeChild(b);
                    c = null;
                    Ga()
                })()
            } else Ga()
        } else Ga()
    }],
    M = [],
    la = [],
    U = [],
    Z,
    na,
    Da,
    Va,
    Q = !1,
    ma = !1,
    L,
    za,
    Sa = !0,
    n,
    Db = "undefined" != typeof q.getElementById && "undefined" != typeof q.getElementsByTagName && "undefined" != typeof q.createElement,
    va = O.userAgent.toLowerCase(),
    wa = O.platform.toLowerCase(),
    Eb = wa ? /win/.test(wa) : /win/.test(va),
    Fb = wa ? /mac/.test(wa) : /mac/.test(va),
    Gb = /webkit/.test(va) ? parseFloat(va.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : !1,
    La = !+"\x0B1",
    ha = [0, 0, 0],
    I = null;
    if ("undefined" != typeof O.plugins && "object" == typeof O.plugins["Shockwave Flash"]) ! (I = O.plugins["Shockwave Flash"].description) || "undefined" != typeof O.mimeTypes && O.mimeTypes["application/x-shockwave-flash"] && !O.mimeTypes["application/x-shockwave-flash"].enabledPlugin || (hb = !0, La = !1, I = I.replace(/^.*\s+(\S+\s+\S+$)/, "$1"), ha[0] = parseInt(I.replace(/^(.*)\..*$/, "$1"), 10), ha[1] = parseInt(I.replace(/^.*\.(.*)\s.*$/, "$1"), 10), ha[2] = /[a-zA-Z]/.test(I) ? parseInt(I.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0);
    else if ("undefined" != typeof J.ActiveXObject) try {
        if (I = (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version")) La = !0,
        I = I.split(" ")[1].split(","),
        ha = [parseInt(I[0], 10), parseInt(I[1], 10), parseInt(I[2], 10)]
    } catch(a) {}
    n = {
        ie: La,
        wk: Gb,
        w3: Db,
        mac: Fb,
        win: Eb,
        pv: ha
    };
    n.w3 && (("undefined" != typeof q.readyState && "complete" == q.readyState || "undefined" == typeof q.readyState && (q.getElementsByTagName("body")[0] || q.body)) && V(), Q || ("undefined" != typeof q.addEventListener && q.addEventListener("DOMContentLoaded", V, !1), n.ie && n.win && (q.attachEvent("onreadystatechange",
    function b() {
        "complete" == q.readyState && (q.detachEvent("onreadystatechange", b), V())
    }), J == rb &&
    function c() {
        if (!Q) {
            try {
                q.documentElement.doScroll("left")
            } catch(d) {
                H(c, 0);
                return
            }
            V()
        }
    } ()), n.wk &&
    function b() {
        Q || (/loaded|complete/.test(q.readyState) ? V() : H(b, 0))
    } (), Wa(V)));
    n.ie && n.win && r.attachEvent("onunload",
    function() {
        for (var a = U.length,
        b = 0; b < a; b++) U[b][0].detachEvent(U[b][1], U[b][2]);
        a = la.length;
        for (b = 0; b < a; b++) Ua(la[b]);
        for (var c in n) n[c] = null;
        n = null;
        for (var d in Y) Y[d] = null;
        Y = null
    });
    

    } catch(a) {}
    var lb = {
    postMessage: function(a, b) {
    b = b || tb;
    if (b.postMessage) b.postMessage(a, "*");
    else if (a && "function" == typeof k.onData) k.onData(a)
    }
    }; ja.prototype = {
    getCanvansCode: function(a) {
    var b;
    b = this.checkWapOrWeb() ? "wapSmartID": "webSmartID";
    return new p(b, a)
    },

    initEc: function(a) {
        var b = "",
        c = this,
        d = void 0 != a && void 0 != a.localAddr ? a.localAddr: "";
        c.checkWapOrWeb();
        this.ec.get("RAIL_OkLJUJ",
        function(a) {
            b = a;
            c.getDfpMoreInfo(function() {
                if (! (9E5 < G("RAIL_EXPIRATION") - (new Date).getTime() & null != G("RAIL_DEVICEID") & void 0 != G("RAIL_DEVICEID") & !c.NeedUpdate())) {
                    for (var a = "",
                    e = "",
                    l = c.getpackStr(b), k = [], n = [], q = [], h = [], m = 0; m < l.length; m++)"new" != l[m].value && -1 == Cb.indexOf(l[m].key) && ( - 1 != Ab.indexOf(l[m].key) ? n.push(l[m]) : -1 != Hb.indexOf(l[m].key) ? q.push(l[m]) : -1 != Bb.indexOf(l[m].key) ? h.push(l[m]) : k.push(l[m]));
                    l = "";
                    for (m = 0; m < n.length; m++) l = l + n[m].key.charAt(0) + n[m].value;
                    n = "";
                    for (m = 0; m < h.length; m++) n = 0 == m ? n + h[m].value: n + "x" + h[m].value;
                    h = "";
                    for (m = 0; m < q.length; m++) h = 0 == m ? h + q[m].value: h + "x" + q[m].value;
                    k.push(new p("storeDb", l));
                    k.push(new p("srcScreenSize", n));
                    k.push(new p("scrAvailSize", h));
                    "" != d && k.push(new p("localCode", pb(d)));
                    e = c.hashAlg(k, a, e);
                    a = e.key;
                    e = e.value;
                    a += "\x26timestamp\x3d" + (new Date).getTime();
                    $a.getJSON("https://127.0.0.1/device" + ("?algID\x3dCdkfQhWOtY\x26hashCode\x3d" + e + a), null,
                    function(a) {
                        var b = JSON.parse(a);
                        void 0 != lb && lb.postMessage(a, r.parent);
                        for (var d in b)"dfp" == d ? G("RAIL_DEVICEID") != b[d] && (W("RAIL_DEVICEID", b[d], 1E3), c.deviceEc.set("RAIL_DEVICEID", b[d])) : "exp" == d ? W("RAIL_EXPIRATION", b[d], 1E3) : "cookieCode" == d && (c.ec.set("RAIL_OkLJUJ", b[d]), W("RAIL_OkLJUJ", "", 0))
                    })
                }
            })
        },
        1)
    },
    

    };
    var mb = !1; u.addEventListener ? u.addEventListener("DOMContentLoaded",
    function b() {
    u.removeEventListener("DOMContentLoaded", b, !1);
    Pa()
    },
    !1) : u.attachEvent && u.attachEvent("onreadystatechange",
    function c() {
    mb || "interactive" != u.readyState && "complete" != u.readyState || (u.detachEvent("onreadystatechange", c), Pa(), mb = !0)
    })
    })();


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.