Greasy Fork

来自缓存

Greasy Fork is available in English.

NGA阴阳师板块版头可动态切换

try to take over the world!

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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
})();