// ==UserScript== // @name NGA 版头/版规/置顶部分折叠 // @namespace https://greasyfork.org/zh-CN/users/164691-shy07 // @version 0.9 // @description 自动折叠 NGA 版头/版规/置顶部分,需要的时候可以点击版头按钮显示(替换跳转功能) // @author Shy07 // @match *://nga.178.com/* // @match *://bbs.ngacn.cc/* // @match *://bbs.nga.cn/* // @grant none // jshint esversion:6 // @downloadURL none // ==/UserScript== (function() { 'use strict' let evHandle = false let manualOpen = false const markClassName = 'shy07-mark-ele' const markEle = document.createElement('i') markEle.className = markClassName const toggle = () => { const toppedTopic = document.querySelector('#toppedtopic') toppedTopic.style.display = manualOpen ? 'none': 'block' manualOpen = !manualOpen; } const checkEL = () => { const checkMarkEle = document.querySelector('.' + markClassName) if (checkMarkEle) return if (evHandle) { container.removeEventListener('click', toggle) } const container = document.querySelector('#toptopics a[class="block_txt block_txt_c0"]') container.href = 'javascript:;'; container.addEventListener('click', toggle); evHandle = true; document.body.append(markEle) } const hideToppedTopic = () => { const toppedTopic = document.querySelector('#toppedtopic'); if (!manualOpen) { toppedTopic.style.display = 'none'; } } hideToppedTopic(); setInterval(() => { hideToppedTopic(); checkEL() }, 400); })();