Redirect To Google

Fuck default baidu.

  1. // ==UserScript==
  2. // @name Redirect To Google
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Fuck default baidu.
  6. // @author Hnayan
  7. // @match *://www.baidu.com/s?wd=*
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12. //Just use '=' to split it,because all '=' in query's inside will convert to '%D3',as same as blank will convert.
  13. //So don't think about 'wd=bla=blah=bl3' and 'hello world'.
  14. const query = window.location.search.split('=')[1];
  15. const googleSite = `https://www.google.com.hk/search?q=${query}`;
  16. //I don't want to see baidu's page
  17. const mask = document.createElement("div");
  18. mask.id = 'maskk';
  19. mask.style = 'position:absolute;width:100%;height:100%;z-index:9999;left:0;top:0;background-color:gray;opacity:0.95;';
  20. document.body.appendChild(mask);
  21. //open in current tab
  22. const virtualButton=document.createElement("a");
  23. virtualButton.setAttribute('href', googleSite);
  24. virtualButton.click();
  25. })();