// ==UserScript== // @name AKG 批量采集工具(带action=grab + resource_id 1-6自选) // @namespace http://tampermonkey.net/ // @version 3.0 // @description 自动捕获环境 + 带action=grab + 自选资源ID + 极速批量请求 // @match https://718zf.xyz/akg_miner.php // @grant GM_xmlhttpRequest // @run-at document-start // ==/UserScript== (function() { 'use strict'; // 全局保存请求环境 let SAVED = { url: '', method: '', headers: {}, hasData: false }; let isListening = true; // ============================ // 劫持 XHR 捕获真实请求 // ============================ const origOpen = XMLHttpRequest.prototype.open; const origSend = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.open = function(method, url) { if (url.includes('akg_api.php') && isListening && !SAVED.hasData) { this._url = url; this._method = method; this._headers = {}; const self = this; this.setRequestHeader = function(k, v) { self._headers[k] = v; XMLHttpRequest.prototype.setRequestHeader.call(this, k, v); }; } origOpen.apply(this, arguments); }; XMLHttpRequest.prototype.send = function(body) { if (this._url?.includes('akg_api.php') && isListening && !SAVED.hasData) { // 保存环境 SAVED.url = this._url; SAVED.method = this._method; SAVED.headers = this._headers; SAVED.hasData = true; setTimeout(createPanel, 300); } origSend.apply(this, arguments); }; // ============================ // 控制面板 // ============================ function createPanel() { if (document.getElementById('akgPanel')) return; const p = document.createElement('div'); p.id = 'akgPanel'; p.style.cssText = ` position:fixed;top:30px;right:30px;width:300px; background:#121212;color:#fff;padding:16px;border-radius:12px; z-index:999999;font-size:14px;box-shadow:0 0 12px #0005 `; p.innerHTML = `
⚡ AKG 极速采集
资源 ID (1-6)
请求次数
`; document.body.appendChild(p); document.getElementById('start').onclick = () => { const id = document.getElementById('rid').value; const count = parseInt(document.getElementById('total').value) || 1; start(id, count); }; } // ============================ // 核心:带 action=grab 发送 // ============================ function start(resource_id, total) { if (!SAVED.hasData) { document.getElementById('log').innerText = "❌ 请先手动采集一次"; return; } isListening = false; const log = document.getElementById('log'); log.innerText = "⏳ 发送中..."; // ✅ 固定带上 action=grab + 自选的 resource_id const postData = `action=grab&resource_id=${resource_id}`; let success = 0; for (let i = 0; i < total; i++) { GM_xmlhttpRequest({ method: SAVED.method, url: SAVED.url, headers: SAVED.headers, data: postData, timeout: 150, onload: () => {}, onerror: () => {} }); } setTimeout(() => { log.innerText = `✅ 完成 ${total} 次请求`; isListening = true; }, 600); } })();