// ==UserScript==
// @name auto gpt
// @namespace http://tampermonkey.net/
// @version 1.0.3
// @author PastKing
// @match *://*/c/pay/*
// @match https://buy.stripe.com/*
// @grant GM_addStyle
// @license MIT
// @description 信用卡自动填写工具
// ==/UserScript==
(function () {
'use strict';
console.log('信用卡自动填写脚本已启动');
// ────────── 内置卡信息参数 ──────────
const CARD_INFO = {
email: "[email protected]",
cardNumber: "1234567890",
expiryDate: "11/31",
cvv: "287",
name: "John Doe",
address: "131 Lupine Drive",
city: "Torrington",
postalCode: "82240",
state: "WY"
};
// ────────── 插入样式 ──────────
GM_addStyle(`
/* 一键输入按钮样式 - 深色主题 */
#oneClickBtn {
position: fixed !important;
top: 15px !important;
right: 15px !important;
z-index: 999999 !important;
padding: 12px 20px !important;
border: 2px solid #00ff88 !important;
border-radius: 8px !important;
background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%) !important;
color: #00ff88 !important;
font-weight: 600 !important;
font-size: 14px !important;
font-family: 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif !important;
cursor: pointer !important;
transition: all 0.3s ease !important;
box-shadow:
0 4px 15px rgba(0, 255, 136, 0.3),
inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
text-shadow: 0 0 10px rgba(0, 255, 136, 0.5) !important;
backdrop-filter: blur(10px) !important;
display: block !important;
visibility: visible !important;
opacity: 1 !important;
min-width: 120px !important;
text-align: center !important;
user-select: none !important;
outline: none !important;
transform: translateZ(0) !important;
will-change: transform, box-shadow !important;
}
#oneClickBtn:hover {
background: linear-gradient(135deg, #00ff88 0%, #00cc6a 100%) !important;
color: #000000 !important;
border-color: #00ff88 !important;
transform: translateY(-2px) scale(1.05) !important;
box-shadow:
0 8px 25px rgba(0, 255, 136, 0.4),
0 0 20px rgba(0, 255, 136, 0.6),
inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
text-shadow: none !important;
}
#oneClickBtn:active {
transform: translateY(-1px) scale(1.02) !important;
box-shadow:
0 4px 15px rgba(0, 255, 136, 0.3),
0 0 15px rgba(0, 255, 136, 0.4) !important;
}
/* 响应式设计 */
@media (max-width: 768px) {
#oneClickBtn {
top: 10px !important;
right: 10px !important;
padding: 10px 16px !important;
font-size: 13px !important;
min-width: 100px !important;
}
}
/* 防止被其他样式覆盖 */
#oneClickBtn * {
pointer-events: none !important;
}
`);
// ────────── 状态变量 ──────────
let oneClickBtn = null;
let isCreating = false;
// ────────── 辅助函数 ──────────
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function setNativeValue(element, value) {
if (!element) return;
const valueSetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(element), 'value')?.set;
if (valueSetter) {
valueSetter.call(element, value);
} else {
element.value = value;
}
// 触发各种事件
['input', 'change', 'blur', 'keyup'].forEach(eventType => {
element.dispatchEvent(new Event(eventType, { bubbles: true }));
});
await delay(100);
}
// 新增:专门处理选择器的函数
async function setSelectValue(selectElement, value) {
if (!selectElement || selectElement.tagName !== 'SELECT') return false;
// 检查选项是否存在
const option = selectElement.querySelector(`option[value="${value}"]`);
if (!option) {
console.warn(`⚠️ 选择器中未找到值为 "${value}" 的选项`);
return false;
}
// 设置选中值
selectElement.value = value;
// 触发各种事件
const events = ['change', 'input', 'blur'];
for (const eventType of events) {
selectElement.dispatchEvent(new Event(eventType, { bubbles: true }));
await delay(50);
}
// 验证是否设置成功
const success = selectElement.value === value;
console.log(`${success ? '✅' : '❌'} 选择器设置${success ? '成功' : '失败'}:`, {
element: selectElement.id,
targetValue: value,
actualValue: selectElement.value,
selectedText: selectElement.selectedOptions[0]?.textContent
});
return success;
}
// ────────── 一键输入功能 ──────────
async function oneClickFill() {
console.log('🚀 开始执行一键输入功能');
// 显示加载状态
if (oneClickBtn) {
oneClickBtn.textContent = '填写中...';
oneClickBtn.style.pointerEvents = 'none';
}
try {
// 查找表单元素
const fields = {
email: document.querySelector('input[type="email"]') || document.getElementById('email'),
cardNumber: document.getElementById('cardNumber'),
cardExpiry: document.getElementById('cardExpiry'),
cardCvc: document.getElementById('cardCvc'),
billingName: document.getElementById('billingName'),
billingAddressLine1: document.getElementById('billingAddressLine1'),
billingLocality: document.getElementById('billingLocality'),
billingPostalCode: document.getElementById('billingPostalCode'),
billingAdministrativeArea: document.getElementById('billingAdministrativeArea'),
termsCheckbox: document.getElementById('termsOfServiceConsentCheckbox')
};
console.log('📋 找到的表单字段:', fields);
// 填写邮箱
if (fields.email) {
await setNativeValue(fields.email, CARD_INFO.email);
console.log('✅ 邮箱已填写:', CARD_INFO.email);
}
// 填写卡号
if (fields.cardNumber) {
await setNativeValue(fields.cardNumber, CARD_INFO.cardNumber);
console.log('✅ 卡号已填写:', CARD_INFO.cardNumber);
}
// 填写过期日期
if (fields.cardExpiry) {
await setNativeValue(fields.cardExpiry, CARD_INFO.expiryDate);
console.log('✅ 过期日期已填写:', CARD_INFO.expiryDate);
}
// 填写CVV
if (fields.cardCvc) {
await setNativeValue(fields.cardCvc, CARD_INFO.cvv);
console.log('✅ CVV已填写:', CARD_INFO.cvv);
}
// 填写姓名
if (fields.billingName) {
await setNativeValue(fields.billingName, CARD_INFO.name);
console.log('✅ 姓名已填写:', CARD_INFO.name);
}
// 填写地址
if (fields.billingAddressLine1) {
await setNativeValue(fields.billingAddressLine1, CARD_INFO.address);
console.log('✅ 地址已填写:', CARD_INFO.address);
}
// 填写城市
if (fields.billingLocality) {
await setNativeValue(fields.billingLocality, CARD_INFO.city);
console.log('✅ 城市已填写:', CARD_INFO.city);
}
// 填写邮政编码
if (fields.billingPostalCode) {
await setNativeValue(fields.billingPostalCode, CARD_INFO.postalCode);
console.log('✅ 邮政编码已填写:', CARD_INFO.postalCode);
}
// 填写州/省(特别处理选择器)
if (fields.billingAdministrativeArea) {
const success = await setSelectValue(fields.billingAdministrativeArea, CARD_INFO.state);
if (success) {
console.log('✅ 州/省已选择:', CARD_INFO.state);
} else {
console.error('❌ 州/省选择失败');
}
}
// 勾选服务条款复选框
if (fields.termsCheckbox && !fields.termsCheckbox.checked) {
fields.termsCheckbox.checked = true;
fields.termsCheckbox.dispatchEvent(new Event('change', { bubbles: true }));
console.log('✅ 服务条款复选框已勾选');
}
console.log('🎉 一键输入完成!');
// 恢复按钮状态
if (oneClickBtn) {
oneClickBtn.textContent = '填写完成 ✓';
oneClickBtn.style.background = 'linear-gradient(135deg, #00ff88 0%, #00cc6a 100%)';
oneClickBtn.style.color = '#000000';
setTimeout(() => {
oneClickBtn.textContent = '一键输入';
oneClickBtn.style.background = 'linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%)';
oneClickBtn.style.color = '#00ff88';
oneClickBtn.style.pointerEvents = 'auto';
}, 2000);
}
} catch (error) {
console.error('❌ 一键输入时出错:', error);
if (oneClickBtn) {
oneClickBtn.textContent = '填写出错 ✗';
oneClickBtn.style.background = 'linear-gradient(135deg, #ff4444 0%, #cc0000 100%)';
oneClickBtn.style.color = '#ffffff';
setTimeout(() => {
oneClickBtn.textContent = '一键输入';
oneClickBtn.style.background = 'linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%)';
oneClickBtn.style.color = '#00ff88';
oneClickBtn.style.pointerEvents = 'auto';
}, 3000);
}
}
}
// ────────── 创建按钮 ──────────
function createOneClickButton() {
if (isCreating || oneClickBtn) return;
isCreating = true;
console.log('🔨 正在创建一键输入按钮...');
try {
oneClickBtn = document.createElement('button');
oneClickBtn.id = 'oneClickBtn';
oneClickBtn.textContent = '一键输入';
oneClickBtn.type = 'button';
// 添加到页面最前面
document.documentElement.appendChild(oneClickBtn);
// 绑定点击事件
oneClickBtn.addEventListener('click', oneClickFill);
// 防止事件冒泡
oneClickBtn.addEventListener('mousedown', (e) => e.stopPropagation());
oneClickBtn.addEventListener('mouseup', (e) => e.stopPropagation());
console.log('✅ 一键输入按钮创建成功');
// 验证按钮是否可见
setTimeout(() => {
if (oneClickBtn) {
const rect = oneClickBtn.getBoundingClientRect();
console.log('📍 按钮位置信息:', {
top: rect.top,
right: rect.right,
width: rect.width,
height: rect.height,
visible: rect.width > 0 && rect.height > 0
});
}
}, 500);
} catch (error) {
console.error('❌ 创建按钮失败:', error);
} finally {
isCreating = false;
}
}
// ────────── 监控按钮状态 ──────────
function monitorButton() {
setInterval(() => {
if (!document.getElementById('oneClickBtn')) {
console.log('🔄 检测到按钮丢失,重新创建...');
oneClickBtn = null;
createOneClickButton();
}
}, 3000);
}
// ────────── 初始化 ──────────
function init() {
console.log('🎯 脚本初始化开始...');
// 等待DOM加载完成
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => {
setTimeout(createOneClickButton, 500);
});
} else {
setTimeout(createOneClickButton, 500);
}
// 监控按钮状态
monitorButton();
// 页面完全加载后再次检查
window.addEventListener('load', () => {
setTimeout(() => {
if (!document.getElementById('oneClickBtn')) {
createOneClickButton();
}
}, 1000);
});
console.log('🚀 脚本初始化完成');
}
// 启动脚本
init();
// ────────── 调试功能 ──────────
window.debugAutoFillButton = function() {
const btn = document.getElementById('oneClickBtn');
console.log('🔍 按钮调试信息:');
console.log('- 按钮元素:', btn);
if (btn) {
console.log('- 是否在DOM中:', document.contains(btn));
console.log('- 位置信息:', btn.getBoundingClientRect());
console.log('- 计算样式:', window.getComputedStyle(btn));
console.log('- 父元素:', btn.parentElement);
} else {
console.log('❌ 按钮不存在,尝试重新创建...');
oneClickBtn = null;
createOneClickButton();
}
};
// 新增:调试选择器功能
window.debugSelectElement = function() {
const select = document.getElementById('billingAdministrativeArea');
console.log('🔍 选择器调试信息:');
console.log('- 选择器元素:', select);
if (select) {
console.log('- 当前值:', select.value);
console.log('- 所有选项:', Array.from(select.options).map(opt => ({
value: opt.value,
text: opt.textContent,
selected: opt.selected
})));
console.log('- 是否有WY选项:', !!select.querySelector('option[value="WY"]'));
}
};
console.log('✅ 脚本加载完成!');
console.log('📝 调试命令:');
console.log('- window.debugAutoFillButton() - 调试按钮');
console.log('- window.debugSelectElement() - 调试选择器');
})();