Skip to content

Instantly share code, notes, and snippets.

@Last-Order
Last active June 21, 2018 12:10
Show Gist options
  • Save Last-Order/f04dbfdf454c8a4a8c6c1e6c8312b164 to your computer and use it in GitHub Desktop.
Save Last-Order/f04dbfdf454c8a4a8c6c1e6c8312b164 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name New Script
// @namespace Violentmonkey Scripts
// @match https://show.bilibili.com/platform/checkSeat.html?*
// @grant none
// ==/UserScript==
//
//
(async () => {
const open = XMLHttpRequest.prototype.open;
const nextTick = () => new Promise(resolve => setTimeout(resolve, 0));
const target = 2;
const submit = async () => {
if ($('.finish-btn').length === 0) {
await nextTick();
} else {
$('.finish-btn').click();
}
}
XMLHttpRequest.prototype.open = function () {
this.addEventListener('load', async function () {
if (this.readyState === 4 && this.responseURL.startsWith('https://show.bilibili.com/api/ticket/area/seat')) {
let counter = 0;
const seats = [];
$('.seats').find('li').each(function () {
if (!$(this).hasClass('unavailable') && !$(this).hasClass('selected') && seats.length < target) {
seats.push($(this).attr('id'));
}
});
for (const seat of seats) {
$('#' + seat).click();
await nextTick();
}
submit();
}
});
open.apply(this, arguments);
};
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment