// ==UserScript==
// @name 逆战抢领助手
// @namespace https://nz.qq.com/
// @version 1.3
// @description 逆战道具一键抢领
// @author 逆战-牢鹊
// @match https://nz.qq.com/cp/a20251120pvphf/*
// @grant GM_log
// @grant GM_addStyle
// @run-at document-end
// @icon https://nz.qq.com/favicon.ico
// @license MIT
// @unwrap
// ==/UserScript==
(() => {
'use strict';
GM_addStyle(`
#speed-helper-box {
position: fixed;top: 50px;right: 20px;z-index: 99999999; /* 仅修改这行:left→right */
width: 320px;background: #fff;border: 1px solid #e6394633;border-radius: 20px;
box-shadow: 0 12px 36px rgba(0,0,0,0.15);font-family: '微软雅黑';
}
#speed-helper-header {
background: linear-gradient(90deg, #e63946, #ff6b6b);color: #fff;
padding: 16px 20px;border-top-left-radius: 20px;border-top-right-radius: 20px;
font-size: 16px;font-weight: bold;
}
#speed-helper-body {
padding: 20px;
}
.time-display {
font-family: monospace;padding: 12px;margin: 10px 0;
background: #e639460d;border: 1px solid #e6394633;border-radius: 10px;
font-size: 15px;color: #e63946;text-align: center;
}
.input-label {
display: block;margin: 8px 0 4px 0;font-size: 14px;color: #333;
}
.speed-helper-input {
width: 100%;padding: 10px 12px;margin: 4px 0 8px 0;
border: 1px solid #e6394633;border-radius: 8px;box-sizing: border-box;
font-size: 14px;
}
.speed-helper-input::placeholder {
color: #999;
}
.prop-name-text {
width: 100%;padding: 10px 12px;margin: 4px 0 8px 0;
border: 1px solid #e6394633;border-radius: 8px;box-sizing: border-box;
font-size: 14px;background: #f9f9f9;color: #333;
}
.countdown {
text-align: center;font-size: 22px;font-weight: bold;
color: #e63946;margin: 15px 0;padding: 10px;
border: 1px solid #e6394633;border-radius: 10px;
}
.speed-helper-actions {
display: flex;gap: 10px;margin-top: 15px;
}
.speed-helper-btn {
flex: 1;padding: 12px;border: none;border-radius: 10px;
cursor: pointer;font-size: 15px;font-weight: 600;
transition: all 0.3s;
}
.btn-start {background: #e63946;color: white;}
.btn-start:hover {background: #d62828;}
.btn-stop {background: #457b9d;color: white;}
.btn-stop:hover {background: #1d3557;}
.btn-get-time {
width: 100%;background: #f8f9fa;color: #e63946;
border: 1px solid #e6394633;margin: 5px 0 10px 0;
}
.speed-helper-toast {
position: fixed;bottom: 30px;left: 50%;transform: translateX(-50%);
background: rgba(0,0,0,0.8);color: white;padding: 10px 20px;
border-radius: 8px;z-index: 99999999;font-size: 14px;
animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
from {transform: translate(-50%, 20px);opacity: 0;}
to {transform: translate(-50%, 0);opacity: 1;}
}
`);
class SpeedHelper {
constructor() {
this.isRunning = false;
this.countdownTimer = null;
this.convertTimer = null;
this.convertFunction = () => part1_2_limitConvert(1);
this.execTimes = 20;
this.propName = '10000NZ购物券(3天)';
}
init() {
const box = document.createElement('div');
box.id = 'speed-helper-box';
box.innerHTML = `
当前时间:--:--:--.---
${this.propName}
等待开始...
`;
document.body.appendChild(box);
this.bindEvents();
this.updateRealTime();
}
bindEvents() {
document.getElementById('get-time').addEventListener('click', () => {
const now = new Date();
const timeStr = this.formatTime(now);
document.getElementById('target-time').value = timeStr;
this.toast(`已导入当前时间:${timeStr}`);
});
document.getElementById('start').addEventListener('click', () => this.start());
document.getElementById('stop').addEventListener('click', () => this.stop());
}
updateRealTime() {
setInterval(() => {
const timeStr = this.formatTime(new Date());
document.getElementById('real-time').textContent = `当前时间:${timeStr}`;
}, 10);
}
formatTime(date) {
return [
String(date.getHours()).padStart(2, '0'),
String(date.getMinutes()).padStart(2, '0'),
String(date.getSeconds()).padStart(2, '0')
].join(':') + `.${String(date.getMilliseconds()).padStart(3, '0')}`;
}
parseTargetTime(timeStr) {
try {
const [hms, ms] = timeStr.split('.');
const [h, m, s] = hms.split(':').map(Number);
const now = new Date();
const target = new Date(now.getFullYear(), now.getMonth(), now.getDate(), h, m, s, ms || 0);
return target.getTime();
} catch (e) {
return null;
}
}
start() {
if (this.isRunning) return;
const targetTimeStr = document.getElementById('target-time').value.trim();
if (!targetTimeStr) {
this.toast('请填写目标时间!');
return;
}
const targetTime = this.parseTargetTime(targetTimeStr);
if (!targetTime) {
this.toast('时间格式错误!请按 HH:MM:SS.ms 填写');
return;
}
const nowTime = Date.now();
if (targetTime <= nowTime) {
this.toast('目标时间不能小于当前时间,请重新输入!');
return;
}
this.isRunning = true;
document.getElementById('start').disabled = true;
document.getElementById('stop').disabled = false;
this.countdownTimer = setInterval(() => {
const now = Date.now();
const remaining = targetTime - now;
if (remaining <= 0) {
clearInterval(this.countdownTimer);
document.getElementById('countdown').textContent = `开始抢购【${this.propName}】!`;
this.runConvert();
return;
}
const sec = Math.floor(remaining / 1000);
document.getElementById('countdown').textContent = `剩余:${sec} 秒`;
}, 10);
this.toast(`已启动抢购【${this.propName}】,等待目标时间...`);
}
runConvert() {
let current = 0;
const interval = Math.max(10, Math.floor(1000 / this.execTimes));
this.convertTimer = setInterval(() => {
if (current >= this.execTimes) {
clearInterval(this.convertTimer);
document.getElementById('countdown').textContent = `【${this.propName}】抢购完成!`;
this.toast(`【${this.propName}】抢购完成!`);
this.stop();
return;
}
try {
this.convertFunction();
current++;
document.getElementById('countdown').textContent = `抢购【${this.propName}】中...`;
GM_log(`第${current}次抢购【${this.propName}】成功`);
const originalFetch = window.fetch;
window.fetch = function(url, options) {
return originalFetch.apply(this, arguments).then(res => {
if (url.includes('comm.ams.game.qq.com/ams/ame/amsvr')) {
res.clone().json().then(data => {
if (data.iRet === '0') {
this.toast(`🎉 【${this.propName}】抢购成功!`);
this.stop();
} else if (current === 1) {
this.toast(`❌ 【${this.propName}】抢购失败:${data.sMsg || '未知错误'}`);
}
});
}
return res;
});
}.bind(this);
} catch (e) {
clearInterval(this.convertTimer);
document.getElementById('countdown').textContent = `【${this.propName}】抢购失败:${e.message}`;
this.toast(`【${this.propName}】抢购失败:${e.message}`);
this.stop();
}
}, interval);
}
stop() {
this.isRunning = false;
clearInterval(this.countdownTimer);
clearInterval(this.convertTimer);
const today = new Date();
const dateStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
document.getElementById('countdown').textContent = `今日日期:${dateStr}`;
document.getElementById('start').disabled = false;
document.getElementById('stop').disabled = true;
}
toast(msg) {
const oldToast = document.querySelector('.speed-helper-toast');
if (oldToast) oldToast.remove();
const toast = document.createElement('div');
toast.className = 'speed-helper-toast';
toast.textContent = msg;
document.body.appendChild(toast);
setTimeout(() => toast.remove(), 3000);
}
}
window.addEventListener('load', () => {
setTimeout(() => new SpeedHelper().init(), 1000);
});
})();