// ==UserScript== // @name 网页自动连点器 // @namespace http://tampermonkey.net/ // @version 1.6 // @description 点击器功能强大,支持多种点击类型和灵活延迟设置 // @author YourName // @match *://*/* // @icon https://img.ixintu.com/download/jpg/202001/d9a6b42c05fa8030705926cb38d7c8a5.jpg!con // @grant GM_setValue // @grant GM_getValue // @grant GM_addStyle // @grant GM_notification // @require https://code.jquery.com/jquery-3.6.0.min.js // ==/UserScript== (function() { 'use strict'; // 广告配置 - 在这里填充您的广告信息 const adConfig = [ { name: "网盘解除下载速度工具", url: "https://pan.quark.cn/s/45d72ccb9e74" }, { name: "12306自动抢票", url: "https://pan.quark.cn/s/34871455b689" }, { name: "office激活工具", url: "https://pan.quark.cn/s/17891483c186" }, { name: "电脑破解软件", url: "https://pan.quark.cn/s/c8feae4a6fc0" }, { name: "PPT模板分享", url: "https://pan.quark.cn/s/d866fba7c0db" }, { name: "各类资源合集", url: "https://pan.quark.cn/s/51e51e77b6b7" } ]; // 存储点击规则的数据结构 let clickRules = GM_getValue('clickRules', []); let isRunning = false; let currentInterval = null; let currentRuleIndex = 0; let minimizeTimeout = null; // 创建固定顶部广告栏 function createFixedAdBanner() { // 如果已经存在,先移除 if ($('#fixed-ad-banner').length) { $('#fixed-ad-banner').remove(); } // 清除可能存在的超时 if (minimizeTimeout) { clearTimeout(minimizeTimeout); minimizeTimeout = null; } // 计算实际显示的广告数量 const activeAds = adConfig.filter(ad => ad.name && ad.url); console.log('有效广告数量:', activeAds.length); if (activeAds.length === 0) { console.log('没有配置广告内容,广告栏不会显示'); return; } // 生成广告位HTML let adsHTML = ''; adConfig.forEach((ad, index) => { if (ad.name && ad.url) { adsHTML += ` 作者推荐 ${ad.name} `; } }); const adBannerHTML = `
${adsHTML}
`; $('body').prepend(adBannerHTML); console.log('固定顶部广告栏已添加到页面'); // 为body添加顶部边距,防止内容被广告栏遮挡 adjustBodyMargin(); // 绑定广告栏事件 $('#toggle-ad-banner').on('click', function() { toggleAdBanner(); }); // 广告点击统计 $('.ad-item').on('click', function(e) { const adIndex = $(this).data('ad-index'); console.log(`广告点击: ${adConfig[adIndex].name}`, adConfig[adIndex].url); // 允许默认行为(跳转链接) return true; }); // 检查广告链接是否正确绑定 setTimeout(() => { const adLinks = $('.ad-item'); console.log(`找到 ${adLinks.length} 个广告链接`); adLinks.each(function() { const href = $(this).attr('href'); console.log('广告链接:', href); }); }, 1000); } // 调整body边距 function adjustBodyMargin() { const bannerHeight = $('#fixed-ad-banner').outerHeight(); $('body').css('margin-top', bannerHeight + 'px'); } // 切换广告栏状态 function toggleAdBanner() { const $banner = $('#fixed-ad-banner'); const $slots = $('.ad-slots'); const $toggleBtn = $('#toggle-ad-banner'); if ($slots.is(':visible')) { // 最小化广告栏 $slots.hide(); $toggleBtn.text('+').attr('title', '展开广告栏'); $banner.css('height', '30px'); // 设置3分钟后自动恢复 minimizeTimeout = setTimeout(() => { expandAdBanner(); }, 3 * 60 * 1000); // 3分钟 } else { // 展开广告栏 expandAdBanner(); } // 调整body边距 adjustBodyMargin(); } // 展开广告栏 function expandAdBanner() { const $banner = $('#fixed-ad-banner'); const $slots = $('.ad-slots'); const $toggleBtn = $('#toggle-ad-banner'); $slots.show(); $toggleBtn.text('−').attr('title', '最小化广告栏'); $banner.css('height', 'auto'); // 清除超时 if (minimizeTimeout) { clearTimeout(minimizeTimeout); minimizeTimeout = null; } // 调整body边距 adjustBodyMargin(); } // 创建自动点击器悬浮窗 function createAutoClicker() { // 如果已经存在,先移除 if ($('#auto-clicker-floating').length) { $('#auto-clicker-floating').remove(); } const floatingHTML = `
`; $('body').append(floatingHTML); // 绑定自动点击器事件 bindAutoClickerEvents(); // 使悬浮窗可拖动 makeDraggable(); } // 绑定自动点击器事件 function bindAutoClickerEvents() { // 切换展开/收缩 $('#toggle-expand').on('click', function() { $('#floating-collapsed').hide(); $('#floating-expanded').show(); }); $('#toggle-collapse').on('click', function() { $('#floating-expanded').hide(); $('#floating-collapsed').show(); }); // 添加规则 $('#add-rule-btn').on('click', showAddRuleDialog); // 查看规则 $('#view-rules-btn').on('click', showRulesList); // 开始执行 $('#start-btn').on('click', startAutoClick); // 停止执行 $('#stop-btn').on('click', stopAutoClick); // 测试点击 $('#test-click-btn').on('click', showTestClickDialog); // 关闭点击器 $('#close-clicker-btn').on('click', function() { stopAutoClick(); $('#auto-clicker-floating').remove(); }); } // 添加CSS样式 function addStyles() { const css = ` /* 固定顶部广告栏样式 */ #fixed-ad-banner { position: fixed; top: 0; left: 0; width: 100%; min-height: 70px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); z-index: 100000; box-shadow: 0 4px 20px rgba(0,0,0,0.3); border-bottom: 2px solid rgba(255,255,255,0.3); transition: all 0.3s ease; display: flex; align-items: center; padding: 10px 15px; box-sizing: border-box; } .ad-container { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 1200px; margin: 0 auto; position: relative; } .ad-slots { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; flex: 1; } .ad-item { display: flex; flex-direction: column; align-items: center; color: white; text-decoration: none; font-size: 14px; font-weight: 600; padding: 8px 12px; border-radius: 8px; background: rgba(255,255,255,0.2); transition: all 0.3s ease; border: 1px solid rgba(255,255,255,0.3); cursor: pointer; min-width: 120px; max-width: 200px; flex: 1; min-height: 50px; justify-content: center; text-align: center; } .ad-item:hover { background: rgba(255,255,255,0.3); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); text-decoration: none; color: white; } .ad-badge { background: rgba(255,255,255,0.9); color: #764ba2; font-size: 10px; padding: 2px 6px; border-radius: 10px; margin-bottom: 4px; font-weight: bold; white-space: nowrap; } .ad-text { white-space: normal; overflow: visible; text-overflow: unset; word-break: break-word; line-height: 1.3; max-height: 2.6em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; } .ad-controls { display: flex; align-items: center; margin-left: 15px; } .toggle-ad-btn { background: rgba(255,255,255,0.2); border: none; color: white; width: 25px; height: 25px; border-radius: 50%; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; } .toggle-ad-btn:hover { background: rgba(255,255,255,0.3); transform: scale(1.1); } /* 自动点击器样式 */ #auto-clicker-floating { position: fixed; top: 90px; right: 20px; z-index: 99999; font-family: Arial, sans-serif; user-select: none; } .floating-panel { background: #f5f5f5; border: 1px solid #ccc; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); overflow: hidden; } #floating-collapsed { width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; } #floating-expanded { width: 280px; } .floating-btn { width: 40px; height: 40px; border: none; background: #4a86e8; color: white; border-radius: 50%; cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; } .floating-btn:hover { background: #3a76d8; } .panel-header { background: #4a86e8; color: white; padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; font-weight: bold; } .close-btn { background: none; border: none; color: white; cursor: pointer; font-size: 16px; } .panel-body { padding: 12px; } .status-indicator { margin-bottom: 12px; text-align: center; font-size: 14px; } .rules-count { font-size: 12px; color: #666; margin-top: 4px; } .current-rule { font-size: 12px; color: #e67e22; margin-top: 4px; font-weight: bold; } .button-group { display: flex; flex-direction: column; gap: 6px; } .action-btn { padding: 8px 12px; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; transition: all 0.2s; } .action-btn:hover { opacity: 0.9; transform: translateY(-1px); } .start { background: #4CAF50; color: white; } .stop { background: #f44336; color: white; } .close { background: #9e9e9e; color: white; } .action-btn:not(.start):not(.stop):not(.close) { background: #2196F3; color: white; } /* 模态对话框样式 */ .modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 100001; } .modal-content { background: white; border-radius: 8px; padding: 20px; width: 90%; max-width: 500px; max-height: 80vh; overflow-y: auto; box-shadow: 0 4px 20px rgba(0,0,0,0.15); } .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid #eee; } .modal-title { font-size: 18px; font-weight: bold; } .modal-close { background: none; border: none; font-size: 20px; cursor: pointer; } .form-group { margin-bottom: 16px; } .form-label { display: block; margin-bottom: 6px; font-weight: bold; } .form-input { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; } .form-row { display: flex; gap: 10px; margin-bottom: 16px; } .form-row .form-group { flex: 1; margin-bottom: 0; } .btn-group { display: flex; gap: 10px; margin-top: 20px; } .btn { padding: 10px 16px; border: none; border-radius: 4px; cursor: pointer; flex: 1; } .btn-primary { background: #2196F3; color: white; } .btn-secondary { background: #9e9e9e; color: white; } .rule-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid #eee; } .rule-info { flex: 1; } .rule-actions { display: flex; gap: 5px; } .delete-btn { background: #f44336; color: white; border: none; border-radius: 4px; padding: 5px 10px; cursor: pointer; } .empty-state { text-align: center; padding: 20px; color: #757575; } /* 坐标捕获模式样式 */ .capture-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 0, 0, 0.1); z-index: 100002; cursor: crosshair; } .capture-message { position: fixed; top: 60px; left: 0; width: 100%; background: rgba(0, 0, 0, 0.8); color: white; text-align: center; padding: 15px; z-index: 100003; font-size: 16px; font-weight: bold; } /* 测试点击标记样式 */ .click-marker { position: fixed; width: 20px; height: 20px; background: rgba(255, 0, 0, 0.7); border: 2px solid white; border-radius: 50%; z-index: 100004; pointer-events: none; animation: pulse 1s infinite; } @keyframes pulse { 0% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.5); opacity: 0.7; } 100% { transform: scale(1); opacity: 1; } } /* 响应式设计 */ @media (max-width: 1024px) { .ad-item { min-width: 100px; max-width: 150px; font-size: 13px; padding: 6px 10px; } } @media (max-width: 768px) { #fixed-ad-banner { min-height: 60px; } .ad-item { min-width: 80px; max-width: 120px; font-size: 12px; padding: 5px 8px; } .ad-badge { font-size: 9px; padding: 1px 4px; } #auto-clicker-floating { top: 80px; right: 10px; } } @media (max-width: 480px) { #fixed-ad-banner { min-height: 50px; padding: 8px 10px; } .ad-item { min-width: 70px; max-width: 90px; font-size: 11px; padding: 4px 6px; min-height: 40px; } .ad-badge { display: none; } .toggle-ad-btn { width: 20px; height: 20px; font-size: 14px; } .ad-controls { margin-left: 8px; } } `; GM_addStyle(css); } // 使悬浮窗可拖动 function makeDraggable() { const floatingWindow = $('#auto-clicker-floating')[0]; let isDragging = false; let currentX; let currentY; let initialX; let initialY; let xOffset = 0; let yOffset = 0; floatingWindow.addEventListener('mousedown', dragStart); document.addEventListener('mousemove', drag); document.addEventListener('mouseup', dragEnd); function dragStart(e) { if (e.target.id === 'toggle-expand' || e.target.id === 'toggle-collapse' || e.target.tagName === 'BUTTON') { return; } initialX = e.clientX - xOffset; initialY = e.clientY - yOffset; if (e.target === floatingWindow || e.target.id === 'floating-collapsed' || e.target.id === 'floating-expanded' || e.target.className.includes('panel-header')) { isDragging = true; } } function drag(e) { if (isDragging) { e.preventDefault(); currentX = e.clientX - initialX; currentY = e.clientY - initialY; xOffset = currentX; yOffset = currentY; setTranslate(currentX, currentY, floatingWindow); } } function dragEnd(e) { initialX = currentX; initialY = currentY; isDragging = false; } function setTranslate(xPos, yPos, el) { el.style.transform = `translate3d(${xPos}px, ${yPos}px, 0)`; } } // 显示添加规则对话框 function showAddRuleDialog() { const modalHTML = ` `; $('body').append(modalHTML); // 绑定事件 $('#capture-position').on('click', startPositionCapture); $('#cancel-add-rule').on('click', function() { $('#add-rule-modal').remove(); }); $('.modal-close').on('click', function() { $('#add-rule-modal').remove(); }); $('#save-rule').on('click', saveClickRule); } // 开始坐标捕获 function startPositionCapture() { $('#add-rule-modal').remove(); const captureHTML = `
点击页面任意位置捕获坐标 (点击后自动关闭)
注意:坐标是相对于浏览器视口的
`; $('body').append(captureHTML); $('#capture-overlay').on('click', function(e) { const x = e.clientX; const y = e.clientY; // 移除捕获层 $('#capture-overlay').remove(); $('#capture-message').remove(); // 重新显示对话框并填充坐标 showAddRuleDialog(); $('#rule-x').val(x); $('#rule-y').val(y); }); } // 保存点击规则 function saveClickRule() { const name = $('#rule-name').val() || `规则${clickRules.length + 1}`; const x = parseInt($('#rule-x').val()); const y = parseInt($('#rule-y').val()); const delay = parseInt($('#rule-delay').val()) || 1000; const clickType = $('#click-type').val(); if (isNaN(x) || isNaN(y)) { alert('请输入有效的坐标'); return; } const newRule = { id: Date.now(), name: name, x: x, y: y, delay: delay, type: clickType }; clickRules.push(newRule); GM_setValue('clickRules', clickRules); // 更新规则计数 updateRulesCount(); $('#add-rule-modal').remove(); showNotification(`规则"${name}"已保存`, 'success'); } // 更新规则计数显示 function updateRulesCount() { $('#rules-count').text(`规则: ${clickRules.length}`); } // 更新当前规则显示 function updateCurrentRuleDisplay(ruleIndex) { if (ruleIndex >= 0 && ruleIndex < clickRules.length) { const rule = clickRules[ruleIndex]; $('#current-rule').text(`当前: ${rule.name || `规则${ruleIndex + 1}`}`); } else { $('#current-rule').text(''); } } // 显示规则列表 function showRulesList() { const rules = GM_getValue('clickRules', []); let rulesHTML = ''; if (rules.length === 0) { rulesHTML = '
暂无规则
'; } else { rules.forEach((rule, index) => { rulesHTML += `
${rule.name || `规则${index + 1}`}
坐标: (${rule.x}, ${rule.y}) | 延迟: ${rule.delay}ms | 类型: ${getClickTypeText(rule.type)}
`; }); } const modalHTML = ` `; $('body').append(modalHTML); // 绑定事件 $('.delete-btn').on('click', function() { const ruleId = parseInt($(this).data('id')); deleteRule(ruleId); }); $('#close-rules-list').on('click', function() { $('#rules-list-modal').remove(); }); $('.modal-close').on('click', function() { $('#rules-list-modal').remove(); }); } // 获取点击类型文本 function getClickTypeText(type) { const typeMap = { 'click': '普通点击', 'doubleClick': '双击', 'rightClick': '右键点击' }; return typeMap[type] || type; } // 删除规则 function deleteRule(ruleId) { const ruleIndex = clickRules.findIndex(rule => rule.id === ruleId); const ruleName = clickRules[ruleIndex]?.name || `规则${ruleIndex + 1}`; clickRules = clickRules.filter(rule => rule.id !== ruleId); GM_setValue('clickRules', clickRules); // 更新规则计数 updateRulesCount(); // 刷新规则列表 $('#rules-list-modal').remove(); showRulesList(); showNotification(`规则"${ruleName}"已删除`, 'info'); } // 显示测试点击对话框 function showTestClickDialog() { const modalHTML = ` `; $('body').append(modalHTML); // 绑定事件 $('#cancel-test').on('click', function() { $('#test-click-modal').remove(); }); $('#start-test').on('click', function() { $('#test-click-modal').remove(); startTestClick(); }); $('.modal-close').on('click', function() { $('#test-click-modal').remove(); }); } // 开始测试点击 function startTestClick() { const captureHTML = `
点击页面任意位置测试点击功能 (右键点击结束测试)
`; $('body').append(captureHTML); $('#test-capture-overlay').on('click', function(e) { const x = e.clientX; const y = e.clientY; // 显示点击标记 showClickMarker(x, y); // 执行点击 const success = performClick(x, y, 'click'); if (success) { console.log(`测试点击成功: (${x}, ${y})`); showNotification(`测试点击成功: (${x}, ${y})`, 'success'); } else { console.log(`测试点击失败: (${x}, ${y})`); showNotification(`测试点击失败: (${x}, ${y})`, 'error'); } }); // 右键点击结束测试 $('#test-capture-overlay').on('contextmenu', function(e) { e.preventDefault(); $('#test-capture-overlay').remove(); $('#test-capture-message').remove(); return false; }); } // 显示点击标记 function showClickMarker(x, y) { // 移除之前的标记 $('.click-marker').remove(); const marker = $('
'); marker.css({ left: (x - 10) + 'px', top: (y - 10) + 'px' }); $('body').append(marker); // 3秒后自动移除标记 setTimeout(() => { marker.remove(); }, 3000); } // 开始自动点击 function startAutoClick() { if (isRunning) return; const rules = GM_getValue('clickRules', []); if (rules.length === 0) { showNotification('请先添加点击规则', 'error'); return; } isRunning = true; currentRuleIndex = 0; updateStatus('状态: 运行中'); showNotification('自动点击已启动', 'info'); // 执行点击循环 function executeNextClick() { if (!isRunning) return; // 获取当前规则 const rule = rules[currentRuleIndex]; // 更新当前规则显示 updateCurrentRuleDisplay(currentRuleIndex); // 执行点击 const success = performClick(rule.x, rule.y, rule.type); if (success) { console.log(`规则执行成功 [${currentRuleIndex + 1}/${rules.length}]: ${rule.name || `规则${currentRuleIndex + 1}`}`); } else { console.log(`规则执行失败 [${currentRuleIndex + 1}/${rules.length}]: ${rule.name || `规则${currentRuleIndex + 1}`}`); } // 移动到下一个规则 currentRuleIndex = (currentRuleIndex + 1) % rules.length; // 如果还有规则,设置下一个规则的延迟 if (currentRuleIndex < rules.length) { const nextRule = rules[currentRuleIndex]; currentInterval = setTimeout(executeNextClick, nextRule.delay); } } // 立即执行第一个规则 executeNextClick(); } // 执行点击操作 function performClick(x, y, type) { try { // 获取目标元素 const element = document.elementFromPoint(x, y); if (!element) { console.log('未找到目标元素'); return false; } // 滚动元素到视图中 element.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'center' }); // 获取元素的真实坐标(考虑滚动和偏移) const rect = element.getBoundingClientRect(); const actualX = rect.left + (rect.width / 2); const actualY = rect.top + (rect.height / 2); let events = []; switch(type) { case 'doubleClick': // 双击事件 events = [ new MouseEvent('mousedown', { bubbles: true, cancelable: true, clientX: actualX, clientY: actualY, button: 0 }), new MouseEvent('mouseup', { bubbles: true, cancelable: true, clientX: actualX, clientY: actualY, button: 0 }), new MouseEvent('click', { bubbles: true, cancelable: true, clientX: actualX, clientY: actualY, button: 0 }), new MouseEvent('mousedown', { bubbles: true, cancelable: true, clientX: actualX, clientY: actualY, button: 0 }), new MouseEvent('mouseup', { bubbles: true, cancelable: true, clientX: actualX, clientY: actualY, button: 0 }), new MouseEvent('click', { bubbles: true, cancelable: true, clientX: actualX, clientY: actualY, button: 0 }), new MouseEvent('dblclick', { bubbles: true, cancelable: true, clientX: actualX, clientY: actualY, button: 0 }) ]; break; case 'rightClick': // 右键点击 events = [ new MouseEvent('mousedown', { bubbles: true, cancelable: true, clientX: actualX, clientY: actualY, button: 2 }), new MouseEvent('mouseup', { bubbles: true, cancelable: true, clientX: actualX, clientY: actualY, button: 2 }), new MouseEvent('contextmenu', { bubbles: true, cancelable: true, clientX: actualX, clientY: actualY, button: 2 }) ]; break; default: // 普通点击 events = [ new MouseEvent('mousedown', { bubbles: true, cancelable: true, clientX: actualX, clientY: actualY, button: 0 }), new MouseEvent('mouseup', { bubbles: true, cancelable: true, clientX: actualX, clientY: actualY, button: 0 }), new MouseEvent('click', { bubbles: true, cancelable: true, clientX: actualX, clientY: actualY, button: 0 }) ]; } // 触发所有事件 events.forEach(event => { element.dispatchEvent(event); }); // 对于链接和按钮,也尝试调用原生click方法 if (element.click && (element.tagName === 'A' || element.tagName === 'BUTTON' || element.type === 'submit')) { element.click(); } // 对于输入框,尝试聚焦 if (element.focus && (element.tagName === 'INPUT' || element.tagName === 'TEXTAREA')) { element.focus(); } return true; } catch (error) { console.error('点击执行错误:', error); return false; } } // 停止自动点击 function stopAutoClick() { if (!isRunning) return; isRunning = false; currentRuleIndex = 0; clearTimeout(currentInterval); updateStatus('状态: 已停止'); updateCurrentRuleDisplay(-1); showNotification('自动点击已停止', 'info'); } // 更新状态显示 function updateStatus(text) { $('#status-text').text(text); } // 显示通知 function showNotification(message, type) { // 使用GM_notification如果可用,否则使用alert if (typeof GM_notification !== 'undefined') { GM_notification({ text: message, title: '自动点击器', timeout: 3000 }); } else { // 简单地在控制台显示 console.log(`${type}: ${message}`); } } // 初始化 function init() { console.log('开始初始化固定顶部广告栏和自动点击器...'); addStyles(); createFixedAdBanner(); createAutoClicker(); console.log('初始化完成'); } // 页面加载完成后初始化 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();