-
Notifications
You must be signed in to change notification settings - Fork 1
/
Chrome_GetBookmarks.ahk
92 lines (82 loc) · 2.09 KB
/
Chrome_GetBookmarks.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#Requires AutoHotkey 2.0
#Include D:\Downloads\cherry-snippet-v2-master\lib\Class_SQLiteDB.ahk
; #Include D:\SoftX\AHK_Scripts_V2\Lib\Image_ImagePut.ahk
; %LocalAppData%\Google\Chrome\
db_file:="D:\SoftX\AHK_Scripts_V2\Chrome_Bookmarks\Favicons"
DB := SQLiteDB()
DB.OpenDB(db_file)
Get_Icon_For_URL(strUrl)
If !DB.CloseDB()
MsgBox("Msg:`t" . DB.ErrorMsg . "`nCode:`t" . DB.ErrorCode, "SQLite Error", 16)
Get_Icon_For_URL(URL)
{
; URL:="https://mail.google.com/mail/"
IconID:=Get_Icon_ID_From_URL(URL)
blob:=Get_Icon_File(IconID)
FileObj := FileOpen('1.ico', "w")
FileObj.RawWrite(blob , blob.Size)
FileObj.Close()
return IconID ;. "`n" . IconFile
; get icon_id in table "icon_mapping" by url
Get_Icon_ID_From_URL(strURL)
{
sql_cmd := 'SELECT icon_id FROM icon_mapping WHERE page_url IN ("' . strURL . '");'
result:=IndexDb(sql_cmd)
return result
}
Get_Icon_File(icon_id_number)
{
sql_cmd := 'SELECT image_data FROM favicon_bitmaps WHERE icon_id =' . icon_id_number . ' AND width = 32;'
If !db.Query(sql_cmd, &query_result)
{
MsgBox("SQLite QUERY Error`n`nMessage: " . db.ErrorMsg . "`nCode: " . db.ErrorCode . "`nFile: " . db_file . "`nQuery: " . sql_cmd)
return 0
}
search_result := ''
Loop
{
result := query_result.Next(&row)
If !result
{
MsgBox("SQLite NEXT Error`n`nMessage: " . db.ErrorMsg . "`nCode: " . db.ErrorCode)
return 0
}
If result = -1
{
Break
}
search_result := row[1]
query_result.Free()
return search_result
}
}
IndexDb(sql_cmd)
{
If !db.Query(sql_cmd, &query_result)
{
MsgBox("SQLite QUERY Error`n`nMessage: " . db.ErrorMsg . "`nCode: " . db.ErrorCode . "`nFile: " . db_file . "`nQuery: " . sql_cmd)
return 0
}
search_result := ''
Loop
{
result := query_result.Next(&row)
If !result
{
MsgBox("SQLite NEXT Error`n`nMessage: " . db.ErrorMsg . "`nCode: " . db.ErrorCode)
return 0
}
If result = -1
{
Break
}
Loop query_result.ColumnCount
{
search_result .= row[A_Index] . A_Tab
}
search_result .= '`n'
}
query_result.Free()
return search_result
}
}