Headlapse

Hide topic head with spoiler on all pages except first

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name           Headlapse
// @name:ru        Шапкозакрывательство
// @description    Hide topic head with spoiler on all pages except first
// @description:ru Каждой шапке по шапке! /Свернуть шапки тем под спойлер на всех страницах темы, кроме первой/
// @version        0.0.6
// @date           23.12.2017
// @author         Halibut
// @namespace      https://greasyfork.org/en/users/145947-halibut
// @homepageURL    https://greasyfork.org/en/scripts/36645-headlapse
// @supportURL     https://forum.ru-board.com/topic.cgi?forum=2&topic=56723&glp
// @license        HUG-WARE
// @include        http*://forum.ru-board.com/topic.cgi?forum=*&topic=*
// @exclude        /^https?:\/\/forum\.ru-board\.com\/topic\.cgi\?forum=\d+&topic=\d+(#\d+|#lt|&start=0)?$/
// @noframes
// @run-at         document-start
// @grant          none
// ==/UserScript==

/******************************************************************************
 * "THE HUG-WARE LICENSE" (Revision 2): As long as you retain this notice you *
 * can do whatever you want with this stuff. If we meet some day, and you     *
 * think this stuff is worth it, you can give me/us a hug.                    *
 *────────────────────────────────────────────────────────────────────────────*
 *────────────────────────────████────────────████────────────────────────────*
 *───────────────────────────█────██████████─█───██───────────────────────────*
 *──────────────────────────█───████────────███────█──────────────────────────*
 *──────────────────────────██─██─────────────███──█──────────────────────────*
 *───────────────────────────███────────────────███───────────────────────────*
 *───────────────────────────██──────────────────█────────────────────────────*
 *──────────────────────────██────███─────███────██───────────────────────────*
 *──────────────────────────█────██─██───██─██────█───────────────────────────*
 *──────────────────────────█─────███─────███─────█───────────────────────────*
 *───────────────────█████───█────────███────────█────█████───────────────────*
 *──────────────────██───███──█─────█──█──█─────██──███───██──────────────────*
 *──────────────────█───────██─█────███─███────██─██───────█──────────────────*
 *──────────────────██────────████───────────█████────────██──────────────────*
 *───────────────────███────────████████████████───────████───────────────────*
 *─────────────────────█████───██─────████─────██──█████──────────────────────*
 *─────────────────────────█████────────────────████──────────────────────────*
 *─────────────────────────────█─────────────────█────────────────────────────*
 *────────────────────────────██─────────────────██───────────────────────────*
 *────────────────────────────█───────────────────█───────────────────────────*
 *────────────────────────────█───────────────────█───────────────────────────*
 *────────────────────────────██─────────────────██───────────────────────────*
 *──────────────────────────████████─────────████████─────────────────────────*
 *─────────────────────────██──────██───────██──────██────────────────────────*
 *────────────────────────██────────█──────██────────██───────────────────────*
 *────────────────────────█─────────█──────█──────────█───────────────────────*
 *────────────────────────███─────████──█████──────███────────────────────────*
 *──────────────────────────████████──█████──████████─────────────────────────*
******************************************************************************/

window.addEventListener('DOMContentLoaded', function headlapse() {
    "use strict";
    this.removeEventListener('DOMContentLoaded', headlapse);
    const tpcHead = document.getElementsByClassName('tb')[0]
    if (!tpcHead || tpcHead && !tpcHead.querySelector('a.tpc[href$="&postno=1"]')) return;
    tpcHead.hidden = true;
    const dummyNode = tpcHead.parentNode.insertBefore(document.createElement('div'), tpcHead),
          show = '\u25BA Показать шапку темы',
          hide = '\u25BC Скрыть шапку темы';
    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>';
    const spoilerHead = tpcHead.previousElementSibling,
          spTitle = spoilerHead.getElementsByTagName('td')[0];
    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';
    spTitle.textContent = show;
    spoilerHead.onclick = e => {
        if (e.button != 0) return;
        e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation();
        tpcHead.hidden = !tpcHead.hidden;
        spTitle.textContent = tpcHead.hidden ? show : hide;
    }
});