URL Clean

Clean / minimize large URLs by stripping tracking info

目前为 2020-11-23 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name URL Clean
  3. // @description Clean / minimize large URLs by stripping tracking info
  4. // @license BSD 3-Clause
  5. // @author Duckle29
  6. // @namespace https://github.com/Duckle29
  7. // @run-at document-start
  8. // @icon https://avatars3.githubusercontent.com/u/2756925?v=3&s=200
  9. // @homepageURL https://github.com/Duckle29/url_clean
  10. // @version 1.0
  11. //
  12. // @include /^https?:\/\/([a-zA-Z]{2,3}\.)?aliexpress\.com\/(item|store\/product)\/.*/
  13. // @include /^https?:\/\/(?:www\.)?ebay\.(?:(?:co.)?[a-zA-Z]{2,3})\/itm/
  14. // @history 1.0 Initial release
  15. // ==/UserScript==
  16.  
  17. (function()
  18. {
  19. 'use strict';
  20. var sites =
  21. [
  22. /^(https?:\/\/(?:www\.)?ebay\.(?:(?:co.)?[a-zA-Z]{2,3})\/itm)(?:\/[0-9a-zA-Z\-]+)(\/\d+)/,
  23. /^(https?:\/\/(?:[a-zA-Z]{2,3}\.)?aliexpress.com\/(?:item|store\/product))(\/[0-9_]+[.]html(?=$|[?]))/
  24. ];
  25.  
  26. sites.forEach(regReplace)
  27.  
  28. function regReplace(expression)
  29. {
  30. var groups = window.location.href.match(expression)
  31. if (groups == null)
  32. {
  33. return
  34. }
  35.  
  36. if (groups.length === 3 && groups[1]+groups[2] != window.location.href)
  37. {
  38. history.replaceState(null, '', groups[1]+groups[2]);
  39. }
  40. }
  41.  
  42. })();