Kanika
Kanika

Reputation: 61

How to override 3rd part js function

I have this code for :

  (function(d,t,p){
    var e = d.createElement(t); e.charset = "utf-8"; e.src = p;
    var s = d.getElementsByTagName(t)[0]; s.parentNode.insertBefore(e,s)
   })(document,"script","http://js.testfreaks.com/onpage/gymsource.com/prd.js")

As you can see here this script is being included in my website.in this script a function used.

   function a(e, r) {

    }

I want to override it. Is it is possiable ?

Upvotes: 0

Views: 262

Answers (1)

Sabrina Luo
Sabrina Luo

Reputation: 3990

It's not possible to override the function a(e, r){}.

As you can see in http://js.testfreaks.com/onpage/gymsource.com/prd.js. The main code is wrapped with below code, which means the function a(e, r){} is not in global scope, but inside the scope of below function.

!function(t,e){
  // all the code
}(jQuery,testFreaks);

Only when the function is in global scope, will you be able to override it

Refer to: What does the exclamation mark do before the function?

Upvotes: 1

Related Questions