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保证页面是中文

你可能感兴趣的:(linux,Google,https,cookie,hk)