1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// ==UserScript==
// @name ZB1 Auto Ticket Grabber v1.7
// @namespace http://tampermonkey.net/
// @version 1.7
// @description 自動搶 ZEROBASEONE 6881 元票種,處理會員碼、條款、錯誤視窗與持續點擊下一步直到成功送出!
// @author Kersi
// @match https://kktix.com/events/zb1wt-25-tp-01/registrations/new
// @grant none
// ==/UserScript==

(function () {
'use strict';

const targetPrice = 6881;
const memberCode = 'VZMNW093WF5W'; // ← 請填入你的 ZEROSE 會員代碼
const ticketQuantity = 1; // ← 可改成 1 或 2
let hasStarted = false;

function findTargetTicketBlock() {
const priceElements = document.querySelectorAll('.ticket-price');
for (const priceEl of priceElements) {
const priceText = priceEl.textContent || '';
const price = parseInt(priceText.replace(/[^\d]/g, ''), 10);
if (price === targetPrice) {
return priceEl.closest('.ticket') || priceEl.parentElement;
}
}
return null;
}

function selectTicket(ticketBlock) {
const plusBtn = ticketBlock.querySelector('.plus');
if (plusBtn) {
for (let i = 0; i < ticketQuantity; i++) {
plusBtn.click();
}
console.log(`🎫 已選擇 ${ticketQuantity} 張票`);
}
}

function fillMemberCode() {
const radioInput = document.querySelector('input[type="radio"][name^="condition-"]');
if (radioInput && !radioInput.checked) {
radioInput.click();
console.log('🔘 已選擇資格 radio');
}

const memberCodeInput = document.querySelector('.member-code');
if (memberCodeInput) {
memberCodeInput.value = memberCode;
memberCodeInput.dispatchEvent(new Event('input', { bubbles: true }));
console.log('🧾 已填入會員代碼');
}
}

function agreeTerms() {
const agreeCheckbox = document.querySelector('#person_agree_terms');
if (agreeCheckbox && !agreeCheckbox.checked && !agreeCheckbox.disabled) {
agreeCheckbox.click();
console.log('✅ 條款已勾選');
}
}

function continuouslyClickNextButton() {
const nextButton = document.querySelector('.register-new-next-button-area button, .btn.btn-lg.btn-primary');
if (nextButton && !nextButton.disabled && nextButton.offsetParent !== null) {
nextButton.click();
console.log('🔁 點擊下一步');
}
setTimeout(continuouslyClickNextButton, 500);
}

function run() {
if (hasStarted) return;
hasStarted = true;

const ticketBlock = findTargetTicketBlock();
if (!ticketBlock) {
console.log('❌ 找不到符合票價的票種');
return;
}

selectTicket(ticketBlock);

setTimeout(() => {
fillMemberCode();
agreeTerms();
continuouslyClickNextButton();
}, 500);
}

function checkAvailabilityAndRun() {
const ticketBlock = findTargetTicketBlock();
if (ticketBlock && ticketBlock.querySelector('.plus')) {
run();
} else {
console.log('⏳ 尚無票,重新整理中...');
setTimeout(() => {
location.reload();
}, 500);
}
}

setInterval(checkAvailabilityAndRun, 500);

// ⚠️ 自動處理錯誤視窗(票券已售完)
const observer = new MutationObserver(() => {
const modal = document.querySelector('.modal.in, .modal.show');
const modalText = modal?.textContent || '';
const confirmBtn = modal?.querySelector('.btn-primary, .btn, button');

if (
modal &&
confirmBtn &&
confirmBtn.offsetParent !== null &&
modalText.includes('糟糕,有人快您一步')
) {
console.log('⚠️ 偵測到票券售完提示,點選確定');
confirmBtn.click();
}
});

observer.observe(document.body, { childList: true, subtree: true });
})();