您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
简单的自动翻页
当前为
// ==UserScript== // @name NGA Auto Pagerize // @namespace https://greasyfork.org/users/263018 // @version 1.1.4 // @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 ATTACHMENT_STYLE_ENABLE_KEY = "ATTACHMENT_STYLE_ENABLE"; // 附件样式 const attachmentStyleEnable = GM_getValue(ATTACHMENT_STYLE_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]); }; // 翻页 if (ui.pageBtn) { const delay = (interval) => new Promise((resolve) => setTimeout(resolve, interval)); const retry = async (fn, retriesLeft = 10, interval = 160) => { try { return await fn(); } catch (error) { await delay(interval); if (retriesLeft > 0) { return await retry(fn, retriesLeft - 1, interval); } } }; const execute = (() => { const observer = new IntersectionObserver((entries) => { if (entries.find((item) => item.isIntersecting)) { retry(() => { if (ui.loadReadHidden.lock) { throw new Error(); } ui.loadReadHidden(0, 2); }); } }); return () => { const anchor = document.querySelector('[title="加载下一页"]'); if (anchor) { observer.observe(anchor); } else { observer.disconnect(); } }; })(); hookFunction(ui, "pageBtn", execute); execute(); } // 移除重复内容 if (ui.topicArg) { const execute = () => { ui.topicArg.data = ui.topicArg.data.reduce((accumulator, currentValue) => { const index = accumulator.findIndex((item) => item[8] === currentValue[8]); if (index < 0) { return [...accumulator, currentValue]; } currentValue[0].closest("TBODY").remove(); return accumulator; }, []); }; hookFunction(ui.topicArg, "loadAll", execute); execute(); } // 附件样式 if (ui.topicArg && attachmentStyleEnable) { const execute = () => { const elements = document.querySelectorAll('[title="主题中有附件"]'); elements.forEach((element) => { element.className = "block_txt white nobr vertmod"; element.style = "background-color: #BD7E6D"; element.innerHTML = "附件"; }) }; hookFunction(ui.topicArg, "loadAll", execute); execute(); } if (attachmentStyleEnable) { GM_registerMenuCommand('附件样式:启用', () => { GM_setValue(ATTACHMENT_STYLE_ENABLE_KEY, false); location.reload(); }); } else { GM_registerMenuCommand('附件样式:禁用', () => { GM_setValue(ATTACHMENT_STYLE_ENABLE_KEY, true); location.reload(); }); } })(commonui);