Google URL formatter

Removes the lengthy Google.com URL parameters and get a clean Google URL.

  1. // ==UserScript==
  2. // @name Google URL formatter
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Removes the lengthy Google.com URL parameters and get a clean Google URL.
  6. // @author You
  7. // @match https://google.com/search*
  8. // @match https://www.google.com/search*
  9.  
  10. // @require https://unpkg.com/url-parse@1.5.1/dist/url-parse.js
  11. // @require https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js
  12. // @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js
  13.  
  14. // @run-at document-idle
  15. // @noframes
  16.  
  17. // @license mit
  18. // ==/UserScript==
  19.  
  20.  
  21. (async function(){
  22.  
  23. console.log(moment().format(), "[Google URL formatter]");
  24.  
  25. console.log(moment().format(), `[Google URL formatter] old url: ${document.location.href}`);
  26.  
  27. console.log(moment().format(), "[Google URL formatter] parsing...");
  28. url = URLParse(document.location.href , true )
  29. url.query = _.omit(url.query, ["sourceid", "ie", "oq", "aqs", "gs_lcp", "ved", "uact", "sclient", "ei", "sxsrf" ]);
  30. // url.toString()
  31. url.host = ""
  32. url.protocol = ""
  33. url.pathname = ""
  34. url.slashes = false
  35.  
  36. console.log(moment().format(), "[Google URL formatter] modifying...");
  37. window.history.replaceState(null, null, url.toString());
  38. // window.history.replaceState(null, null, '?q=hoge');
  39.  
  40. console.log(moment().format(), `[Google URL formatter] new url: ${document.location.href}`);
  41.  
  42. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址