Facebook Remove Redundant URL Ref

Remove refsrc in facebook url

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

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