// ==UserScript== // @name pokemon_cafe_script // @namespace https://git.moonjuice.tw/moonjuice/pokemon_script // @version 2024-06-28 // @description try to take over the world! // @author moonjuice // @match https://reserve.pokemon-cafe.jp/* // @match https://osaka.pokemon-cafe.jp/* // @match file:///* // @icon https://reserve.pokemon-cafe.jp/assets/favicon-fa237093863d556ccbcc35094a79472be555cd11f4a1a7e16dc7a0a5cd71675c.ico // @grant GM_setValue // @grant GM_getValue // @run-at document-end // @downloadURL https://git.moonjuice.tw/moonjuice/pokemon_script/raw/branch/main/pokemon_cafe.js // @updateURL https://git.moonjuice.tw/moonjuice/pokemon_script/raw/branch/main/pokemon_cafe.js // ==/UserScript== (function() { 'use strict'; const guest = 4; // Your code here... /*if ($('.button.arrow-down') != null && $('.button.arrow-down').length != 0) { if (Array.isArray($('.button.arrow-down'))) { if ($('.button.arrow-down')[0].text.includes('Reloading')) { $('.button.arrow-down')[0].click(); } } else { if ($('.button.arrow-down').text.length != 1 && $('.button.arrow-down').text.includes('Reloading')) { $('.button.arrow-down').click(); } } }*/ if (document.getElementsByClassName('button arrow-down').length == 1) { if (document.getElementsByClassName('button arrow-down')[0].text.includes('Reloading')) { document.getElementsByClassName('button arrow-down')[0].click(); } } if('/' == location.pathname) { $('#agreeChecked')[0].click(); $('.button-container-agree > button')[0].click(); } else if ('/reserve/auth_confirm' == location.pathname) { $('.button.arrow-down')[0].click(); //location.href = 'https://reserve.pokemon-cafe.jp/reserve/step1'; } else if ('/reserve/step1' == location.pathname) { if ($('select')[0].value == 0) { $('select')[0].options[guest].selected = true; $('select')[0].onchange(); } else { let dt = new Date(); dt.setDate(dt.getDate() + 31); //dt.setMonth(2); //dt.setDate(1); dt.setHours(17); dt.setMinutes(0); $('input[name=date]')[0].value = dt; $('input[name=commit]')[0].click(); } } else if ('/reserve/step2' == location.pathname) { const seatId = chooseSeat(); if (seatId != -1) { $('input[name=seat_id]')[0].value = seatId; $('input[name=guest]')[0].value = guest; $('#hidden-form')[0].submit(); } else { console.log('no seat'); $('.button.button-secondary')[0].click(); } } else if ('/reserve/step3' == location.pathname) { $('input[id=name]')[0].value='name'; $('input[id=name_kana]')[0].value='name'; $('input[id=phone_number]')[0].value='phone'; $('input[id=email]')[0].value='email'; } else { /*if (GM_getValue('seatId') != -1) { alert('快!!'); }*/ console.log(GM_getValue('seat')); console.log(GM_getValue('seatId')); } })(); function chooseSeat() { var seatId = -1; if ($('.post-link').length && $('.post-link').length > 0) { var c_seats = Array.from($('.post-link')).filter((element) => element.text.includes('C')); var d_seats = Array.from($('.post-link')).filter((element) => element.text.includes('D')); var a_seats = Array.from($('.post-link')).filter((element) => element.text.includes('A')); if (location.hostname.startsWith('reserve')) { // tokyo => c seat first var seats_1450 = Array.from($('.post-link')).filter((element) => element.text.includes('14:50')); /*if (seats_1450.length > 0) { GM_setValue('seat', seats_1450[0].text); seatId = seats_1450[0].getAttribute('data-seat-id'); } else*/ if (c_seats.length > 0) { GM_setValue('seat', c_seats[0].text); seatId = c_seats[0].getAttribute('data-seat-id'); } else if (d_seats.length > 0) { GM_setValue('seat', d_seats[0].text); seatId = d_seats[0].getAttribute('data-seat-id'); } else if (a_seats.length > 0) { GM_setValue('seat', a_seats[0].text); seatId = a_seats[0].getAttribute('data-seat-id'); } else { GM_setValue('seat', $('.post-link')[0].text); seatId = $('.post-link')[0].getAttribute('data-seat-id'); } } else { // osaka => A seat first //var seats_1350 = Array.from($('.post-link')).filter((element) => element.text.includes('13:50')); /*if (seats_1350.length > 0) { GM_setValue('seat', seats_1350[0].text); seatId = seats_1350[0].getAttribute('data-seat-id'); } else*/ if (a_seats.length > 0) { GM_setValue('seat', a_seats[0].text); seatId = a_seats[0].getAttribute('data-seat-id'); } else { GM_setValue('seat', $('.post-link')[0].text); seatId = $('.post-link')[0].getAttribute('data-seat-id'); } } } GM_setValue('seatId', seatId); return seatId; }