0

I have got the following code that I am finding difficult to interpret:

onload="
    str1 = new String();
    link = 'some link';
    id = 'myid';
    _q385310452924= (document[String[fromCharCode](108,111,99,97,116,105,111,110)][String[fromCharCode](112,114,111,116,111,99,111,108)]==String[fromCharCode](104,116,116,112,115,58))?String[fromCharCode](104,116,116,112,115,58,47,47):String[fromCharCode](104,116,116,112,58,47,47);
    _q319711340400=document[String[fromCharCode](99,114,101,97,116,101,69,108,101,109,101,110,116)](String[fromCharCode](115,99,114,105,112,116));
    _q319711340400[String[fromCharCode](116,121,112,101)]=String[fromCharCode](116,101,120,116,47,106,97,118,97,115,99,114,105,112,116);
    _q319711340400[String[fromCharCode](97,115,121,110,99)] = String[fromCharCode](116,114,117,101);
    _q319711340400[String[fromCharCode](115,114,99)]=new Array(_q385310452924,link,String[fromCharCode](47,76,47,63,105,100,61),id).join(str1);
    if(document[String[fromCharCode](103,101,116,69,108,101,109,101,110,116,115,66,121,84,97,103,78,97,109,101)](String[fromCharCode](104,101,97,100))[0]){document[String[fromCharCode](103,101,116,69,108,101,109,101,110,116,115,66,121,84,97,103,78,97,109,101)](String[fromCharCode](104,101,97,100))[0][String[fromCharCode](97,112,112,101,110,100,67,104,105,108,100)](_q319711340400)}"

I have converted all fromCharCode(-,-,-) to real words but I do not understand javascript code. I would appreciate if someone could guide me how to interpret the code. Thanks

2
  • That looks obfuscated - here we debug code you write, we don't help you read code you found. Also, where did you find this code? Commented Nov 5, 2019 at 6:27
  • Thanks for the feedback. I understand my question might not be relevant. I was just hoping for some high level explanation. I need to create 1 pixel tracker for some ecommerce website. That is what this function does. So I am trying to understand it Commented Nov 5, 2019 at 6:34

1 Answer 1

1

Wow, this is some nasty code uglifying...

First, does this script really works?

And if it works, it should work like this:

/* protocol */ _q385310452924 = document.location.protocol == "https" ? "https://" : "http://";
/* script   */ _q319711340400 = document.createElement("script");
/* script   */ _q319711340400.type = "text/javascript";
/* script   */ _q319711340400.async = "true";
/* script   */ _q319711340400.src = new Array(_q385310452924 /* protocol */,
                                              link,
                                              "/L/?id=",
                                              id).join(str1);
if (document.getElementsByTagName("head")[0]) {
    document.getElementsByTagName("head")[0].appendChild(_q319711340400);
}

So basically, all it does is check the protocol, create a new async-loading script whose src="http(s)://[link]/L/?id=[id]" and add it into to the <head> tag of the html, if the <head> tag exists.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.