您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
置顶折叠
当前为
// ==UserScript== // @name NGA Topped Collapse // @namespace https://gf.qytechs.cn/users/263018 // @version 1.0.0 // @author snyssss // @description 置顶折叠 // @match *://bbs.nga.cn/* // @match *://ngabbs.com/* // @match *://nga.178.com/* // @grant GM_registerMenuCommand // @grant GM_setValue // @grant GM_getValue // @noframes // ==/UserScript== ((ui) => { if (!ui) return; // KEY const COLLAPSE_SUBFORUMS_ENABLE_KEY = "COLLAPSE_SUBFORUMS_ENABLE"; // 折叠子版块 const collapseSubForumsEnable = GM_getValue(COLLAPSE_SUBFORUMS_ENABLE_KEY) || false; // 钩子 const hookFunction = (object, functionName, callback) => { ((originalFunction) => { object[functionName] = function () { const returnValue = originalFunction.apply(this, arguments); callback.apply(this, [returnValue, originalFunction, arguments]); return returnValue; }; })(object[functionName]); }; // 是否折叠 let collapsed = true; // 主函数 const execute = () => { const topped = document.querySelector("#toptopics"); if (topped) { const postrow = topped.querySelector(".postrow"); const subForums = document.querySelectorAll( "#sub_forums_c, #more_sub_forums_c" ); const collapse = () => { [postrow, ...(collapseSubForumsEnable ? subForums : [])].forEach( (element) => { element.style = `display: ${collapsed ? "none" : "block"}`; } ); }; const button = topped.querySelector("A"); button.onclick = () => { collapsed = !collapsed; collapse(); return false; }; collapse(); } }; // 绑定事件 (() => { let initialized = false; hookFunction(ui, "eval", () => { if (initialized) return; if (ui.parseToppedTopic) { hookFunction(ui, "parseToppedTopic", execute); initialized = true; } }); execute(); })(); // 菜单项 if (collapseSubForumsEnable) { GM_registerMenuCommand("折叠子版块:启用", () => { GM_setValue(COLLAPSE_SUBFORUMS_ENABLE_KEY, false); location.reload(); }); } else { GM_registerMenuCommand("折叠子版块:禁用", () => { GM_setValue(COLLAPSE_SUBFORUMS_ENABLE_KEY, true); location.reload(); }); } })(commonui);
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址