Headlapse

Hide topic head with spoiler on all pages except first

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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