Remove junk URL parameters

Hides UTM and other tracking parameters from URLs.

  1. // ==UserScript==
  2. // @name Remove junk URL parameters
  3. // @namespace DavidJCobb
  4. // @description Hides UTM and other tracking parameters from URLs.
  5. // @include http://*
  6. // @include https://*
  7. // @version 1
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. {
  12. let url = new URL(window.location.href);
  13. { // Remove garbage keys
  14. let params = url.searchParams;
  15. if (params.get("wpsrc") == "socialedge")
  16. params.delete("wpsrc");
  17. for(var key of params.keys()) {
  18. switch (key) {
  19. case "tse_id":
  20. params.delete(key);
  21. continue;
  22. }
  23. if (key.startsWith("utm_"))
  24. params.delete(key);
  25. }
  26. }
  27. //
  28. // show altered URL in URL bar
  29. //
  30. history.replaceState(
  31. {},
  32. window.title,
  33. url.href
  34. );
  35. }

QingJ © 2025

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