Facebook Comment Sorter

Forces Facebook comments to show "All Comments" or "Newest" instead of "Most Relevant" + Auto-expand replies

这些是此脚本的所有版本。 只显示代码变更过的版本。

  • v2.1 2025-06-03

    Facebook Comment Sorter - Changelog

    Version 2.1 (2025-01-06) - Reply Expansion Update 🚀

    ✨ New Features

    Automatic Comment Reply Expansion

    • Smart Reply Detection: Automatically finds and expands reply buttons with multi-language support
      • Detects patterns like "View X replies", "X balasan", "Show more replies"
      • Supports numeric patterns in 12+ languages
      • Excludes hide/collapse buttons and "load more comments" buttons
    • Viewport-Aware Processing: Only expands replies that are visible on screen (configurable)
    • Scroll Position Preservation: Maintains your reading position when replies expand
    • Performance Optimized:
      • Processes one reply button at a time to avoid overwhelming the page
      • Debounced scroll handling for smooth performance
      • Configurable delays between expansions

    Enhanced Configuration System

    const CONFIG = {
        sortPreference: "all",      // "newest" or "all"
        debug: true,               // Console logging
        expandReplies: true,       // Auto-expand replies
        replyExpandDelay: 1000,    // Delay between expansions (ms)
        viewportOnly: true         // Only expand visible replies
    };
    

    🔧 Improvements

    • Better Performance: Added debouncing for scroll events and mutation observers
    • Memory Management: Properly clears processed reply buttons on page navigation
    • Enhanced Debugging: Added specific logs for reply expansion activities
    • Code Organization: Separated reply expansion logic into dedicated functions

    📝 Technical Details

    • Reply Button Detection: Uses advanced text pattern matching for multiple languages
    • Scroll Handling: Implements passive event listeners for better performance
    • State Management: Uses WeakSet for processed buttons to prevent memory leaks

    🌍 Reply Expansion Language Support

    Detects reply buttons in:

    • English: "replies", "view replies", "X more replies"
    • Indonesian: "balasan", "lihat balasan", "X balasan lagi"
    • Spanish: "respuestas"
    • French: "réponses"
    • German: "antworten"
    • Italian: "risposte"
    • Dutch: "antwoorden"
    • Russian: "ответов"
    • Chinese: "回复"
    • Japanese: "返信"
    • Arabic: "ردود"
    • Hindi: "उत्तर"
  • v2.0 2025-06-01

    Version 2.0 - "finally fixed That annoying bug" update

    What Got Fixed

    • The big one: Script was being dumb and clicking "Newest" when you wanted "All Comments". Here's what was happening:
      • Facebook's "Newest" menu item actually contains text like "NewestShow all comments with the newest comments first"
      • Our old matching logic saw "all comments" in there and thought it was the "All Comments" option
      • So when you set sortPreference = "all", it kept clicking "Newest" instead
      • Now we check if the text STARTS with our target words instead of just containing them
    • Menu detection completely rewritten - now it actually separates menu titles from descriptions
    • Fixed the script randomly stopping working on some comment sections

    What's New

    • Smart matching system: Tries 3 different strategies to find the right menu option:
      1. Looks for items that start with the exact text we want
      2. Tries to extract just the title part (before Facebook's description text)
      3. Falls back to menu positions if text matching fails (Most Relevant=0, Newest=1, All Comments=2)
    • Debug mode: Set DEBUG = true to see exactly what's happening in the console
      • Shows all menu items it finds
      • Tells you which matching strategy worked
      • Logs API modifications
    • Better language support: Added more translations and smarter text detection
    • More API coverage: Now modifies additional Facebook parameters like view_option, sort_by, isInitialFetch

    Under the Hood Stuff

    • Completely rewrote the menu item matching logic (was a mess before)
    • Enhanced GraphQL POST body modification - now catches more API calls
    • Better error recovery - removes buttons from processed list if menu doesn't appear
    • Added comprehensive parameter mappings for both XMLHttpRequest and fetch
    • Improved button filtering to avoid clicking wrong elements
    • More robust URL change detection

    How to Use It

    Same as before - just change the setting at the top:

    const sortPreference = "all";    // for all comments
    const sortPreference = "newest"; // for newest first
    

    Known Issues

    • Sometimes needs a second try on slow connections
    • Facebook changes their interface randomly, so it might break occasionally

    Version 1.1 (Previous Update)

    • Fixed some menu clicking issues
    • Added support for different languages
    • Made it work with Facebook's GraphQL API changes

    Version 1.0 (First Release)

    • Basic comment sorting
    • Worked... most of the time 😅

    Note: If something breaks, check the browser console with DEBUG = true and let me know what you see!

  • v2.0 2025-06-01

    facebook comment sorter: fix various known bug, major update

  • v1.1 2025-04-24 Imported from URL
  • v1.1 2025-04-23

    Facebook Comment Sorter v1.1 - Changelog

    What's changed in this version?

    Bug Fixes

    • Fixed issue with unwanted filter popups on profile pages
    • Resolved problem where script stopped functioning on comment sections
    • Eliminated popup spam when browsing pages with "filters" elements

    Improvements

    • Added targeted blocklist for problematic filter buttons
    • Improved detection of comment sort buttons vs profile filter buttons
    • Enhanced parent element checking to avoid triggering profile filter UI
    • Optimized button selection logic for better accuracy
    • Added specific checks for filter dialogs to prevent unwanted interactions

    Code Enhancements

    • Simplified button detection logic for better maintainability
    • Reorganized code structure for clearer separation of concerns
    • Improved error handling when interacting with Facebook UI elements
    • Enhanced URL processing for more reliable comment sorting
    • Optimized performance by reducing unnecessary button processing
  • v1.0 2025-04-17