Created
December 19, 2025 14:35
-
-
Save benleb/df13787a1f5d3a92e1dd94c5ddfa6c4e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // --- Configuration --- | |
| const CHECK_INTERVAL_MS = 3337; // Check every 2 seconds | |
| function checkForTicket() { | |
| console.log(`[${new Date().toLocaleTimeString()}] π Checking for tickets in background...`); | |
| // Fetch the current page content in the background | |
| fetch(window.location.href) | |
| .then(response => response.text()) | |
| .then(html => { | |
| // We use Regex instead of DOMParser to avoid Content Security Policy (CSP) errors | |
| // The site blocks inline styles which DOMParser might trigger when parsing the full HTML | |
| // 1. Check if we have a "Buy" button indicator | |
| // Looking for the specific button class and text "Buy" | |
| const hasBuyButton = html.includes('btn-success') && html.includes('Buy'); | |
| if (hasBuyButton) { | |
| // 2. Extract the form action URL | |
| // We look for an action URL that contains '/buy/' | |
| const actionMatch = html.match(/action="([^"]*\/buy\/[^"]*)"/); | |
| // 3. Extract the CSRF token | |
| const csrfMatch = html.match(/name="csrfmiddlewaretoken" value="([^"]+)"/); | |
| if (actionMatch && csrfMatch) { | |
| console.log("!!! π« TICKET FOUND !!! Attempting to buy..."); | |
| const action = actionMatch[1]; | |
| const csrfToken = csrfMatch[1]; | |
| // Create a form in the current page to submit | |
| const submitForm = document.createElement('form'); | |
| submitForm.method = 'POST'; | |
| submitForm.action = action; | |
| // NOTE: We do NOT set style.display = 'none' here because it violates the site's CSP. | |
| // The form is appended and submitted immediately, so it won't be visible for long. | |
| const tokenField = document.createElement('input'); | |
| tokenField.type = 'hidden'; | |
| tokenField.name = 'csrfmiddlewaretoken'; | |
| tokenField.value = csrfToken; | |
| submitForm.appendChild(tokenField); | |
| document.body.appendChild(submitForm); | |
| console.log("π Submitting buy request..."); | |
| submitForm.submit(); | |
| // Stop the loop | |
| return; | |
| } else { | |
| // Found indicators but couldn't extract exact details. | |
| // This might happen if the HTML structure is slightly different than expected. | |
| console.warn("β οΈ Found 'Buy' button indicators but couldn't extract form details. Retrying..."); | |
| setTimeout(checkForTicket, CHECK_INTERVAL_MS); | |
| } | |
| } else { | |
| // No ticket found, schedule next check | |
| setTimeout(checkForTicket, CHECK_INTERVAL_MS); | |
| } | |
| }) | |
| .catch(err => { | |
| console.error("β Error fetching page:", err); | |
| // Retry even on error | |
| setTimeout(checkForTicket, CHECK_INTERVAL_MS); | |
| }); | |
| } | |
| // Start the process | |
| console.log("π Ticket Auto-Buyer started! Keep this tab open."); | |
| checkForTicket(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment