# Discourse에서 주제 닫기 및 아카이브하기 사용자 스크립트

**URL:** <https://meta.discourse.org/t/discourse-close-archive-topic-userscript/352211>\
**Category:** General\
**Created:** [2월 14, 2025, 4:23오전 UTC](https://meta.discourse.org/t/discourse-close-archive-topic-userscript/352211 "2025-02-14T04:23:57Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [2월 14, 2025, 6:07오후 UTC](https://meta.discourse.org/t/discourse-close-archive-topic-userscript/352211/8 "2025-02-14T18:07:45Z")

</div>

관리자이신가요, 아니면 모더레이터인가요? 관리자라면 유저스크립트에 의존하기보다 테마 컴포넌트를 직접 만들 수 있을 것입니다.

그렇다고 해도, 코드를 수정할 수 없는 사이트에서는 다양한 개선 사항을 위해 유저스크립트가 여전히 흥미로운 해결책입니다.

저는 많은 웹사이트에서 이를 사용하고 있습니다.

meta.discourse.org에서는 편집기 안에서 선택한 텍스트를 `<kbd>` 태그로 감싸는 `Ctrl`+`Shift`+`k` 단축키를 추가하는 스크립트를 하나 가지고 있습니다. 🙂

```js
// ==UserScript==
// @name meta.discourse.org용 <kbd> 단축키
// @namespace Violentmonkey Scripts
// @version 1.0
// @description meta.discourse.org의 텍스트 영역에 Ctrl + Shift + k로 <kbd> 태그 삽입
// @author chatGPT
// @match https://meta.discourse.org/*
// @grant none
// ==/UserScript==

(function() {
    'use strict';

    document.addEventListener('keydown', function(event) {
        if (event.ctrlKey && event.shiftKey && event.key === 'K') {
            const activeElement = document.activeElement;
            if (activeElement.tagName === 'TEXTAREA' && activeElement.classList.contains('ember-text-area')) {
                const start = activeElement.selectionStart;
                const end = activeElement.selectionEnd;
                const text = activeElement.value;
                const insertText = '<kbd>';
                const closeText = '</kbd>';

                const selectedText = text.slice(start, end);
                activeElement.value = text.slice(0, start) + insertText + selectedText + closeText + text.slice(end);

                const cursorPosition = end === start
                    ? start + insertText.length
                    : start + insertText.length + selectedText.length + closeText.length;

                activeElement.selectionStart = activeElement.selectionEnd = cursorPosition;

                event.preventDefault();
            }
        }
    });
})();

```

또한, Tampermonkey는 소스 코드가 공개되지 않았기 때문에 사용하지 않습니다. 저는 오픈 소스 소프트웨어를 선호하며, 경쟁 제품들이 여러 개 있지만(모두 비슷해 보이고 스크립트는 상호 호환됩니다) 가장 많이 사용되는 것은 [Violentmonkey](https://violentmonkey.github.io/)라고 생각합니다.

---

_[View the full topic](https://meta.discourse.org/t/discourse-close-archive-topic-userscript/352211)._
