linux下讓FireFox 默認使用google ncr或加密搜索

主要是因爲我這邊 google.com.hk 太慢了,甚至我發的一個請求GET http://www.google.com.hk/ 用了2000+ms。

所以,遷移到www.google.com是必須的。
但是你訪問https://www.google.com會302到http://www.google.com.hk/
所以先訪問www.google.com/ncr然後我估計它會寫一個cookie,然後你訪問https://www.google.com就不會302了,但https://www.google.com/ncr會跳到http頁面。

但是,萬一那天cookie清掉了呢?so,分析需求:

必須使用 .com ,不依賴cookie,使用https通訊。

1.在接下來的摸索中我發現http://www.google.com/ncr#hl=zh-CN&q=word(或者用符合搜索欄模式的url:http://www.google.com/ncr#?=&hl=zh-CN&q=word)可以不依賴cookie到.com,可惜https://www.google.com/ncr#hl=zh-CN&q=word會302到http頁面。

即要用不依賴cookie的ncr就沒法用https了

2.如果要用https的話就先訪問http://www.google.com/ncr來寫入cookie,然後搜索時訪問https://www.google.com/search?hl=zh_CN&q=word即可。

以下是兩種解決方案:

1.ncr方案(此方案不用管cookie,但是用不了https)

修改about:config中 keyword.URL 的值爲https://www.google.com.hk/ncr#hl=zh-cn&rls=org.mozilla:en-US:unofficial&q=

接下來修改/usr/lib64/firefox/searchplugins/google.xml文件

這是原文件的後三個Url標籤:

  1. <Url type="text/html" method="GET" template="https://www.google.com/search"> 
  2.   <Param name="q" value="{searchTerms}"/><Param name="ie" value="utf-8"/><Param name="oe" value="utf-8"/><Param name="aq" value="t"/><Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/> 
  3.   <MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/> 
  4. </Url> 
  5. <!-- Keyword search URL is the same as the default, but with an additional parameter --> 
  6. <Url type="application/x-moz-keywordsearch" method="GET" template="https://www.google.com/search"> 
  7.   <Param name="q" value="{searchTerms}"/><Param name="ie" value="utf-8"/><Param name="oe" value="utf-8"/><Param name="aq" value="t"/><Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/> 
  8.   <MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/> 
  9.   <Param name="channel" value="fflb"/> 
  10. </Url> 
  11. <!-- Context/Right-click search URL is the same as the default, but with an additional parameter --> 
  12. <Url type="application/x-moz-contextsearch" method="GET" template="https://www.google.com/search"> 
  13.   <Param name="q" value="{searchTerms}"/><Param name="ie" value="utf-8"/><Param name="oe" value="utf-8"/><Param name="aq" value="t"/><Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/> 
  14.   <MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/> 
  15.   <Param name="channel" value="rcs"/> 
  16. </Url> 
  17. <SearchForm>https://www.google.com/</SearchForm> 

修改後:

  1. <Url type="text/html" method="GET" template="https://www.google.com/ncr#">   
  2.   <Param name="Ignore" value="Ignore"/><Param name="hl" value="zh_CN"/><Param name="q" value="{searchTerms}"/><Param name="ie" value="utf-8"/><Param name="oe" value="utf-8"/><Param name="aq" value="t"/><Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/>   
  3.   <MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/>   
  4. </Url>   
  5. <!-- Keyword search URL is the same as the default, but with an additional parameter -->   
  6. <Url type="application/x-moz-keywordsearch" method="GET" template="https://www.google.com/ncr#">   
  7.   <Param name="Ignore" value="Ignore"/><Param name="hl" value="zh_CN"/><Param name="q" value="{searchTerms}"/><Param name="ie" value="utf-8"/><Param name="oe" value="utf-8"/><Param name="aq" value="t"/><Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/>   
  8.   <MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/>   
  9.   <Param name="channel" value="fflb"/>   
  10. </Url>   
  11. <!-- Context/Right-click search URL is the same as the default, but with an additional parameter -->   
  12. <Url type="application/x-moz-contextsearch" method="GET" template="https://www.google.com/ncr#">   
  13.   <Param name="Ignore" value="Ignore"/><Param name="hl" value="zh_CN"/><Param name="q" value="{searchTerms}"/><Param name="ie" value="utf-8"/><Param name="oe" value="utf-8"/><Param name="aq" value="t"/><Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/>   
  14.   <MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/>   
  15.   <Param name="channel" value="rcs"/>   
  16. </Url>   
  17. <SearchForm>https://www.google.com/ncr#hl=zh_CN</SearchForm>  

2.https方案(此方案用https搜索,但須cookie,否則會302到hk)

修改about:config中 keyword.URL 的值爲https://www.google.com/search?hl=zh_CN&rls=org.mozilla:en-US:unofficial&q=

修改/usr/lib64/firefox/searchplugins/google.xml文件,把前面提到的那一段修改爲:

  1. <Url type="text/html" method="GET" template="https://www.google.com/search"> 
  2.   <Param name="hl" value="zh_CN"/><Param name="q" value="{searchTerms}"/><Param name="ie" value="utf-8"/><Param name="oe" value="utf-8"/><Param name="aq" value="t"/><Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/> 
  3.   <MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/> 
  4. </Url> 
  5. <!-- Keyword search URL is the same as the default, but with an additional parameter --> 
  6. <Url type="application/x-moz-keywordsearch" method="GET" template="https://www.google.com/search"> 
  7.   <Param name="hl" value="zh_CN"/><Param name="q" value="{searchTerms}"/><Param name="ie" value="utf-8"/><Param name="oe" value="utf-8"/><Param name="aq" value="t"/><Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/> 
  8.   <MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/> 
  9.   <Param name="channel" value="fflb"/> 
  10. </Url> 
  11. <!-- Context/Right-click search URL is the same as the default, but with an additional parameter --> 
  12. <Url type="application/x-moz-contextsearch" method="GET" template="https://www.google.com/search"> 
  13.   <Param name="hl" value="zh_CN"/><Param name="q" value="{searchTerms}"/><Param name="ie" value="utf-8"/><Param name="oe" value="utf-8"/><Param name="aq" value="t"/><Param name="rls" value="{moz:distributionID}:{moz:locale}:{moz:official}"/> 
  14.   <MozParam name="client" condition="defaultEngine" trueValue="firefox-a" falseValue="firefox"/> 
  15.   <Param name="channel" value="rcs"/> 
  16. </Url> 
  17. <SearchForm>https://www.google.com/#hl=zh_CN</SearchForm> 

 個人意見:

我覺得還是用https的解決方案好,可以突破關鍵字過濾,至於有時候會清cookie,那就訪問一次https://www.google.com/ncr#hl=zh_CN唄。

測試環境:fedora17

注:hl=zh_CN保證頁面是中文

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章