Facebook Remove Redundant URL Ref

Remove refsrc in facebook url

  1. // ==UserScript==
  2. // @name Facebook Remove Redundant URL Ref
  3. // @namespace https://github.com/livinginpurple
  4. // @version 2019.04.25.07
  5. // @description Remove refsrc in facebook url
  6. // @author livinginpurple
  7. // @license WTFPL
  8. // @match http://*.facebook.com/*
  9. // @match https://*.facebook.com/*
  10. // @grant none
  11. // @run-at document-start
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. //https://m.facebook.com/story.php?story_fbid=426978937875840&id=291618078078594&refid=7&__tn__=-R
  17. console.log(GM_info.script.name + " is loading.");
  18. let SearchParameters = location.search.split('&');
  19. let uri = location.origin + location.pathname + SearchParameters[0] + "&" + SearchParameters[1];
  20. let keywords = ["refsrc", "__tn__", "__xts__"];
  21.  
  22. keywords.forEach(element => {
  23. if (location.href.includes(element)) {
  24. ModifyUrl(uri);
  25. }
  26. });
  27.  
  28. function ModifyUrl(replaceUri) {
  29. // 修改網址,且不留下歷史紀錄
  30. window.history.replaceState({},
  31. window.title,
  32. replaceUri
  33. );
  34. }
  35. console.log(GM_info.script.name + " is running.");
  36. })(window);