1

I am using SQLite3 library to read the Chrome's history. I am successful in reading the history however, when I try to insert the data, the data is inserted but doesn't shows up in Google Chrome's history. Here's my code to insert into History:

 SQLiteCommand Command = new SQLiteCommand();
 Command.Connection = Connection;
 Command.CommandText = "INSERT INTO urls(url,title,visit_count,typed_count,last_visit_time,hidden,favicon_id) VALUES ('My Website','http://coolsite.com',40,30,(@Date),0,0)";
 SQLiteParameter DateParam = new SQLiteParameter("Date", DbType.Int64);
 DateParam.Value = DateTime.Now.Ticks;
 Command.Parameters.Add(DateParam);
 Command.ExecuteNonQuery();

The History item is created using this code, but it won't appear if viewed in Google Chrome's History tab. The difference I find in my insertion and Chrome's insertion is the TimeStamp. Refer to the screenshot below:

https://i.stack.imgur.com/0MSnA.jpg

Any idea on how to add the row properly and make it appear in Chrome's History tab ?

DelegateX
  • 719
  • 3
  • 8
  • 1
    Chrome does not measure timestamps in Windows ticks. The database contains other tables which must have matching records. – CL. Sep 29 '13 at 12:38

1 Answers1

0

In order to enter the data properly to Chromes' tables, first you need the @Date parameter to fit Chrome's calculation, apparently 'webkit' format, of this parameter which is (pretty accurate):

long chromeTime = ConvertToUnixTime(DateTime.UtcNow) + 11644473600) * 1000000;

Where Convert to Unix time:

public static long ConvertToUnixTime(DateTime aDateTime)
{
    var epochTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
    return Convert.ToInt64((aDateTime - epochTime).TotalSeconds);
}

Along with that, the important part is to insert into 'visits' table a row with the matching id and eligible values, for example:

INSERT INTO visits(id,url,visit_time,from_visit,transition,segment_id,visit_duration) VALUES (3,50,1.305334687E+16,0,805306368,0,0)

If that doesn't work, try deleting the existing rows from 'urls' and 'visits' tables first.

Community
  • 1
  • 1
Moshisho
  • 2,781
  • 1
  • 23
  • 39