修改 Chrome 自定義搜索編碼

自定義搜索的配置存儲文件

"%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"

測試流程

  1. 關(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

  1. 關(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字段有變化。

  1. 開啟同步,多次測試tb,一切正常。重啟chrome,多次測試,未見異常。

注: 修改后的狀態(tài)被認(rèn)可,同步成功。

  1. 關(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
  1. 啟動Chrome,稍等片刻(等待同步執(zhí)行),地址欄輸入tb+空格測試搜索名稱顯示。

注: 顯示亂碼

  1. 修改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)。

  1. 重復(fù)5操作

注: 未見異常。

歷史參考

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 今天的大地是藍(lán)色的,波浪在我腳底奔騰, 我望著天空中撲騰著翅膀的麻雀,心里席卷過一陣舒適的風(fēng)。 衣襟擺動,太陽緩緩...
    虹一伶閱讀 179評論 0 0
  • 最近在寫的采集框架,為了實(shí)現(xiàn)功能擴(kuò)展,采用了大量的配置文件。這就造成了每添加一個(gè)站點(diǎn)都需要手動配置大量參數(shù)。對這種...
    涅槃1992閱讀 621評論 0 4
  • 當(dāng)你以為自己很努力了,其實(shí)還有比你更努力的人,加油,成功沒有捷徑!?。?!
    你再也不是我心中的你了閱讀 167評論 0 0

友情鏈接更多精彩內(nèi)容