您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Farmgod and send attack automatically at Loot Assistant at random intervals
当前为
// ==UserScript== // @name Autofarm V2 // @version 2.1 // @include https://*/game.php*screen=am_farm* // @namespace https://greasyfork.org/users/1388863 // @description Farmgod and send attack automatically at Loot Assistant at random intervals // ==/UserScript== (function () { 'use strict'; // Create toggle button let button = document.createElement("button"); button.innerText = "Stop"; button.style.position = "fixed"; button.style.bottom = "40px"; button.style.left = "20px"; button.style.padding = "8px 15px"; button.style.fontSize = "14px"; button.style.zIndex = "1000"; button.style.backgroundColor = "#4CAF50"; button.style.color = "white"; button.style.border = "none"; button.style.borderRadius = "5px"; button.style.cursor = "pointer"; document.body.appendChild(button); // Create countdown box let countdownPopup = document.createElement("div"); countdownPopup.style.position = "fixed"; countdownPopup.style.bottom = "75px"; countdownPopup.style.left = "20px"; countdownPopup.style.padding = "8px 15px"; countdownPopup.style.fontSize = "14px"; countdownPopup.style.zIndex = "1000"; countdownPopup.style.backgroundColor = "#333"; countdownPopup.style.color = "white"; countdownPopup.style.borderRadius = "5px"; countdownPopup.style.display = "none"; // Initially hidden document.body.appendChild(countdownPopup); // Settings button const settingsBtn = document.createElement('button'); settingsBtn.innerText = 'Settings'; settingsBtn.style.position = 'fixed'; settingsBtn.style.bottom = '110px'; settingsBtn.style.left = '20px'; settingsBtn.style.zIndex = '1000'; settingsBtn.style.backgroundColor = '#555'; settingsBtn.style.color = 'white'; settingsBtn.style.border = 'none'; settingsBtn.style.borderRadius = '5px'; settingsBtn.style.cursor = 'pointer'; document.body.appendChild(settingsBtn); // Settings popup const settingsPopup = document.createElement('div'); settingsPopup.style.display = 'none'; settingsPopup.style.position = 'fixed'; settingsPopup.style.bottom = '150px'; settingsPopup.style.left = '20px'; settingsPopup.style.backgroundColor = '#f9f9f9'; settingsPopup.style.padding = '20px'; settingsPopup.style.border = '1px solid #ddd'; settingsPopup.style.zIndex = '1000'; settingsPopup.innerHTML = ` <label>Chat ID: <input type="text" id="chatIdInput" value="${localStorage.getItem('telegramChatId') || '1817608753'}"></label><br><br> <button id="saveSettingsBtn">Save Settings</button><br><br> `; document.body.appendChild(settingsPopup); // Toggle settings popup settingsBtn.addEventListener('click', () => { settingsPopup.style.display = settingsPopup.style.display === 'none' ? 'block' : 'none'; }); // Save settings document.getElementById('saveSettingsBtn').addEventListener('click', () => { const chatId = document.getElementById('chatIdInput').value; localStorage.setItem('telegramChatId', chatId); settingsPopup.style.display = 'none'; alert("Settings saved successfully!"); }); let isRunning = true; let intervalId; let countdownInterval; let lastCaptchaTime = 0; let captchaDetected = false; // Telegram bot API token and function const botToken = "8151644407:AAEzt2C10IC8xGIc_Iaoeno02aPHg-cQFVU"; function sendToTelegram(message) { const chatId = localStorage.getItem('telegramChatId') || '1817608753'; const url = `https://api.telegram.org/bot${botToken}/sendMessage?chat_id=${chatId}&text=${encodeURIComponent(message)}`; fetch(url) .then(response => { if (!response.ok) { console.error("Failed to send message to Telegram:", response.statusText); } else { console.log("Message sent to Telegram:", message); } }) .catch(error => console.error("Telegram API error:", error)); } // Functions function randomDelay(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } function pressEnterRandomly() { const delay = randomDelay(200, 250); document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', code: 'Enter', which: 13, keyCode: 13, bubbles: true })); intervalId = setTimeout(pressEnterRandomly, delay); } function loadFarmGodScript() { $.getScript('https://higamy.github.io/TW/Scripts/Approved/FarmGodCopy.js') .done(function (script, textStatus) { console.log('Script loaded successfully:', textStatus); }) .fail(function (jqxhr, settings, exception) { console.error('Error loading script:', exception); }); } function clickOptionButton(retries = 3) { let button = document.querySelector('input.btn.optionButton[value="Plan farms"]'); if (button) { button.click(); console.log("Button 'Plan farms' clicked"); } else { console.log("Button 'Plan farms' not found"); if (retries > 0) { console.log("Retrying..."); setTimeout(function () { clickOptionButton(retries - 1); }, randomDelay(2000, 4000)); } } } function startProcess() { setTimeout(() => { // Delay before loading FarmGod script loadFarmGodScript(); setTimeout(() => { clickOptionButton(); setTimeout(() => { pressEnterRandomly(); startCountdown(); // Start countdown after initial process setup }, randomDelay(1000, 5000)); // Step 3 to 4 delay }, randomDelay(1000, 5000)); // Step 2 to 3 delay }, randomDelay(1000, 5000)); // Initial delay before loading script } function stopProcess() { clearTimeout(intervalId); clearInterval(countdownInterval); button.innerText = "Start"; countdownPopup.style.display = "none"; // Hide countdown popup isRunning = false; } function toggleProcess() { if (isRunning) { stopProcess(); } else if (!captchaDetected) { // Only start if CAPTCHA not detected startProcess(); button.innerText = "Stop"; isRunning = true; } } function startCountdown() { let timeLeft = randomDelay(300, 600); // 10 to 15 minutes in seconds countdownPopup.style.display = "block"; // Show countdown popup countdownInterval = setInterval(() => { if (timeLeft <= 0) { clearInterval(countdownInterval); countdownPopup.style.display = "none"; // Hide countdown popup before reload location.reload(); // Only reload after the countdown completes } else { countdownPopup.innerText = `Next loop in: ${Math.floor(timeLeft / 60)}m ${timeLeft % 60}s`; timeLeft--; } }, 1000); } // CAPTCHA detection function checkCaptcha() { const captchaIframe = document.querySelector('iframe[src*="hcaptcha"]'); const currentTime = Date.now(); if (captchaIframe && !captchaDetected) { console.log("CAPTCHA detected"); captchaDetected = true; stopProcess(); // Stop all other processes sendToTelegram("CAPTCHA detected. All processes have been stopped."); } else if (!captchaIframe && captchaDetected) { // If CAPTCHA is resolved captchaDetected = false; console.log("CAPTCHA resolved"); sendToTelegram("CAPTCHA resolved. You can start the process again."); } } // Initial Process Start startProcess(); // Toggle Button Event button.addEventListener("click", toggleProcess); // Check CAPTCHA every second setInterval(checkCaptcha, 1000); })();