自定義搜索的配置存儲文件
"%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Web Data"
keywords 表結(jié)構(gòu)(Chrome v60 / 2017.09.04)
CREATE TABLE "keywords"
(
id INTEGER PRIMARY KEY,
short_name VARCHAR NOT NULL, -- 名稱
keyword VARCHAR NOT NULL, -- 關(guān)鍵字
favicon_url VARCHAR NOT NULL,
url VARCHAR NOT NULL, -- 鏈接
safe_for_autoreplace INTEGER,
originating_url VARCHAR,
date_created INTEGER DEFAULT 0,
usage_count INTEGER DEFAULT 0,
input_encodings VARCHAR, -- 編碼類型
suggest_url VARCHAR,
prepopulate_id INTEGER DEFAULT 0,
created_by_policy INTEGER DEFAULT 0,
instant_url VARCHAR,
last_modified INTEGER DEFAULT 0, -- 最后一次修改時(shí)間
sync_guid VARCHAR,
alternate_urls VARCHAR,
search_terms_replacement_key VARCHAR,
image_url VARCHAR,
search_url_post_params VARCHAR,
suggest_url_post_params VARCHAR,
instant_url_post_params VARCHAR,
image_url_post_params VARCHAR,
new_tab_url VARCHAR,
last_visited INTEGER DEFAULT 0
);
常用查詢字段
select
id,
short_name,
keyword,
input_encodings,
last_modified
from keywords;
查看百科(bk)的自定義搜索配置
select
id,
short_name,
keyword,
input_encodings,
last_modified
from keywords
where keyword = 'bk';
更新百科(bk)編碼
更新后 last_modified 增加,為了 chrome 能接收更改,同步服務(wù)端
update keywords
set input_encodings = 'UTF-8', last_modified = last_modified + 1
where keyword='bk';
命令行編碼
cmd 在 gbk
chcp 936編碼下,"百度貼吧"會展示為"鐧懼害璐村惂"
- 設(shè)置命令行展示編碼為 utf-8
chcp 65001
以上 2017.9 更新
前言
這個(gè)文檔從整理到今日發(fā)布跨度有一年了,至少在最后一次更新時(shí)還是有效的。之所以有了最后一次更新項(xiàng),是因?yàn)閏hrome的搜索設(shè)置經(jīng)歷了從無法同步到同步的轉(zhuǎn)變,同步的時(shí)間就是那個(gè)字段last_modified,類似于一個(gè)版本控制的標(biāo)識。
--update 2013.03.26
我將百度詞典的搜索別名定為:di,但發(fā)現(xiàn)編碼變成utf8了,但chrome不支持,我就通過如下方法手動修改:
update keywords set input_encodings = 'utf8' , last_modified = last_modified +1 where keyword='di';
---老資料update2010.5.4---
集成gb2312
sqlite "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Web Data" "update keywords set input_encodings = 'gb2312' where keyword='tb';
update keywords_backup set input_encodings = 'gb2312' where keyword='tb';
select * from keywords where keyword='tb';
select * from keywords_backup where keyword='tb'; "
背景資料
操作前的環(huán)境
設(shè)置了名為“百度貼吧”的搜索,關(guān)鍵字為“tb”,鏈接為http://tieba.baidu.com/f?kw=%s
搜索的內(nèi)容存儲在%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Web Data 推斷文件中的keywords表里,keywords_backup 為備份表。
| 對應(yīng)字段 | 注釋 |
|---|---|
| short_name | 名稱 |
| keyword | 關(guān)鍵字 |
| url | 鏈接 |
| input_encodings | 編碼類型 |
| last_modified | 最后一次修改時(shí)間 |
常用操作語句
- 修改keywords和keywords_backup中關(guān)鍵字為“tb”的記錄的編碼為GBK,并查看修改結(jié)果:
sqlite "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Web Data" "update keywords set input_encodings = 'gbk' where keyword='tb'; update keywords_backup set input_encodings = 'gbk' where keyword='tb'; select id,short_name,keyword,input_encodings,last_modified from keywords where keyword='tb'; select id,short_name,keyword,input_encodings,last_modified from keywords_backup where keyword='tb'; "
- 修改編碼,并更新最后修改的時(shí)間
sqlite "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Web Data" "update keywords set input_encodings = 'GB2312' , last_modified = last_modified +1 where keyword='tb'; update keywords_backup set input_encodings = 'GB2312' , last_modified = last_modified +1 where keyword='tb'; select id,short_name,keyword,input_encodings,last_modified from keywords where keyword='tb'; select id,short_name,keyword,input_encodings,last_modified from keywords_backup where keyword='tb'; "
- 查看當(dāng)前關(guān)鍵字為“tb”的記錄的狀態(tài):
sqlite "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Web Data" "select id,short_name,keyword,input_encodings,last_modified from keywords where keyword='tb'; select id,short_name,keyword,input_encodings,last_modified from keywords_backup where keyword='tb'; "
- 導(dǎo)出數(shù)據(jù)庫描述語句
echo ".output sql.txt" && echo ".schema > sql.txt" | sqlite "web data"
測試流程
- 關(guān)閉Chrome,查看當(dāng)前狀態(tài):
40|百度貼吧|tb||http://tieba.baidu.com/f?kw={searchTerms}|0|0||1330616134|0|||0|0|0|0||1330616134|7DA70CB3-119B-482B-8A87-1799E90FACBC
40|百度貼吧|tb||http://tieba.baidu.com/f?kw={searchTerms}|0||1330616134|0||0||0|0|0|0||1330616134|7DA70CB3-119B-482B-8A87-1799E90FACBC
- 關(guān)閉同步,通過chrome修改short_name(百度貼吧->百度貼吧1),關(guān)閉Chrome,查看狀態(tài):
40|百度貼吧1|tb||http://tieba.baidu.com/f?kw={searchTerms}|0|0||1330616134|0|||0|0|0|0||1330776225|7DA70CB3-119B-482B-8A87-1799E90FACBC
40|百度貼吧1|tb||http://tieba.baidu.com/f?kw={searchTerms}|0||1330616134|0||0||0|0|0|0||1330776225|7DA70CB3-119B-482B-8A87-1799E90FACBC
注: 兩者狀態(tài)中short_name與last_modified字段有變化。
- 開啟同步,多次測試tb,一切正常。重啟chrome,多次測試,未見異常。
注: 修改后的狀態(tài)被認(rèn)可,同步成功。
- 關(guān)閉Chrome,通過手工修改short_name(百度貼吧1->百度貼吧),查看狀態(tài):
sqlite "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Web Data" "update keywords set short_name = '百度貼吧' where keyword='tb'; update keywords_backup set short_name = '百度貼吧' where keyword='tb'; select * from keywords where keyword='tb'; select * from keywords_backup where keyword='tb'; "
40|百度貼吧|tb||http://tieba.baidu.com/f?kw={searchTerms}|0|0||1330616134|7|gbk||0|0|0|0||1330776225|7DA70CB3-119B-482B-8A87-1799E90FACBC
40|百度貼吧|tb||http://tieba.baidu.com/f?kw={searchTerms}|0||1330616134|7|gbk|0||0|0|0|0||1330776225|7DA70CB3-119B-482B-8A87-1799E90FACBC
- 啟動Chrome,稍等片刻(等待同步執(zhí)行),地址欄輸入tb+空格測試搜索名稱顯示。
注: 顯示亂碼
- 修改4的short_name,再次執(zhí)行:
sqlite "%USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default\Web Data" "update keywords set short_name = '鐧懼害璐村惂' where keyword='tb'; update keywords_backup set short_name = '鐧懼害璐村惂' where keyword='tb'; select * from keywords where keyword='tb'; select * from keywords_backup where keyword='tb'; "
注: “鐧懼害璐村惂” 為 手工修改前從命令行復(fù)制下的“百度貼吧”的另一種編碼形態(tài)。
- 重復(fù)5操作
注: 未見異常。