newbiegalore
Programmer
Hello all ,
I am learning JS and extension programming and so am facing a few hurdles. I would greatly appreciate any pointers/code-samples/links to possible solutions.
My extension needs to read the history.dat file from the user's profile. I am trying to read the data stream and will need to extract the URLs from the file. Is there some easy/standard command/API to do this? I guess it must be a commonly implemented feature.
I have tried using String.fromCharCode(a-decimal-number); and written some functions based on code I saw on prodigynet.co.uk, they are listed at the very end of this post. I have not come across an API which could extract the URLs from the firefox history file. It would be great if someone could please point me in the right direction. All I can get using an alert on the read buffer is 61,104,116,116, ... etc.. which stands for =http:... . I tried to using alerts on String.fromCharCode for each character position via charAt, but it didn't work :-( .
Thanks again,
-A
=====================================================================
aResult is obtained from within
var ffhistobserver = {
onStreamComplete : function(aLoader, aContext, aStatus, aLength, aResult)
{
}};
and contains the actual data in the history file..next I tried to convert that to text..alas!!
var fftexti = clean_numstr(aResult, 16);
var fftexto = "" ;
for(jloop1=0; jloop1 < fftexti.length; jloop1+=2)
{
fftexto+=byteToChar(parseInt(fftexti.substring(i, i+2), 16));
}
function byteToChar(histnum)
{
if(histnum < 32 || histnum > 255) return " ";
return charArray[histnum-32];
}
function clean_numstr(raw_str, histbase)
{
var ret_str = "";
var histc = "";
var histi;
for(histi=0; histi < raw_str.length; histi++) {
histc = raw_str.charAt(histi);
if(histc == "0" || parseInt(histc, histbase) > 0) {
ret_str += histc;
}
}
return ret_str;
}
var charArray = new Array(
' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-',
'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
'<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '', 'Ç', 'ü',
'é', 'â', 'ä', 'à', 'å', 'ç', 'ê', 'ë', 'è', 'ï', 'î', 'ì', 'Ä', 'Å',
'É', 'æ', 'Æ', 'ô', 'ö', 'ò', 'û', 'ù', 'ÿ', 'Ö', 'Ü', 'ø', '£', 'Ø',
'×', 'ƒ', 'á', 'í', 'ó', 'ú', 'ñ', 'Ñ', 'ª', 'º', '¿', '®', '¬', '½',
'¼', '¡', '«', '»', '_', '_', '_', '¦', '¦', 'Á', 'Â', 'À', '©', '¦',
'¦', '+', '+', '¢', '¥', '+', '+', '-', '-', '+', '-', '+', 'ã', 'Ã',
'+', '+', '-', '-', '¦', '-', '+', '¤', 'ð', 'Ð', 'Ê', 'Ë', 'È', 'i',
'Í', 'Î', 'Ï', '+', '+', '_', '_', '¦', 'Ì', '_', 'Ó', 'ß', 'Ô', 'Ò',
'õ', 'Õ', 'µ', 'þ', 'Þ', 'Ú', 'Û', 'Ù', 'ý', 'Ý', '¯', '´', '', '±',
'_', '¾', '¶', '§', '÷', '¸', '°', '¨', '·', '¹', '³', '²', '_', ' ');
I am learning JS and extension programming and so am facing a few hurdles. I would greatly appreciate any pointers/code-samples/links to possible solutions.
My extension needs to read the history.dat file from the user's profile. I am trying to read the data stream and will need to extract the URLs from the file. Is there some easy/standard command/API to do this? I guess it must be a commonly implemented feature.
I have tried using String.fromCharCode(a-decimal-number); and written some functions based on code I saw on prodigynet.co.uk, they are listed at the very end of this post. I have not come across an API which could extract the URLs from the firefox history file. It would be great if someone could please point me in the right direction. All I can get using an alert on the read buffer is 61,104,116,116, ... etc.. which stands for =http:... . I tried to using alerts on String.fromCharCode for each character position via charAt, but it didn't work :-( .
Thanks again,
-A
=====================================================================
aResult is obtained from within
var ffhistobserver = {
onStreamComplete : function(aLoader, aContext, aStatus, aLength, aResult)
{
}};
and contains the actual data in the history file..next I tried to convert that to text..alas!!
var fftexti = clean_numstr(aResult, 16);
var fftexto = "" ;
for(jloop1=0; jloop1 < fftexti.length; jloop1+=2)
{
fftexto+=byteToChar(parseInt(fftexti.substring(i, i+2), 16));
}
function byteToChar(histnum)
{
if(histnum < 32 || histnum > 255) return " ";
return charArray[histnum-32];
}
function clean_numstr(raw_str, histbase)
{
var ret_str = "";
var histc = "";
var histi;
for(histi=0; histi < raw_str.length; histi++) {
histc = raw_str.charAt(histi);
if(histc == "0" || parseInt(histc, histbase) > 0) {
ret_str += histc;
}
}
return ret_str;
}
var charArray = new Array(
' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-',
'.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
'<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '', 'Ç', 'ü',
'é', 'â', 'ä', 'à', 'å', 'ç', 'ê', 'ë', 'è', 'ï', 'î', 'ì', 'Ä', 'Å',
'É', 'æ', 'Æ', 'ô', 'ö', 'ò', 'û', 'ù', 'ÿ', 'Ö', 'Ü', 'ø', '£', 'Ø',
'×', 'ƒ', 'á', 'í', 'ó', 'ú', 'ñ', 'Ñ', 'ª', 'º', '¿', '®', '¬', '½',
'¼', '¡', '«', '»', '_', '_', '_', '¦', '¦', 'Á', 'Â', 'À', '©', '¦',
'¦', '+', '+', '¢', '¥', '+', '+', '-', '-', '+', '-', '+', 'ã', 'Ã',
'+', '+', '-', '-', '¦', '-', '+', '¤', 'ð', 'Ð', 'Ê', 'Ë', 'È', 'i',
'Í', 'Î', 'Ï', '+', '+', '_', '_', '¦', 'Ì', '_', 'Ó', 'ß', 'Ô', 'Ò',
'õ', 'Õ', 'µ', 'þ', 'Þ', 'Ú', 'Û', 'Ù', 'ý', 'Ý', '¯', '´', '', '±',
'_', '¾', '¶', '§', '÷', '¸', '°', '¨', '·', '¹', '³', '²', '_', ' ');