Reddit:折叠或展开所有线索
一键折叠所有顶级评论线索,或将它们全部重新展开。
可复制的代码
// Collapse every top-level comment, or expand them all again
const comments = document.querySelectorAll('shreddit-comment[depth="0"]');
const anyOpen = Array.prototype.some.call(comments, function (c) {
return c.getAttribute('collapsed') === null;
});
comments.forEach(function (c) {
if (anyOpen) { c.setAttribute('collapsed', ''); }
else { c.removeAttribute('collapsed'); }
});
如何使用此示例
- 用上方按钮复制代码。
- 安装 JustZix(2 分钟),在目标页面打开扩展。
- 添加一条匹配该页面的新规则。
- 启用操作面板,在「操作」选项卡中添加按钮并粘贴代码 — 一键运行。
为此示例评分
暂无评分 — 成为第一个。