From eae1847ac5f798b5e32388152631ca6a8ad46a3c Mon Sep 17 00:00:00 2001 From: moonjuice Date: Thu, 7 Mar 2024 07:29:24 +0000 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20pokemon=5Fcafe.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pokemon_cafe.js | 57 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 20 deletions(-) diff --git a/pokemon_cafe.js b/pokemon_cafe.js index 22d8c0d..6e1522f 100644 --- a/pokemon_cafe.js +++ b/pokemon_cafe.js @@ -1,16 +1,18 @@ // ==UserScript== -// @name pokemon -// @namespace http://tampermonkey.net/ -// @version 2024-01-25 +// @name pokemon_cafe_script +// @namespace https://git.moonjuice.tw/moonjuice/pokemon_script +// @version 2024-03-07 // @description try to take over the world! -// @author You +// @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 +// @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() { @@ -75,28 +77,43 @@ function chooseSeat() { var seatId = -1; + GM_setValue('seat', '0'); + GM_setValue('seatId', seatId); if ($('.post-link').length && $('.post-link').length > 0) { - //var seats_1450 = Array.from($('.post-link')).filter((element) => element.text.includes('14:50')); 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 (seats_1450.length > 0) { + 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*/ 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; } \ No newline at end of file