I'm tring to create Chrome Extension for private purposes. Already did some work, but stucked in the part where I have to read *.txt file into an array. Can you tell me please, what I supposed to do, to read content of *.txt file to an array. What exactly I have to write in manifest, and in main script? I really did researches, but my skills doesn't allow me to understand what I have to do.
I've trying the code below, but it gives an empty alert
function readTextFile(file)
{
var rawFile = new XMLHttpRequest();
rawFile.open("GET", file, true);
rawFile.onreadystatechange = function ()
{
if(rawFile.readyState === 4)
{
if(rawFile.status === 200 || rawFile.status === 0)
{
var allText = rawFile.responseText.split('\n');
alert(allText);
}
}
};
rawFile.send(null);
}
readTextFile("file:///C:/Users/Admin/Desktop/PL/example.txt");