// ==UserScript== // @name 斗鱼2024年12月钓鱼大赛自动操作脚本 // @namespace your_namespace_here // @match https://www.douyu.com/pages/fish-act/mine* // @grant none // @version 1.0 // @description 自动检测斗鱼钓鱼活动按钮并进行相应点击操作,实现自动抛竿、收杆,在活动时间段(中午12:00到凌晨00:30每个准点开启半小时)内执行抛竿 // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; function isActivityTime() { const now = new Date(); const hour = now.getHours(); const minute = now.getMinutes(); // 判断是否在活动时间范围内(中午12:00到凌晨00:30每个准点开启半小时) return (hour >= 12 && hour < 24 && minute < 30) || (hour === 0 && minute < 30); } function simulateClick(element) { const clickEvent = new MouseEvent('click', { view: window, bubbles: true, cancelable: true }); element.dispatchEvent(clickEvent); } const interval = 3000; function checkAndAct() { console.log(`每隔 ${interval/1000} 秒执行检测功能`); // 尝试查找并关闭提示弹窗 const resultModal = document.querySelector('.CommonModal-modal.is-center.ManualFishResultModal'); if (resultModal) { const closeBtn = resultModal.querySelector('div.btn'); if (closeBtn) { simulateClick(closeBtn); } } const starterDiv = document.querySelector('.Starter'); if (starterDiv) { const majorBtn = starterDiv.querySelector('.majorBtn'); if (majorBtn) { const status = majorBtn.querySelector('.status'); if (majorBtn.classList.contains('active')) { const openFishingButton = majorBtn.querySelector('div.info > div.tips > p.tips.minor'); if (openFishingButton && openFishingButton.textContent.trim() === '开启钓鱼') { const now = new Date(); const year = now.getFullYear(); const month = (now.getMonth() + 1).toString().padStart(2, '0'); const day = now.getDate().toString().padStart(2, '0'); const hour = now.getHours().toString().padStart(2, '0'); const minute = now.getMinutes().toString().padStart(2, '0'); const second = now.getSeconds().toString().padStart(2, '0'); const formattedTime = `${year}-${month}-${day} ${hour}:${minute}:${second}`; if (isActivityTime()) { console.log(`在大赛时间段内,目前时间为:${formattedTime}`); console.log('点击抛竿'); simulateClick(openFishingButton); }else{ console.log(`不在大赛时间段内,目前时间为:${formattedTime}`); } } } else if (majorBtn.classList.contains('finish')) { const finishButton = majorBtn.querySelector('div.info > div.tips > p.tips.major'); if (finishButton && finishButton.textContent.trim() === '收竿') { console.log('点击收竿'); simulateClick(finishButton); } } } } } // 使用setInterval设置每隔3000毫秒(即3秒,你可以根据实际需求调整时间间隔)执行一次checkAndAct函数 setInterval(checkAndAct, interval); })();