前情提要:请教佬友们,你们在看帖的时候,那个展开回复的按钮如何应对的?每次都要手动点一下,感觉好累,是我用法不对吗?
身处 AI 大时代,这种小问题怎么能难倒佬友们呢,这就让小长工 AI 来施施工。
楼中楼自动展开的油猴脚本附上:
// ==UserScript==
// @name 自动回复展开
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Automatically expands replies in comments
// @author GPT & zhong
// @match https://linux.do/t/topic/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Function to check and click the reply fold button
function expandReplies() {
// Select the element containing the text "个回复"
let replyElements = document.querySelectorAll('span');
replyElements.forEach(element => {
if (element.textContent.includes('个回复') && element.parentElement.getAttribute('aria-expanded') === 'false') {
// Click the parent element only if it is not already expanded
element.parentElement.click();
}
});
}
// Run the function every 2 seconds to ensure new elements are also clicked
setInterval(expandReplies, 2000);
})();