JavaScript// ==UserScript==
// @name 自动改“默认排序”为“最新评论”
// @namespace https://www.luogu.com.cn/user/1510406
// @version 1.0
// @description 自动改“默认排序”为“最新评论”。
// @author FlowerRed
// @match https://www.luogu.com.cn/article/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function run() {
let sel = '.comment-filter-line .combo-wrapper';
let btn = document.querySelector(sel);
if (btn && btn.textContent.includes('默认排序')) {
btn.click();
setTimeout(selopt, 100);
}
}
function selopt() {
let opts = document.querySelectorAll('.dropdown li');
for (let opt of opts) {
if (opt.textContent.trim() === '最新评论') {
opt.click();
break;
}
}
}
setTimeout(run, 200);
})();