SimpCity Replies

Adds a "View Replies" button under each post with improved performance and styling.

Dessa är versionerna av skriptet där koden uppdaterades. Visa alla versioner.

  • v0.3 2025-04-01

    Key Changes and Improvements:

    GM_addStyle: All CSS rules are moved into a single GM_addStyle block, making the JavaScript cleaner and styles easier to manage. Added some basic table styling (borders, padding, background, zebra-striping) and link styling.

    CSS Loading Animation: Replaced the setInterval for loading dots with a pure CSS keyframe animation (sc-ellipsis) applied via the sc-replies-loading-dots class.

    CSS Classes: Uses classes (sc-replies-button, sc-replies-container, sc-replies-table, etc.) instead of inline styles.

    DocumentFragment: Used in fetchAnswers when creating and appending table rows. This improves performance by adding all rows to the DOM in a single operation.

    Constants: Defined constants for button text and other repeated strings (BUTTON_TEXT_VIEW, LOADING_TEXT_BASE, etc.).

    Error Handling:

    Added ontimeout handler to GM_xmlhttpRequest.

    Ensured dataset.loading = "false" is set in all fetchAnswers exit paths (success, no replies, error).

    Added checks to disable the button if essential info (Post ID, Thread ID) cannot be found initially in addAnswerButton.

    Added console.warn if a reply block is missing expected data.

    Robustness:

    Used optional chaining (?.) when accessing potentially null properties (e.g., postLink?.href, headerLink?.getAttribute).

    Attempting a potentially more reliable way to get Post ID using closest('.message[data-content]') which is common in XenForo, with a fallback to the original data-lb-id method.

    Added a prominent comment warning about the fragility of the hardcoded searchId.

    Added rel="noopener noreferrer" to generated links for security.

    Added &o=date to the search URL to sort results chronologically (optional, remove if not desired).

    Code Structure: Minor improvements in variable naming and structure. Added trim() when extracting text content.


    Post ID Extraction: Improved reliability by trying the data-content attribute first and refining the extraction from the post link URL for the display text.

    Accessibility: Added title attribute to the time cell showing the full timestamp if available.

  • v0.2 2025-03-26