DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Firefox Advanced History Info
This shows you the time you last visited each URL in Firefox (sorted by the time you visited it)
#!/usr/bin/perl -w
#
# Firefox Advanced history info.
# Copy your places.sqlite to somewhere you can run this.
# (which is usually in:
# "C:\Documents and Settings\${USER}\Application Data\Mozilla\Firefox\Profiles\${PROFILE}\places.sqlite" )
# This calls the sqlite3 binary so doesn't need DBD::SQLite
#
use strict;
die "$0: ERROR - can't find places.sqlite\n" if ! -f 'places.sqlite';
my $hist;
my $run_query = 'echo "select last_visit_date, url from moz_places;" | sqlite3 places.sqlite';
open (QUERY, "$run_query|") || die "Can't run '$run_query': $!\n";
while (defined (my $line = <QUERY>)) {
if ( $line =~ /^([0-9]+)\|(.*)$/ ) {
my ($time, $url) = ($1, $2);
chomp $url;
if ( length($time) > 10 ) {
$time = substr($time, 0, 10);
}
$hist->{$url} = {
time => $time,
url => $url,
};
}
}
close QUERY;
my @mon = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
my @day = qw( Sun Mon Tue Wed Thu Fri Sat );
sub by_time ($$) {
my ($a, $b) = (shift, shift);
$hist->{$a}->{time} <=> $hist->{$b}->{time};
}
for my $key ( sort by_time keys %{$hist} ) {
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)
= gmtime($hist->{$key}->{time});
printf "%4d-%02d-%02d %02d:%02d:%02d (%s %02d %s %04d) %s\n",
$year + 1900, $mon + 1, $mday, $hour, $min, $sec,
$day[$wday], $mday, $mon[$mon], $year + 1900,
$hist->{$key}->{url};
}
NB: The current versions of Firefox give you more than this under History -> Show All History (Ctrl-Shift-H)





