Remove Redundant URL Search Parameters

Remove Redundant URL Search Parameters like fbclid

当前为 2019-07-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Remove Redundant URL Search Parameters
  3. // @namespace https://github.com/livinginpurple
  4. // @version 2019.07.22.11
  5. // @description Remove Redundant URL Search Parameters like fbclid
  6. // @author livinginpurple
  7. // @exclude https://*.google.com/*
  8. // @exclude https://*.facebook.com/*
  9. // @exclude https://www.plurk.com/*
  10. // @include *
  11. // @grant none
  12. // @run-at document-start
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. console.log(GM_info.script.name + " is loading.");;
  18. let TotalReplaceUri = location.href.split("?")[0];
  19. let FirstSearchParameter = location.search.split('&')[0];
  20. let PartialReplaceUri = TotalReplaceUri + FirstSearchParameter;
  21. let keywords = ["fbclid", "jobsource", "from=fb"];
  22.  
  23. keywords.forEach(element => {
  24. if (location.href.includes(element)) {
  25. ModifyUrl(TotalReplaceUri);
  26. }
  27. });
  28.  
  29. if (PartialReplaceUri.includes("fbclid") && !FirstSearchParameter.includes("fbclid")) {
  30. ModifyUrl(PartialReplaceUri);
  31. }
  32.  
  33. function ModifyUrl(replaceUri) {
  34. // 修改網址,且不留下歷史紀錄
  35. window.history.replaceState({},
  36. window.title,
  37. replaceUri
  38. );
  39. }
  40. console.log(GM_info.script.name + " is running.");
  41. })(document);