// ==UserScript== // @name auto-exchange-invite // @namespace http://tampermonkey.net/ // @version 1.0.0 // @copyright 2025-06-05 // @description:en Auto exchange pt invites when cost only 1,000 bonus in a random time 15s-60s. // @description:zh-CN 当邀请码价格为 1,000 魔力值的时候,随机等待 15s-60s 后自动交换。 // @author missingmeow // @match *://www.ptskit.com/mybonus.php* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 定义等待函数 var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); // 获取随机数 function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min)) + min; } // 交换邀请名额 function exchangeInvite() { try { const td = document.querySelector('td[id="outer"]'); if (!td) throw new Error('td not found'); const table = td.querySelector('table'); if (!table) throw new Error('table not found'); const rows = table.querySelectorAll('tr'); const targetRow = Array.from(rows).find(tr => { // 检查是否包含指定的
const form = tr.querySelector('form[action="?action=exchange"][method="post"]') !== null; if (!form) return false; const tds = tr.querySelectorAll('td'); const is1000 = Array.from(tds).find(td => { return td.textContent === '1,000'; }); if (!is1000) return false; const hasInviteText = Array.from(tds).some(td => { return td.textContent.includes('1个邀请名额') && ! tr.textContent.includes('临时'); }); return hasInviteText; }); if (!targetRow) throw new Error('Target row not found'); const submitBtn = targetRow.querySelector('input[type="submit"]'); if (!submitBtn) throw new Error('Submit button not found'); console.log('准备交换邀请名额...'); submitBtn.click(); } catch (error) { console.error('操作失败:', error.message); } } const sec = getRandomInt(15000, 60000); console.log('倒计时 %d 秒后开始交换邀请名额...', sec/1000); wait(sec).then(() => { exchangeInvite(); }); })();