Spawn request failed: 419 { "message": "CSRF token mismatch." } // ==UserScript== //…
- User
Spawn request failed: 419 { "message": "CSRF token mismatch." }
// ==UserScript== // @name Agar-ar Spawn Button // @namespace http://tampermonkey.net/ // @version 0.4 // @description Adds a spawn button with a shortcut key 'E' on agar-ar.com // @match https://agar-ar.com/* // @grant none // ==/UserScript==
(function() { 'use strict';
window.addEventListener('load', function() { const spawnButton = document.createElement("button"); spawnButton.innerText = "Spawn"; spawnButton.style.position = "relative"; spawnButton.style.margin = "20px auto"; spawnButton.style.display = "block"; spawnButton.style.backgroundColor = "#ff0000"; spawnButton.style.color = "#ffffff"; spawnButton.style.border = "none"; spawnButton.style.borderRadius = "5px"; spawnButton.style.fontSize = "16px";
const mainElement = document.getElementById("main"); if (mainElement) { mainElement.appendChild(spawnButton); } else { console.error("Element with id 'main' not found."); } // دالة للحصول على CSRF Token من الكوكيز const getCsrfToken = () => { return document.cookie .split('; ') .find(row => row.startsWith('XSRF-TOKEN=')) ?.split('=')[1]; }; // دالة إرسال طلب Spawn const sendSpawnRequest = async () => { const csrfToken = getCsrfToken(); if (!csrfToken) { console.error("CSRF Token not found."); return; // إذا لم يتم العثور على التوكن، لا تستمر } try { const response = await fetch("https://agar-ar.com/api/spawn", { method: "POST", headers: { "Content-Type": "application/json", "x-requested-with": "XMLHttpRequest", "x-xsrf-token": csrfToken, // استخدام CSRF Token المحدد }, body: JSON.stringify({}) }); if (response.ok) { console.log("Spawn request sent successfully!"); } else { const errorData = await response.text(); console.log("Spawn request failed:", response.status, errorData); } } catch (error) { console.error("Error sending spawn request:", error); } }; spawnButton.addEventListener("click", sendSpawnRequest); document.addEventListener("keydown", (event) => { if (event.key.toLowerCase() === 'e') { sendSpawnRequest(); } });});
})();
- Assistant
- User
الكود كامل
- Assistant