TOKIS Comments Manager

Toggle the visibility of comments on TOKIS websites.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         TOKIS Comments Manager
// @namespace    https://github.com/Eta7H/TOKIS-Comments-Manager
// @version      0.1
// @description  Toggle the visibility of comments on TOKIS websites.
// @author       You
// @grant        GM_registerMenuCommand
// @grant        GM_getValue
// @grant        GM_setValue
// @include      https://manatoki*.net/*
// @include      https://newtoki*.com/*
// @include      https://booktoki*.com/*
// @license     MIT
// ==/UserScript==

(function() {
    'use strict';

    // 메뉴를 등록하는 함수
    function registerMenu() {
        GM_registerMenuCommand("댓글 섹션 초기 상태 토글", () => {
            var isExpanded = GM_getValue("isCommentsExpanded", false);
            GM_setValue("isCommentsExpanded", !isExpanded);
            alert("댓글 섹션 초기 상태가 " + (isExpanded ? "접혀있는 상태" : "펼쳐있는 상태") + "로 설정되었습니다. 변경사항을 적용하려면 페이지를 새로고침하세요.");
        });
    }

    // 메뉴 등록
    registerMenu();

    // 'viewcomment' 요소의 초기 상태
    var isExpanded = GM_getValue("isCommentsExpanded", false);

    var viewCommentElem = document.getElementById('viewcomment');
    if (viewCommentElem) {
        // 버튼 생성
        var toggleButton = document.createElement('button');
        toggleButton.innerHTML = isExpanded ? '닫' : '열기';
        viewCommentElem.parentNode.insertBefore(toggleButton, viewCommentElem);

        // 초기 상태 설정
        viewCommentElem.style.display = isExpanded ? 'block' : 'none';

        // 버튼 클릭 이벤트
        toggleButton.addEventListener('click', function() {
            isExpanded = !isExpanded;
            viewCommentElem.style.display = isExpanded ? 'block' : 'none';
            toggleButton.innerHTML = isExpanded ? '닫기' : '열기';
        });
    }
})();