Facebook Group Sort by Recent

Forces Facebook groups to sort posts by "Recent Activity" automatically

当前为 2025-03-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Facebook Group Sort by Recent
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Forces Facebook groups to sort posts by "Recent Activity" automatically
  6. // @author CHATgpt
  7. // @match *://*.facebook.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to update sorting if not already set
  16. function updateSorting() {
  17. const url = new URL(window.location.href);
  18. if (!url.searchParams.has("sorting_setting")) {
  19. url.searchParams.set("sorting_setting", "RECENT_ACTIVITY");
  20. window.location.replace(url.href);
  21. }
  22. }
  23.  
  24. // Run once when the script loads
  25. updateSorting();
  26.  
  27. // Observe URL changes (Facebook uses dynamic navigation)
  28. let lastUrl = location.href;
  29. const observer = new MutationObserver(() => {
  30. if (location.href !== lastUrl) {
  31. lastUrl = location.href;
  32. updateSorting();
  33. }
  34. });
  35.  
  36. // Start observing changes to the page
  37. observer.observe(document, { subtree: true, childList: true });
  38. })();