Update Tildes with "Newest reply" to 1.0.1

- Fix newest reply sorting algorithm (see ad00abe067)
This commit is contained in:
blankie 2024-03-04 19:13:49 +11:00
parent fab80b9266
commit 909dc69dc0
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 10 additions and 4 deletions

View File

@ -2,7 +2,7 @@
// @name Tildes with "Newest reply" // @name Tildes with "Newest reply"
// @namespace blankie-scripts // @namespace blankie-scripts
// @match https://tildes.net/* // @match https://tildes.net/*
// @version 1.0.0 // @version 1.0.1
// @author blankie // @author blankie
// @description A userscript that adds a "newest reply" to topics on Tildes // @description A userscript that adds a "newest reply" to topics on Tildes
// @inject-into content // @inject-into content
@ -12,8 +12,14 @@
"use strict"; "use strict";
function commentSortKey(li) { function commentSortKey(li) {
// Set `li` to the first reply if possible // Set `li` to the most nested reply
li = li.querySelector(".comment-tree-item") || li; 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); return new Date(li.querySelector(".comment-header .comment-posted-time").dateTime);
} }