Skip to content

Instantly share code, notes, and snippets.

@nothingmuch
Created January 6, 2010 13:21
Show Gist options
  • Save nothingmuch/270267 to your computer and use it in GitHub Desktop.
Save nothingmuch/270267 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
# fixed for recent version of Chrome by hac (https://gist.github.com/771425)
use strict;
use warnings;
use Mac::PropertyList qw(parse_plist_file);
use DBI;
my $app_support = "$ENV{HOME}/Library/Application Support";
my $dbh = DBI->connect("dbi:SQLite:dbname=$app_support/Google/Chrome/Default/Web Data");
my $plist = parse_plist_file("$app_support/Keywurl/Keywords.plist");
my $keywords = $plist->{keywords};
$dbh->begin_work;
my $t = time;
my $sth = $dbh->prepare(qq{
INSERT INTO keywords VALUES (
NULL, -- id
?, -- name
?, -- keyword
"", -- favicon url
?, -- url
0, -- show in default list
0, -- safe for auto replace
"", -- originating URL
$t, -- date created
0, -- usage count
"", -- input encodings
"", -- suggest url
0, -- prepopulate id
0, -- autogenerate keyword
0, -- logo id
0, -- created by policy
"" -- instant URL
)
});
foreach my $link ( keys %$keywords ) {
my $data = $keywords->{$link};
my $url = $data->{expansion}->value;
$url =~ s/\{query\}/{searchTerms}/g;
$sth->execute(
$link, # name
$link, # keyword
$url,
);
}
$dbh->commit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment