Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Windows 綜合教學 >> 關於 Windows

Win 10 正式版如何將小娜搜尋引擎改為 Google?自製 Chrome 擴充功能實現

編輯:關於 Windows

Win 10 任務列搜尋(Cortana)預設使用 Bing,習慣 Google 的用戶可透過自製 Chrome 擴充功能,將搜尋請求重導向至 Google。本文提供完整原始碼與打包教學。

製作步驟

  1. 建立資料夾 CortanaUseGoogle,內建兩個文字檔:CortanaUseGoogle.js、manifest.json。
  2. CortanaUseGoogle.js 內容:
    chrome.webRequest.onBeforeRequest.addListener(
      function(details) {
        return { redirectUrl: "https://www.google.com/search?q=" + details.url.split(/=|&/)[1].replace("%20", "+") };
      },
      {urls: ["https://cn.bing.com/search*"]},
      ["blocking"]
    );
  3. manifest.json 內容:
    {
      "name": "Cortana use Google",
      "version": "1.0",
      "manifest_version": 2,
      "description": "Just a extension",
      "background": { "scripts": ["CortanaUseGoogle.js"] },
      "permissions": ["webRequest", "webRequestBlocking", "https://cn.bing.com/"]
    }
  4. 開啟 Chrome「擴充功能」頁面,勾選「開發人員模式」,點擊「封裝擴充功能」,選擇資料夾產生 .crx 檔,拖入 Chrome 安裝。

Cortana 搜尋

封裝擴充功能

搜尋結果

改用百度或其他引擎

將 JS 中 https://www.google.com/search?q= 替換為 https://www.baidu.com/s?wd=,並移除 .replace("%20", "+") 即可。

前置條件

  • 需將 Chrome 設為預設瀏覽器。
  • 此為開發者模式安裝,Chrome 可能提示「非商店應用」。

這或許是您親手開發的第一個 Chrome 擴充功能!

Copyright © Windows教程網 All Rights Reserved