From 909dc69dc0ef79b366b4500df4744ebcdc4e6ef7 Mon Sep 17 00:00:00 2001 From: blankie Date: Mon, 4 Mar 2024 19:13:49 +1100 Subject: [PATCH] Update Tildes with "Newest reply" to 1.0.1 - Fix newest reply sorting algorithm (see https://gitlab.com/blankX/tildes/-/commit/ad00abe067b3184daafe133d31d90633a917e234) --- Tildes with -Newest reply-.user.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Tildes with -Newest reply-.user.js b/Tildes with -Newest reply-.user.js index 856e663..f00d7b3 100644 --- a/Tildes with -Newest reply-.user.js +++ b/Tildes with -Newest reply-.user.js @@ -2,7 +2,7 @@ // @name Tildes with "Newest reply" // @namespace blankie-scripts // @match https://tildes.net/* -// @version 1.0.0 +// @version 1.0.1 // @author blankie // @description A userscript that adds a "newest reply" to topics on Tildes // @inject-into content @@ -12,8 +12,14 @@ "use strict"; function commentSortKey(li) { - // Set `li` to the first reply if possible - li = li.querySelector(".comment-tree-item") || li; + // Set `li` to the most nested reply + while (true) { + let reply = li.querySelector(".comment-tree-item"); + if (!reply) { + break; + } + li = reply; + } return new Date(li.querySelector(".comment-header .comment-posted-time").dateTime); } @@ -87,4 +93,4 @@ function addNewestReply() { addNewestReply(); if ((new URLSearchParams(location.search)).get("b_comment_order") === "newest_reply") { sortCommentsByNewestReply(); -} +} \ No newline at end of file