更新 pokemon_cafe.js

This commit is contained in:
2024-03-07 07:29:24 +00:00
parent c588533656
commit eae1847ac5

View File

@@ -1,16 +1,18 @@
// ==UserScript== // ==UserScript==
// @name pokemon // @name pokemon_cafe_script
// @namespace http://tampermonkey.net/ // @namespace https://git.moonjuice.tw/moonjuice/pokemon_script
// @version 2024-01-25 // @version 2024-03-07
// @description try to take over the world! // @description try to take over the world!
// @author You // @author moonjuice
// @match https://reserve.pokemon-cafe.jp/* // @match https://reserve.pokemon-cafe.jp/*
// @match https://osaka.pokemon-cafe.jp/* // @match https://osaka.pokemon-cafe.jp/*
// @match file:///* // @match file:///*
// @icon https://reserve.pokemon-cafe.jp/assets/favicon-fa237093863d556ccbcc35094a79472be555cd11f4a1a7e16dc7a0a5cd71675c.ico // @icon https://reserve.pokemon-cafe.jp/assets/favicon-fa237093863d556ccbcc35094a79472be555cd11f4a1a7e16dc7a0a5cd71675c.ico
// @grant GM_setValue // @grant GM_setValue
// @grant GM_getValue // @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== // ==/UserScript==
(function() { (function() {
@@ -75,28 +77,43 @@
function chooseSeat() { function chooseSeat() {
var seatId = -1; var seatId = -1;
GM_setValue('seat', '0');
GM_setValue('seatId', seatId);
if ($('.post-link').length && $('.post-link').length > 0) { 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 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 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')); 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); GM_setValue('seat', seats_1450[0].text);
seatId = seats_1450[0].getAttribute('data-seat-id'); seatId = seats_1450[0].getAttribute('data-seat-id');
} else*/ if (c_seats.length > 0) { } else*/ if (c_seats.length > 0) {
GM_setValue('seat', c_seats[0].text); GM_setValue('seat', c_seats[0].text);
seatId = c_seats[0].getAttribute('data-seat-id'); seatId = c_seats[0].getAttribute('data-seat-id');
} else if (d_seats.length > 0) { } else if (d_seats.length > 0) {
GM_setValue('seat', d_seats[0].text); GM_setValue('seat', d_seats[0].text);
seatId = d_seats[0].getAttribute('data-seat-id'); seatId = d_seats[0].getAttribute('data-seat-id');
} else if (a_seats.length > 0) { } else if (a_seats.length > 0) {
GM_setValue('seat', a_seats[0].text); GM_setValue('seat', a_seats[0].text);
seatId = a_seats[0].getAttribute('data-seat-id'); seatId = a_seats[0].getAttribute('data-seat-id');
} else { } else {
GM_setValue('seat', $('.post-link')[0].text); GM_setValue('seat', $('.post-link')[0].text);
seatId = $('.post-link')[0].getAttribute('data-seat-id'); 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; return seatId;
} }