Greasy Fork is available in English.
try to take over the world!
// ==UserScript==
// @name NGA阴阳师板块版头可动态切换
// @namespace http://tampermonkey.net/
// @version 0.2.1
// @description try to take over the world!
// @author You
// @include https://ngabbs.com/thread.php?fid=538
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 版头
const topicDom = document.querySelector('#toptopics')
topicDom.style.display = 'none' // 默认隐藏
// 添加切换按钮
const buttonDom = document.createElement('button')
buttonDom.id = '_myButton'
buttonDom.innerText = '显示版头'
// 按钮容器
const pbDom = document.querySelector('#m_pbtntop')
pbDom.appendChild(buttonDom)
// 绑定事件
buttonDom.onclick = () => {
if (topicDom.style.display === 'none') {
buttonDom.innerText = '隐藏版头'
topicDom.style.display = ''
} else {
buttonDom.innerText = '显示版头'
topicDom.style.display = 'none'
}
}
// 样式
pbDom.style.position = 'relative'
buttonDom.style.padding = '10px 20px'
buttonDom.style.position = 'absolute'
buttonDom.style.top = '0'
// 隐藏其他
document.querySelector('#m_threads').querySelector('.w100').childNodes.forEach(item => {
if (item.toString() === '[object HTMLSpanElement]') {
item.style.display = 'none'
}
})
document.querySelector('#mainmenu').style.marginBottom = 0
})();