Skip to content

Instantly share code, notes, and snippets.

@eto
Created May 26, 2025 14:51
Show Gist options
  • Save eto/21c6def545299dddf3a1dc1bd0e09bbd to your computer and use it in GitHub Desktop.
Save eto/21c6def545299dddf3a1dc1bd0e09bbd to your computer and use it in GitHub Desktop.
# 大阪万博自動化スクリプト
- とりあえずChatGPTに書かせてみたんだけど、うまく動いてない。
// ==UserScript==
// @name Expo2025 Auto Clicker – Debug
// @namespace http://tampermonkey.net/
// @version 2025-05-25
// @description 「もっと見る」と「一番上の予約枠+申込」自動化(詳細ログ付き)
// @match https://ticket.expo2025.or.jp/*
// @run-at document-idle
// ==/UserScript==
(() => {
'use strict';
/* ---- 共通ログ関数 ---- */
const log = (...msg) => console.log('[ExpoAuto]', ...msg);
log('ユーザースクリプト読み込み完了', new Date().toLocaleTimeString());
/* ===================================================
1) もっと見るボタン自動クリック
===================================================*/
const clickMoreBtn = () => {
const btns = Array.from(
document.querySelectorAll('button.style_more_btn__ymb22')
);
btns.forEach((btn, idx) => {
const disabled =
btn.disabled || btn.classList.contains('style_more_btn_deactive__jsP8I');
if (!disabled) {
log(`もっと見る(${idx}) をクリック`);
btn.click();
}
});
};
/* 0.3 秒ごと + DOM 変化時の二重監視で確実に押す */
setInterval(clickMoreBtn, 300);
new MutationObserver(clickMoreBtn).observe(document.body, {
childList: true,
subtree: true
});
/* ===================================================
2) ラジオボタン選択 & 申込ボタン自動クリック
===================================================*/
const state = {
radioSelected: false,
radioValue: null,
submitClicked: false
};
/* 一番上の有効ラジオを選択 */
const selectFirstRadio = () => {
if (state.radioSelected) return;
const radios = Array.from(
document.querySelectorAll(
'input[type="radio"][name="date_picker"]:not([disabled])'
)
);
if (!radios.length) return;
const first = radios[0];
if (!first.checked) {
/* click() で “ユーザー操作に近い” イベント列を発生させる */
first.click();
log('ラジオ選択:', first.value);
} else {
log('ラジオは既に選択済み:', first.value);
}
state.radioSelected = true;
state.radioValue = first.value;
};
/* 申込ボタンが有効化された瞬間を捕捉してクリック */
const trySubmit = () => {
if (!state.radioSelected || state.submitClicked) return;
const btn = document.querySelector('button.style_reservation_next_link__7gOxy');
if (!btn) return;
if (btn.disabled) {
/* まだ無効 */
return;
}
log('申込ボタンをクリック');
btn.click();
state.submitClicked = true;
};
/* 定期監視 */
setInterval(() => {
selectFirstRadio();
trySubmit();
}, 400);
/* MutationObserver で “disabled 解除” を検知 */
const submitObserver = new MutationObserver(trySubmit);
submitObserver.observe(document.body, {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ['disabled']
});
/* ページ初期表示でも即試行 */
selectFirstRadio();
trySubmit();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment