Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected hidden div appears in html file

I have been trying to search this, but haven't even found anyone with the same problem.

For my assignment, I had to write a javascript code that would read all the text from the external page (from the same directory though), but that's not the problem. The problem appeared when I have created a test html file with some random text.

HTML Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test</title>
</head>
<body>    
    <p> Just a random text.</p>
    <h1> More of a random text</h1>
    <p> And again, just testing the program.</p>    
</body>
</html>

And this code is taken from the debugger:

Image of html file as from Inspector

The problem is my javascript code does read the text from this div element and append the array of words that i have.

Does anyone know why is this div generated and how to get rid of it ?

P.S I have tried creating other html files, but div appears there too.

Thanks in advance!

EDIT:

That's my JS code:

var externalPage;
var words = [];
var j = 0;

function indexOf(array, item) {
    for (var i = 0; i < array.length; i++) {

        if (array[i][0].toString() === item.toString()) return i;
    }
    return -1;
}

function clearNode(node) {

    while (node.firstChild) {
        node.removeChild(node.firstChild);
    }
}

function sortNumerically(words) {

return words.sort(function(a,b){
    return b[1] - a[1];
});

}

function sortAlphabetically(words) {

    return words.sort();
}


function openFile(url) {

    externalPage = window.open();
    externalPage.location = url;

}

function extractWords(node) {

    if (node.nodeType==Node.ELEMENT_NODE) {
        for (var m = node.firstChild; m!=null; m = m.nextSibling)
            extractWords(m);
    }
    else {

        var value = node.nodeValue.trim();
        value = value.split(/\s/);
        for(var i = 0; i < value.length; i++) {

            if(indexOf(words, value[i]) != -1) {

                words[indexOf(words, value[i])][1] =
                    words[indexOf(words, value[i])][1] + 1;

            } else if(value[i] != '') {

                words.push([]);
                words[j][0] = value[i];
                words[j][1] = 1;

                j++;
            }
        }
    }
}

function populateTable(arr) {

    var tbody = document.createElement('tbody');

    clearNode(tbody);

    for(var i = 0; i< words.length; i++) {

        var tr = document.createElement('tr');

        var tdW = document.createElement('td');
        var tdF = document.createElement('td');

        tdW.appendChild(document.createTextNode(arr[i][0]));
        tdF.appendChild(document.createTextNode(arr[i][1]));

        tr.appendChild(tdW);
        tr.appendChild(tdF);

        tbody.appendChild(tr);

    }

    document.getElementById('tableCounter').appendChild(tbody);

}

function generateArray(node) {

    words = [];
    j = 0;
    extractWords(node, words);
    alert(sortNumerically(words));

    populateTable(words);

}
like image 467
Oleg Nalivajev Avatar asked Oct 17 '22 17:10

Oleg Nalivajev


1 Answers

This hidden box is an effect of a virus. The page dataloading.net is know as a virus page. You can search for it with your favourite search-module (google, bing, ...).

like image 109
DomeTune Avatar answered Nov 04 '22 22:11

DomeTune