Headlapse

Hide topic head with spoiler on all pages except first

当前为 2017-12-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Headlapse
  3. // @name:ru Шапкозакрывательство
  4. // @description Hide topic head with spoiler on all pages except first
  5. // @description:ru Каждой шапке по шапке! /Свернуть шапки тем под спойлер на всех страницах темы, кроме первой/
  6. // @version 0.0.4
  7. // @date 23.12.2017
  8. // @author Halibut
  9. // @namespace https://greasyfork.org/en/users/145947-halibut
  10. // @homepageURL https://greasyfork.org/en/scripts/36645-headlapse
  11. // @supportURL https://forum.ru-board.com/topic.cgi?forum=2&topic=56723&glp
  12. // @license HUG-WARE
  13. // @include http*://forum.ru-board.com/topic.cgi?forum=*&topic=*
  14. // @exclude /^https?:\/\/forum\.ru-board\.com\/topic\.cgi\?forum=\d+&topic=\d+(#\d+|&start=0)?$/
  15. // @noframes
  16. // @run-at document-start
  17. // @grant none
  18. // ==/UserScript==
  19.  
  20. /******************************************************************************
  21. * "THE HUG-WARE LICENSE" (Revision 2): As long as you retain this notice you *
  22. * can do whatever you want with this stuff. If we meet some day, and you *
  23. * think this stuff is worth it, you can give me/us a hug. *
  24. *────────────────────────────────────────────────────────────────────────────*
  25. *────────────────────────────████────────────████────────────────────────────*
  26. *───────────────────────────█────██████████─█───██───────────────────────────*
  27. *──────────────────────────█───████────────███────█──────────────────────────*
  28. *──────────────────────────██─██─────────────███──█──────────────────────────*
  29. *───────────────────────────███────────────────███───────────────────────────*
  30. *───────────────────────────██──────────────────█────────────────────────────*
  31. *──────────────────────────██────███─────███────██───────────────────────────*
  32. *──────────────────────────█────██─██───██─██────█───────────────────────────*
  33. *──────────────────────────█─────███─────███─────█───────────────────────────*
  34. *───────────────────█████───█────────███────────█────█████───────────────────*
  35. *──────────────────██───███──█─────█──█──█─────██──███───██──────────────────*
  36. *──────────────────█───────██─█────███─███────██─██───────█──────────────────*
  37. *──────────────────██────────████───────────█████────────██──────────────────*
  38. *───────────────────███────────████████████████───────████───────────────────*
  39. *─────────────────────█████───██─────████─────██──█████──────────────────────*
  40. *─────────────────────────█████────────────────████──────────────────────────*
  41. *─────────────────────────────█─────────────────█────────────────────────────*
  42. *────────────────────────────██─────────────────██───────────────────────────*
  43. *────────────────────────────█───────────────────█───────────────────────────*
  44. *────────────────────────────█───────────────────█───────────────────────────*
  45. *────────────────────────────██─────────────────██───────────────────────────*
  46. *──────────────────────────████████─────────████████─────────────────────────*
  47. *─────────────────────────██──────██───────██──────██────────────────────────*
  48. *────────────────────────██────────█──────██────────██───────────────────────*
  49. *────────────────────────█─────────█──────█──────────█───────────────────────*
  50. *────────────────────────███─────████──█████──────███────────────────────────*
  51. *──────────────────────────████████──█████──████████─────────────────────────*
  52. ******************************************************************************/
  53.  
  54. window.addEventListener('DOMContentLoaded', function headlapse() {
  55. "use strict";
  56. this.removeEventListener('DOMContentLoaded', headlapse);
  57. const tpcHead = document.getElementsByClassName('tb')[0]
  58. if (!tpcHead || tpcHead && !tpcHead.querySelector('a.tpc[href$="&postno=1"]')) return;
  59. tpcHead.hidden = true;
  60. const dummyNode = tpcHead.parentNode.insertBefore(document.createElement('div'), tpcHead),
  61. show = '\u25BA Показать шапку темы',
  62. hide = '\u25BC Скрыть шапку темы';
  63. dummyNode.outerHTML = '<table width="95%" cellspacing="1" cellpadding="3" bgcolor="#999999" align="center" border="0"><tbody><tr><td valign="middle" bgcolor="#dddddd" align="left"></td></tr></tbody></table>';
  64. const spoilerHead = tpcHead.previousElementSibling,
  65. spTitle = spoilerHead.getElementsByTagName('td')[0];
  66. spoilerHead.style.cssText = '-moz-user-select: none !important;-webkit-user-select: none !important; -ms-user-select: none !important; user-select: none !important; cursor: pointer !important';
  67. spTitle.textContent = show;
  68. spoilerHead.onclick = e => {
  69. if (e.button != 0) return;
  70. e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation();
  71. tpcHead.hidden = !tpcHead.hidden;
  72. spTitle.textContent = tpcHead.hidden ? show : hide;
  73. }
  74. });