monthly reservation auto confirm

A new userscript

Size

2.2 KB

Version

1.0.1

Created

Mar 23, 2026

Updated

25 days ago

1// ==UserScript==
2// @name		monthly reservation auto confirm
3// @description		A new userscript
4// @version		1.0.1
5// @match		https://*.foresttrip.go.kr/*
6// @icon		https://foresttrip.go.kr/favicon.ico
7// ==/UserScript==
8(function() {
9    'use strict';
10    
11    const observer = new MutationObserver((mutationsList) => {
12        for (const mutation of mutationsList) {
13            if (mutation.type === 'childList') {
14                mutation.addedNodes.forEach(node => {
15                    if (node.nodeType === 1) {
16                        // 새 레이어 감지
17                        const layer = node.querySelector('[id^="mCSB_"].mCSB_container');
18                        if (layer) {
19                            console.log('새 레이어 생성됨!', layer);
20
21                            // 1️⃣ submitBtn 클릭
22                            layer.querySelectorAll('.submitBtn').forEach(btn => btn.click());
23
24                            // 2️⃣ 레이어 밖 체크박스 클릭 (id="chkAgree")
25                            const checkbox = document.getElementById('chkAgree'); 
26                            if (checkbox && !checkbox.checked) {
27                                checkbox.click();
28                                console.log('약관 체크박스 클릭 완료');
29                            }
30
31                            // 3️⃣ 버튼 클릭 후 생성되는 input focus
32                            const inputObserver = new MutationObserver(() => {
33                                const input = document.getElementById('atmtcRsrvtPrvntChrct');
34                                if (input) {
35                                    input.focus();
36                                    console.log('input focus 완료!');
37                                    inputObserver.disconnect(); // 한 번만 처리
38                                }
39                            });
40
41                            // input이 어디에 붙을지 모르니 body 전체 감시
42                            inputObserver.observe(document.body, { childList: true, subtree: true });
43                        }
44                    }
45                });
46            }
47        }
48    });
49
50    // body 전체 감시
51    observer.observe(document.body, { childList: true, subtree: true });
52})();