Bangumi Staff Folding

Fold the excessive long staff list

目前为 2021-09-22 提交的版本。查看 最新版本

// ==UserScript==
// @name         Bangumi Staff Folding
// @namespace    https://gf.qytechs.cn/users/193469
// @description  Fold the excessive long staff list
// @version      1.0
// @author       Rui LIU (@liurui39660)
// @match        https://bgm.tv/subject/*
// @icon         https://icons.duckduckgo.com/ip2/bgm.tv.ico
// @license      MIT
// @run-at       document-end
// ==/UserScript==

(function () {
	'use strict';

	// If there are 12 names, the 11th and 12th will be hidden
	// Another typical value is 1, where only the most essential info is shown
	const threshold = 10;

	for (const li of document.querySelectorAll('#infobox > li')) {
		if (li.childNodes.length > threshold * 2 + 1) { // Entry name and commas
			const folded = document.createElement('span')
			for (let i = threshold * 2 + 1; i < li.childNodes.length;)
				folded.append(li.removeChild(li.childNodes[i]))
			folded.hidden = true;
			li.append(folded)

			const button = document.createElement('a')
			button.text = '\t>>>'
			button.href = ''
			button.onclick = ev => {
				ev.preventDefault()
				button.text = folded.hidden ? '\t<<<' : '\t>>>'
				folded.hidden = !folded.hidden
			}
			li.append(button)
		}
	}
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址