Bangumi Staff Folding

Fold the excessive long staff list

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

  1. // ==UserScript==
  2. // @name Bangumi Staff Folding
  3. // @namespace https://gf.qytechs.cn/users/193469
  4. // @description Fold the excessive long staff list
  5. // @version 1.1
  6. // @author Rui LIU (@liurui39660)
  7. // @match https://bgm.tv/subject/*
  8. // @match https://bangumi.tv/subject/*
  9. // @icon https://icons.duckduckgo.com/ip2/bgm.tv.ico
  10. // @license MIT
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict';
  16.  
  17. // If there are 12 names, the 11th and 12th will be hidden
  18. // Another typical value is 1, where only the most essential info is shown
  19. const threshold = 10;
  20.  
  21. for (const li of document.querySelectorAll('#infobox > li')) {
  22. if (li.childNodes.length > threshold * 2 + 1) { // Entry name and commas
  23. const folded = document.createElement('span');
  24. for (let i = threshold * 2 + 1; i < li.childNodes.length;)
  25. folded.append(li.removeChild(li.childNodes[i]));
  26. folded.hidden = true;
  27. li.append(folded);
  28.  
  29. const button = document.createElement('a');
  30. button.text = `\t[+${Math.ceil(folded.childNodes.length / 2)}]`;
  31. button.alt_text = '\t[<<<]';
  32. button.href = '';
  33. button.onclick = ev => {
  34. ev.preventDefault();
  35. folded.hidden = !folded.hidden;
  36. [button.text, button.alt_text] = [button.alt_text, button.text];
  37. };
  38. li.append(button);
  39. }
  40. }
  41. })();

QingJ © 2025

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