🏠 Home 

遗弃百度,拥抱谷歌

使用百度时自动携带搜索参数跳转去谷歌


安装此脚本?
  1. // ==UserScript==
  2. // @name 遗弃百度,拥抱谷歌
  3. // @namespace gogogoghost
  4. // @version 0.4
  5. // @description 使用百度时自动携带搜索参数跳转去谷歌
  6. // @author $(ghost)
  7. // @license MIT
  8. // @match https://www.baidu.com/*
  9. // @run-at document-start
  10. // @grant none
  11. // ==/UserScript==
  12. (function() {
  13. 'use strict';
  14. if(window.leaveBaidu){
  15. return;
  16. }
  17. window.leaveBaidu=true;
  18. const srcKey='wd=';
  19. const destUrl='https://www.google.com/search?q=';
  20. let search=window.location.search;
  21. let indexStart=search.indexOf(srcKey);
  22. if(indexStart>0){
  23. indexStart+=srcKey.length-1;
  24. let indexEnd=search.indexOf('&',indexStart);
  25. if(indexEnd<0){
  26. indexEnd=search.length;
  27. }
  28. let keyword=search.substring(indexStart+1,indexEnd);
  29. window.location.href=destUrl+keyword;
  30. }
  31. })();