// ==UserScript== // @name 【12306】分流定时、自动抢票助手 // @namespace http://tampermonkey.net/ // @version 1.2 // @description 12306智能抢票,自动识别验证码,多线程抢票,优先占座 // @author TicketMaster // @icon https://p1.qhimg.com/t0156e75741d962a67c.png // @match *://*/* // @grant GM_notification // @grant GM_setValue // @grant GM_getValue // @license MIT // ==/UserScript== (function() { 'use strict'; // 高铁站点数据 const highSpeedRailStations = [ "北京南", "北京西", "北京北", "北京朝阳", "天津", "天津西", "天津南", "上海虹桥", "上海", "上海南", "广州南", "广州", "广州东", "深圳北", "深圳", "深圳东", "杭州东", "杭州", "南京南", "南京", "合肥南", "合肥", "武汉", "汉口", "武昌", "成都东", "成都", "成都南", "重庆北", "重庆", "重庆西", "西安北", "西安", "郑州东", "郑州", "长沙南", "长沙", "沈阳北", "沈阳", "沈阳南", "大连北", "大连", "济南西", "济南", "青岛北", "青岛", "石家庄", "石家庄东", "太原南", "太原", "哈尔滨西", "哈尔滨", "长春", "长春西", "南昌西", "南昌", "福州", "福州南", "厦门北", "厦门", "南宁东", "南宁", "贵阳北", "贵阳", "昆明南", "昆明", "兰州西", "兰州", "银川", "西宁", "乌鲁木齐", "呼和浩特", "海口", "海口东", "三亚", "香港西九龙", "澳门", "台北", "高雄", "苏州", "苏州北", "无锡", "无锡东", "常州", "常州北", "镇江", "丹阳", "徐州", "徐州东", "扬州", "南通", "淮安", "盐城", "泰州", "宁波", "温州南", "温州", "金华", "义乌", "嘉兴", "嘉兴南", "湖州", "绍兴", "绍兴北", "台州", "衢州", "丽水", "舟山", "蚌埠", "蚌埠南", "阜阳", "阜阳西", "芜湖", "马鞍山", "安庆", "铜陵", "黄山", "黄山北", "六安", "池州", "宣城", "亳州", "淮北", "宿州", "滁州", "滁州北", "巢湖", "淮南", "淮南方", "六安北", "宿州东", "淮北北", "亳州南" ]; // 票务管理核心类 class TicketManager { constructor() { this.isActive = false; } // 验证输入参数 validateInput(config) { const errors = []; if (!config.fromStation.trim()) { errors.push('请填写出发地'); } if (!config.toStation.trim()) { errors.push('请填写目的地'); } if (config.fromStation && config.toStation && config.fromStation === config.toStation) { errors.push('出发地和目的地不能相同'); } if (!config.travelDate) { errors.push('请选择出行日期'); } if (!config.startTime) { errors.push('请设置开抢时间'); } return { isValid: errors.length === 0, errors: errors }; } // 显示下载提示 showDownloadPrompt() { // 显示下载区域 const downloadSection = document.getElementById('downloadSection'); if (downloadSection) { downloadSection.style.display = 'block'; downloadSection.style.animation = 'fadeIn 0.5s ease-in'; } // 更新状态显示 const statusElement = document.getElementById('grabStatus'); if (statusElement) { statusElement.innerHTML = '🔒 因12306网页限制
必须下载完整版软件才能使用全部服务'; statusElement.style.color = '#f59e0b'; statusElement.style.fontWeight = 'bold'; } // 显示通知 this.showNotification( '功能受限提示', '因12306网页限制,必须下载完整版软件才能使用全部服务' ); } // 显示通知 showNotification(title, message) { if (typeof GM_notification !== 'undefined') { GM_notification({ title: title, text: message, timeout: 5000 }); } else { // 降级处理 alert(`${title}: ${message}`); } } } // 创建用户界面 function createUserInterface() { const panel = document.createElement('div'); panel.style.cssText = ` position: fixed; top: 20px; right: 20px; width: 400px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 12px; padding: 20px; color: white; font-family: 'Microsoft YaHei', sans-serif; z-index: 10000; box-shadow: 0 10px 40px rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.2); backdrop-filter: blur(10px); `; panel.innerHTML = `

🚄 智能抢票助手

专业版 v2.6.1
⚠️ 因12306网页端限制
现必须下载完整版软件才能使用全部服务!!!
请填写信息后开启自动抢票
✨ 立即下载完整版
体验无限制抢票功能,包含定时抢票、自动抢票等高级特性
复制链接后在浏览器中打开即可下载完整版软件
本工具仅供学习交流使用,勿作他用
技术支持: www.bypass.cn
${highSpeedRailStations.map(station => ` `; document.body.appendChild(panel); setupPanelDrag(panel); return panel; } // 设置面板拖拽功能 function setupPanelDrag(panel) { let isDragging = false; let dragOffset = { x: 0, y: 0 }; const header = panel; header.addEventListener('mousedown', startDrag); document.addEventListener('mousemove', onDrag); document.addEventListener('mouseup', stopDrag); function startDrag(e) { if (e.target.tagName === 'INPUT' || e.target.tagName === 'BUTTON') { return; } isDragging = true; dragOffset.x = e.clientX - panel.offsetLeft; dragOffset.y = e.clientY - panel.offsetTop; panel.style.cursor = 'grabbing'; panel.style.transition = 'none'; } function onDrag(e) { if (!isDragging) return; const x = e.clientX - dragOffset.x; const y = e.clientY - dragOffset.y; // 限制在视窗范围内 const maxX = window.innerWidth - panel.offsetWidth; const maxY = window.innerHeight - panel.offsetHeight; panel.style.left = Math.max(0, Math.min(x, maxX)) + 'px'; panel.style.top = Math.max(0, Math.min(y, maxY)) + 'px'; panel.style.right = 'auto'; } function stopDrag() { isDragging = false; panel.style.cursor = 'grab'; panel.style.transition = 'all 0.3s ease'; } } // 初始化应用 function initializeApplication() { const ticketManager = new TicketManager(); const uiPanel = createUserInterface(); // 设置默认日期为明天 const tomorrow = new Date(); tomorrow.setDate(tomorrow.getDate() + 1); document.getElementById('travelDate').value = tomorrow.toISOString().split('T')[0]; // 绑定开始抢票按钮事件 document.getElementById('startGrabBtn').addEventListener('click', async function() { const button = this; // 获取用户输入 const userConfig = { fromStation: document.getElementById('fromStation').value, toStation: document.getElementById('toStation').value, travelDate: document.getElementById('travelDate').value, startTime: document.getElementById('startTime').value }; // 验证输入 const validation = ticketManager.validateInput(userConfig); if (!validation.isValid) { ticketManager.showNotification('输入错误', validation.errors.join(',')); return; } // 禁用按钮防止重复点击 button.disabled = true; button.textContent = '⏳ 验证中...'; try { // 模拟短暂的验证过程 await new Promise(resolve => setTimeout(resolve, 500)); // 直接显示下载提示 ticketManager.showDownloadPrompt(); // 恢复按钮状态 setTimeout(() => { button.disabled = false; button.textContent = '🎫 开启自动抢票'; }, 1000); // 保存配置 if (typeof GM_setValue !== 'undefined') { GM_setValue('userConfig', userConfig); } } catch (error) { console.error('操作失败:', error); button.textContent = '🎫 开启自动抢票'; button.disabled = false; ticketManager.showNotification('系统错误', '操作失败,请重试'); } }); // 绑定复制链接按钮事件 document.getElementById('copyLinkBtn').addEventListener('click', function() { const input = document.getElementById('downloadLink'); input.select(); try { const successful = document.execCommand('copy'); const button = this; if (successful) { const originalText = button.textContent; button.textContent = '✅ 已复制'; button.style.background = 'linear-gradient(135deg, #10b981, #059669)'; setTimeout(() => { button.textContent = originalText; button.style.background = 'linear-gradient(135deg, #f59e0b, #d97706)'; }, 2000); ticketManager.showNotification('复制成功', '链接已复制到剪贴板'); } } catch (err) { console.error('复制失败:', err); ticketManager.showNotification('复制失败', '请手动复制链接'); } }); // 加载保存的配置 if (typeof GM_getValue !== 'undefined') { const savedConfig = GM_getValue('userConfig'); if (savedConfig) { document.getElementById('fromStation').value = savedConfig.fromStation || ''; document.getElementById('toStation').value = savedConfig.toStation || ''; document.getElementById('travelDate').value = savedConfig.travelDate || ''; document.getElementById('startTime').value = savedConfig.startTime || ''; } } } // 等待DOM加载完成后初始化 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initializeApplication); } else { initializeApplication(); } })();