c# - 为谷歌浏览器设置默认搜索引擎

标签 c# .net google-chrome

我必须开发一个 exe 应用程序来替换 Google Chrome 的默认搜索引擎,并在安装该 exe 后设置我的 Google Chrome 私有(private)搜索引擎。

最佳答案

首选项保存在 Preferences 中文件在 C:\Users\##UserName##\AppData\Local\Google\Chrome\User Data\Default .

这是一个 JSON 文件。您应该查找文件的以下部分:

   "default_search_provider": {
      "alternate_urls": [ "{google:baseURL}#q={searchTerms}", "{google:baseURL}search#q={searchTerms}", "{google:baseURL}webhp#q={searchTerms}" ],
      "enabled": true,
      "encodings": "UTF-8",
      "icon_url": "http://www.google.com/favicon.ico",
      "id": "2",
      "image_url": "{google:baseURL}searchbyimage/upload",
      "image_url_post_params": "encoded_image={google:imageThumbnail},image_url={google:imageURL},sbisrc={google:imageSearchSource},original_width={google:imageOriginalWidth},original_height={google:imageOriginalHeight}",
      "instant_url": "{google:baseURL}webhp?sourceid=chrome-instant&{google:RLZ}{google:forceInstantResults}{google:instantExtendedEnabledParameter}{google:ntpIsThemedParameter}{google:omniboxStartMarginParameter}ie={inputEncoding}",
      "instant_url_post_params": "",
      "keyword": "google.com",
      "name": "Google",
      "new_tab_url": "{google:baseURL}_/chrome/newtab?{google:RLZ}{google:instantExtendedEnabledParameter}{google:ntpIsThemedParameter}ie={inputEncoding}",
      "prepopulate_id": "1",
      "search_terms_replacement_key": "espv",
      "search_url": "{google:baseURL}search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:bookmarkBarPinned}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}{google:omniboxStartMarginParameter}ie={inputEncoding}",
      "search_url_post_params": "",
      "suggest_url": "{google:baseSuggestURL}search?{google:searchFieldtrialParameter}client={google:suggestClient}&xssi=t&q={searchTerms}&{google:cursorPosition}{google:zeroPrefixUrl}{google:pageClassification}sugkey={google:suggestAPIKeyParameter}",
      "suggest_url_post_params": "",
      "synced_guid": "CE1B8BFD-412B-4AB3-B597-325B07CA7E76"
   },

如果您从浏览器外部更改该文件,我不知道浏览器会如何 react !当用户决定使用 Google 帐户在不同计算机之间同步 Chrome 设置时,它可能会同步回存储在云中的版本。

关于c# - 为谷歌浏览器设置默认搜索引擎,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21397989/

相关文章:

c# - 从 .NET 网络应用程序中删除 ReportViewer,仍在寻找 ReportViewer dll

c# - 如何在 Controller 中获取登录用户的 ID?

c# - Marshal.SizeOf(typeof(IntPtr)) 与 sizeof(IntPtr)

html - IE 11 以不同于其他浏览器的方式显示 CSS

javascript - 从 chrome.storage.sync 保存和检索

c# - 通过 Web 服务访问 Team Foundation Server 的信息

c# - 异步 C# 服务器连续从多个套接字读取

c# - 如何模拟 JsonReader 单元测试自定义 JsonConverter

google-chrome - 尝试在 Headless Chrome V71 上运行时 Protractor 测试用例执行失败

c# - 如何在 Nancy 中编写接受 JSON 的 post 方法以及如何从 C# 客户端调用它?