Update Tildes with "Newest reply" to 1.0.2
- Fix hang on https://tildes.net/~lgbt/1evw/children_to_no_longer_be_prescribed_puberty_blockers_nhs_england_confirms?b_comment_order=newest_reply
This commit is contained in:
parent
909dc69dc0
commit
cbebfa5995
|
@ -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.1
|
// @version 1.0.2
|
||||||
// @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
|
||||||
|
@ -23,12 +23,19 @@ function commentSortKey(li) {
|
||||||
return new Date(li.querySelector(".comment-header .comment-posted-time").dateTime);
|
return new Date(li.querySelector(".comment-header .comment-posted-time").dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortCommentsByNewestReply(ol = null) {
|
function sortCommentsByNewestReply(ol = null, sortedCommentTrees = null) {
|
||||||
ol = ol || document.querySelector("#comments");
|
ol = ol || document.querySelector("#comments");
|
||||||
|
sortedCommentTrees = sortedCommentTrees || new WeakSet();
|
||||||
|
|
||||||
let comments = [];
|
let comments = [];
|
||||||
for (let li of ol.children) {
|
for (let li of ol.children) {
|
||||||
sortCommentsByNewestReply(li.querySelector(".comment-tree"));
|
let commentTree = li.querySelector(".comment-tree");
|
||||||
|
if (!commentTree || sortedCommentTrees.has(commentTree)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sortedCommentTrees.add(commentTree);
|
||||||
|
sortCommentsByNewestReply(commentTree, sortedCommentTrees);
|
||||||
|
|
||||||
comments.push(li);
|
comments.push(li);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue