// ==UserScript== // @name AI彩票选号生成器 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 中国福利彩票和体育彩票智能选号生成器 - 支持双色球、大乐透、3D、排列3/5等 // @author AI Assistant // @match *://*/* // @grant GM_addStyle // @grant GM_setClipboard // @grant GM_notification // @run-at document-idle // @license MIT // ==/UserScript== (function() { 'use strict'; // 彩票配置 const LOTTERY_CONFIG = { 'ssq': { name: '双色球', type: '福利彩票', redRange: [1, 33], redCount: 6, blueRange: [1, 16], blueCount: 1, description: '红色球 33选6 + 蓝色球 16选1' }, 'dlt': { name: '大乐透', type: '体育彩票', frontRange: [1, 35], frontCount: 5, backRange: [1, 12], backCount: 2, description: '前区 35选5 + 后区 12选2' }, '3d': { name: '3D', type: '福利彩票', digits: 3, digitRange: [0, 9], description: '000-999 三位数' }, 'pl3': { name: '排列3', type: '体育彩票', digits: 3, digitRange: [0, 9], description: '000-999 三位数' }, 'pl5': { name: '排列5', type: '体育彩票', digits: 5, digitRange: [0, 9], description: '00000-99999 五位数' }, 'qxc': { name: '七星彩', type: '体育彩票', digits: 7, digitRange: [0, 9], description: '7位数字,每位0-9' }, 'kl8': { name: '快乐8', type: '福利彩票', range: [1, 80], selectCount: 20, description: '80选20' } }; // 创建样式 const style = ` .lottery-generator-container { position: fixed; top: 20px; right: 20px; width: 360px; max-height: 90vh; background: linear-gradient(145deg, #1a1a2e, #16213e); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); z-index: 9999999; font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif; overflow: hidden; transition: all 0.3s ease; } .lottery-generator-container.minimized { width: 60px; height: 60px; border-radius: 50%; cursor: pointer; } .lottery-generator-container.minimized .lottery-main-content { display: none; } .lottery-header { background: linear-gradient(135deg, #e94560, #0f3460); padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; cursor: move; } .lottery-header h3 { margin: 0; color: #fff; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; } .lottery-header h3::before { content: "🎰"; } .lottery-controls { display: flex; gap: 8px; } .lottery-btn-icon { width: 28px; height: 28px; border: none; border-radius: 6px; background: rgba(255,255,255,0.2); color: #fff; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: all 0.2s; } .lottery-btn-icon:hover { background: rgba(255,255,255,0.3); transform: scale(1.1); } .lottery-main-content { padding: 20px; max-height: calc(90vh - 120px); overflow-y: auto; } .lottery-main-content::-webkit-scrollbar { width: 6px; } .lottery-main-content::-webkit-scrollbar-track { background: rgba(255,255,255,0.1); border-radius: 3px; } .lottery-main-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 3px; } .lottery-type-selector { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; } .lottery-type-btn { padding: 10px 8px; border: 2px solid rgba(255,255,255,0.1); border-radius: 10px; background: rgba(255,255,255,0.05); color: #a0a0a0; cursor: pointer; font-size: 12px; font-weight: 500; transition: all 0.3s; text-align: center; } .lottery-type-btn:hover { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.2); } .lottery-type-btn.active { background: linear-gradient(135deg, #667eea, #764ba2); border-color: transparent; color: #fff; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4); } .lottery-info { background: rgba(255,255,255,0.05); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; } .lottery-info h4 { margin: 0 0 6px 0; color: #fff; font-size: 14px; display: flex; align-items: center; gap: 6px; } .lottery-info .type-badge { font-size: 10px; padding: 2px 8px; border-radius: 10px; background: linear-gradient(135deg, #e94560, #ff6b6b); } .lottery-info p { margin: 0; color: #888; font-size: 12px; } .lottery-options { display: flex; gap: 12px; margin-bottom: 16px; } .lottery-option-group { flex: 1; } .lottery-option-label { display: block; color: #888; font-size: 12px; margin-bottom: 6px; } .lottery-input { width: 100%; padding: 10px 12px; border: 2px solid rgba(255,255,255,0.1); border-radius: 8px; background: rgba(255,255,255,0.05); color: #fff; font-size: 14px; box-sizing: border-box; transition: all 0.3s; } .lottery-input:focus { outline: none; border-color: #667eea; background: rgba(255,255,255,0.1); } .lottery-generate-btn { width: 100%; padding: 14px; border: none; border-radius: 10px; background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.3s; margin-bottom: 16px; } .lottery-generate-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4); } .lottery-generate-btn:active { transform: translateY(0); } .lottery-results { background: rgba(255,255,255,0.03); border-radius: 12px; padding: 12px; max-height: 300px; overflow-y: auto; } .lottery-results-title { color: #666; font-size: 12px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; } .lottery-result-item { background: rgba(255,255,255,0.05); border-radius: 8px; padding: 12px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; } .lottery-result-item:last-child { margin-bottom: 0; } .lottery-number-display { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; } .lottery-ball { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.3); } .lottery-ball.red { background: linear-gradient(135deg, #ff4757, #ff6b81); box-shadow: 0 3px 10px rgba(255, 71, 87, 0.4); } .lottery-ball.blue { background: linear-gradient(135deg, #3742fa, #5352ed); box-shadow: 0 3px 10px rgba(55, 66, 250, 0.4); } .lottery-ball.green { background: linear-gradient(135deg, #2ed573, #7bed9f); box-shadow: 0 3px 10px rgba(46, 213, 115, 0.4); } .lottery-ball.purple { background: linear-gradient(135deg, #a55eea, #8854d0); box-shadow: 0 3px 10px rgba(165, 94, 234, 0.4); } .lottery-ball.orange { background: linear-gradient(135deg, #ffa502, #ff6348); box-shadow: 0 3px 10px rgba(255, 165, 2, 0.4); } .lottery-ball.plain { background: linear-gradient(135deg, #747d8c, #57606f); box-shadow: 0 3px 10px rgba(116, 125, 140, 0.4); } .lottery-ball-separator { color: #666; font-size: 18px; align-self: center; margin: 0 4px; } .lottery-copy-btn { padding: 8px 12px; border: none; border-radius: 6px; background: rgba(255,255,255,0.1); color: #fff; cursor: pointer; font-size: 12px; transition: all 0.2s; } .lottery-copy-btn:hover { background: rgba(102, 126, 234, 0.5); } .lottery-copy-btn.copied { background: rgba(46, 213, 115, 0.5); } .lottery-lucky-btn { width: 100%; padding: 12px; border: 2px dashed rgba(255,255,255,0.2); border-radius: 10px; background: transparent; color: #888; cursor: pointer; font-size: 13px; transition: all 0.3s; margin-top: 12px; } .lottery-lucky-btn:hover { border-color: #ffd700; color: #ffd700; background: rgba(255, 215, 0, 0.05); } .lottery-tips { margin-top: 16px; padding: 12px; background: rgba(255, 193, 7, 0.1); border-radius: 8px; border-left: 3px solid #ffc107; } .lottery-tips p { margin: 0; color: #b0b0b0; font-size: 11px; line-height: 1.6; } .lottery-tips strong { color: #ffc107; } /* 动画 */ @keyframes lotteryBounce { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } } .lottery-ball.animate { animation: lotteryBounce 0.3s ease; } /* 拖拽时的样式 */ .lottery-generator-container.dragging { opacity: 0.9; cursor: move; } /* 响应式 */ @media (max-width: 400px) { .lottery-generator-container { width: calc(100% - 40px); right: 20px; left: 20px; } } `; // 添加样式 GM_addStyle(style); // 创建DOM结构 function createLotteryUI() { const container = document.createElement('div'); container.className = 'lottery-generator-container'; container.id = 'lottery-generator'; container.innerHTML = `

AI彩票选号器

双色球福利彩票

红色球 33选6 + 蓝色球 16选1

生成结果

点击上方按钮生成号码

温馨提示:理性购彩,量力而行。彩票为公益事业,中奖概率有限,请勿沉迷。本工具仅供娱乐参考。

`; document.body.appendChild(container); return container; } // 初始化UI const container = createLotteryUI(); const typeSelector = document.getElementById('lottery-type-selector'); const generateBtn = document.getElementById('lottery-generate'); const resultsList = document.getElementById('lottery-results-list'); const copyAllBtn = document.getElementById('copy-all'); const minimizeBtn = document.getElementById('lottery-minimize'); const closeBtn = document.getElementById('lottery-close'); const luckyBtn = document.getElementById('lottery-lucky'); const countInput = document.getElementById('lottery-count'); let currentType = 'ssq'; let results = []; // 渲染类型选择器 function renderTypeSelector() { typeSelector.innerHTML = ''; Object.entries(LOTTERY_CONFIG).forEach(([key, config]) => { const btn = document.createElement('button'); btn.className = `lottery-type-btn ${key === currentType ? 'active' : ''}`; btn.textContent = config.name; btn.dataset.type = key; btn.addEventListener('click', () => selectType(key)); typeSelector.appendChild(btn); }); } // 选择彩票类型 function selectType(type) { currentType = type; const config = LOTTERY_CONFIG[type]; // 更新UI document.querySelectorAll('.lottery-type-btn').forEach(btn => { btn.classList.toggle('active', btn.dataset.type === type); }); document.getElementById('lottery-name').textContent = config.name; document.getElementById('lottery-type').textContent = config.type; document.getElementById('lottery-desc').textContent = config.description; // 清空结果 results = []; renderResults(); } // 生成随机数 function randomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } // 打乱数组 function shuffleArray(array) { const arr = [...array]; for (let i = arr.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [arr[i], arr[j]] = [arr[j], arr[i]]; } return arr; } // 生成双色球号码 function generateSSQ() { const reds = shuffleArray([...Array(33).keys()].map(i => i + 1)).slice(0, 6).sort((a, b) => a - b); const blue = randomInt(1, 16); return { reds, blue }; } // 生成大乐透号码 function generateDLT() { const front = shuffleArray([...Array(35).keys()].map(i => i + 1)).slice(0, 5).sort((a, b) => a - b); const back = shuffleArray([...Array(12).keys()].map(i => i + 1)).slice(0, 2).sort((a, b) => a - b); return { front, back }; } // 生成数字型彩票 function generateDigits(config) { const digits = []; for (let i = 0; i < config.digits; i++) { digits.push(randomInt(config.digitRange[0], config.digitRange[1])); } return digits; } // 生成快乐8号码 function generateKL8() { return shuffleArray([...Array(80).keys()].map(i => i + 1)).slice(0, 20).sort((a, b) => a - b); } // 生成号码 function generateNumbers() { const count = parseInt(countInput.value) || 1; const numbers = []; for (let i = 0; i < Math.min(count, 50); i++) { switch (currentType) { case 'ssq': numbers.push(generateSSQ()); break; case 'dlt': numbers.push(generateDLT()); break; case '3d': case 'pl3': case 'pl5': case 'qxc': numbers.push(generateDigits(LOTTERY_CONFIG[currentType])); break; case 'kl8': numbers.push(generateKL8()); break; } } return numbers; } // 渲染结果 function renderResults() { if (results.length === 0) { resultsList.innerHTML = '

点击上方按钮生成号码

'; copyAllBtn.style.display = 'none'; return; } copyAllBtn.style.display = 'block'; resultsList.innerHTML = results.map((num, index) => { let html = ''; let text = ''; if (currentType === 'ssq') { html = num.reds.map(r => `
${r}
`).join(''); html += '+'; html += `
${num.blue}
`; text = `红球: ${num.reds.join(', ')} 蓝球: ${num.blue}`; } else if (currentType === 'dlt') { html = num.front.map(f => `
${f}
`).join(''); html += '+'; html += num.back.map(b => `
${b}
`).join(''); text = `前区: ${num.front.join(', ')} 后区: ${num.back.join(', ')}`; } else if (currentType === 'kl8') { html = num.map(n => `
${n}
`).join(''); text = num.join(', '); } else { html = num.map((n, i) => { const colors = ['red', 'blue', 'green', 'orange', 'purple', 'plain', 'plain']; return `
${n}
`; }).join(''); text = num.join(''); } return `
${html}
`; }).join(''); // 添加动画效果 document.querySelectorAll('.lottery-ball').forEach((ball, i) => { setTimeout(() => { ball.classList.add('animate'); }, i * 50); }); } // 复制单个号码 window.copyNumber = function(index) { const num = results[index]; let text = ''; if (currentType === 'ssq') { text = `红球: ${num.reds.join(', ')} | 蓝球: ${num.blue}`; } else if (currentType === 'dlt') { text = `前区: ${num.front.join(', ')} | 后区: ${num.back.join(', ')}`; } else if (currentType === 'kl8') { text = num.join(', '); } else { text = num.join(''); } GM_setClipboard(text); GM_notification({ text: '号码已复制!', timeout: 1500 }); // 按钮反馈 const btn = document.querySelector(`.lottery-result-item[data-index="${index}"] .lottery-copy-btn`); if (btn) { btn.textContent = '已复制!'; btn.classList.add('copied'); setTimeout(() => { btn.textContent = '复制'; btn.classList.remove('copied'); }, 1500); } }; // 复制全部 copyAllBtn.addEventListener('click', () => { let text = `${LOTTERY_CONFIG[currentType].name} 选号结果:\n\n`; results.forEach((num, i) => { if (currentType === 'ssq') { text += `第${i + 1}注: 红球 ${num.reds.join(', ')} | 蓝球 ${num.blue}\n`; } else if (currentType === 'dlt') { text += `第${i + 1}注: 前区 ${num.front.join(', ')} | 后区 ${num.back.join(', ')}\n`; } else if (currentType === 'kl8') { text += `第${i + 1}注: ${num.join(', ')}\n`; } else { text += `第${i + 1}注: ${num.join('')}\n`; } }); text += '\n---\n由 AI彩票选号生成器 生成'; GM_setClipboard(text); GM_notification({ text: '全部号码已复制!', timeout: 2000 }); }); // 生成按钮事件 generateBtn.addEventListener('click', () => { results = generateNumbers(); renderResults(); }); // 幸运机选 luckyBtn.addEventListener('click', () => { // 随机选择类型 const types = Object.keys(LOTTERY_CONFIG); const randomType = types[Math.floor(Math.random() * types.length)]; selectType(randomType); // 生成5注 countInput.value = 5; results = generateNumbers(); renderResults(); GM_notification({ text: `已切换到${LOTTERY_CONFIG[randomType].name}并生成5注!`, timeout: 2000 }); }); // 最小化 minimizeBtn.addEventListener('click', () => { container.classList.toggle('minimized'); minimizeBtn.textContent = container.classList.contains('minimized') ? '➕' : '➖'; }); // 关闭 closeBtn.addEventListener('click', () => { container.style.display = 'none'; }); // 拖拽功能 let isDragging = false; let dragOffsetX, dragOffsetY; const header = container.querySelector('.lottery-header'); header.addEventListener('mousedown', (e) => { if (e.target.classList.contains('lottery-btn-icon')) return; isDragging = true; container.classList.add('dragging'); dragOffsetX = e.clientX - container.offsetLeft; dragOffsetY = e.clientY - container.offsetTop; }); document.addEventListener('mousemove', (e) => { if (!isDragging) return; container.style.left = (e.clientX - dragOffsetX) + 'px'; container.style.top = (e.clientY - dragOffsetY) + 'px'; container.style.right = 'auto'; }); document.addEventListener('mouseup', () => { isDragging = false; container.classList.remove('dragging'); }); // 初始化 renderTypeSelector(); // 创建悬浮球 const floatingBall = document.createElement('div'); floatingBall.innerHTML = '🎰'; floatingBall.style.cssText = ` position: fixed; bottom: 30px; right: 30px; width: 60px; height: 60px; background: linear-gradient(135deg, #667eea, #764ba2); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; cursor: pointer; box-shadow: 0 8px 30px rgba(102, 126, 234, 0.5); z-index: 9999998; transition: all 0.3s; `; floatingBall.title = '打开彩票选号器'; floatingBall.addEventListener('click', () => { container.style.display = 'block'; container.classList.remove('minimized'); floatingBall.style.display = 'none'; }); document.body.appendChild(floatingBall); // 监听显示状态 const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if (mutation.type === 'attributes' && mutation.attributeName === 'style') { if (container.style.display === 'none') { floatingBall.style.display = 'flex'; } } }); }); observer.observe(container, { attributes: true }); })();