1

WebPage that I research uses JS for doing some stuff. In the JS source code of the webpage I found this

i.audioUnmaskSource(e.src)

When I am trying to call this function from the console in Chrome it says

VM1452:1 Uncaught ReferenceError: i is not defined
at <anonymous>:1:1

Also Scope in developer tools says that i is an Object and is inside the Closure. How can I access this function from Console in Chrome? Scope of devtools

Here is the part of code that is called. It is a function audioUnamskSource as you can see:

function r(e) {
    if (!a() && ~e.indexOf("audio_api_unavailable")) {
        var t = e.split("?extra=")[1].split("#")
          , n = "" === t[1] ? "" : o(t[1]);
        if (t = o(t[0]),
        "string" != typeof n || !t)
            return e;
        n = n ? n.split(String.fromCharCode(9)) : [];
        for (var r, s, l = n.length; l--; ) {
            if (s = n[l].split(String.fromCharCode(11)),
            r = s.splice(0, 1, t)[0],
            !i[r])
                return e;
            t = i[r].apply(null, s)
        }
        if (t && "http" === t.substr(0, 4))
            return t
    }
    return e
}
amandala
  • 15
  • 2
  • 6
Andreotti
  • 47
  • 1
  • 8
  • 2
    If you just enter `i` does it return something? – Charlie Fish Oct 16 '17 at 23:28
  • Well what is `i`? Pretty hard to help without the right code, but if something is not in global scope than you would not be able to call it. You can set a break point where it is defined and call it. – epascarello Oct 16 '17 at 23:28
  • https://stackoverflow.com/questions/11438549/how-do-i-search-through-scope-variables-in-google-chrome-developer-tools – chiliNUT Oct 16 '17 at 23:28
  • It's hard to understand which 'i' is it is exactly.Because code is written very strange.The are a lot of different i's.In Crome I can't click on 'i' and see which 'i' is it, like in example in Xcode or VS.I can show what is inside – Andreotti Oct 16 '17 at 23:36
  • added what is inside the function – Andreotti Oct 16 '17 at 23:42
  • The code looks minimized, so `i` is likely scoped. You can't access scoped variables. Look for the code that says `i = ...` (it's probably enclosed in something else) and add `window.i = i;` after it if you want to access `i` from your console. You shouldn't do this in production. – aaron Oct 17 '17 at 00:11
  • When you say it is inside of a closure, then I'm assuming a function/object is returned from inside of another function. That returned function/object needs to provide an interface to the function you are trying to call. I cannot see that interface in the code that you have shown. – Sean12 Oct 17 '17 at 01:55
  • Is this code cherry-picked from `audioplayer.js`? If so, here's the de-minified version: https://gist.github.com/anonymous/2a83dd7ee6024af69921d678b669ceb4. I can't make sense of it, perhaps others can help. – tresf Oct 17 '17 at 02:12
  • Yes that is 'audioplayer.js'.And I want to call function audioUnmaskSource from the console – Andreotti Oct 17 '17 at 10:12

0 Answers0