您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adding button to save your time
当前为
// ==UserScript== // @name save time to click // @namespace http://tampermonkey.net/ // @version 0.0.2 // @description Adding button to save your time // @match https://www.edominacy.com/*/battlefield/*/* // @grant none // @license MIT free to use // ==/UserScript== (function () { const PREFIX = { NAVY: "a#battleWeapons_25_", TANK: "a#battleWeapons_26_", SPECIAL_WEAPON: "a#battleWeapons_32_5" }; // Weapon quality manager compatible with old browsers const weaponQualityManager = new (function () { this.quality = 5; // Start with quality 5 this.isInitial = true; // Initial state // Select the next quality this.pickNextQuality = function (callback) { if (this.quality > 1) { this.quality--; // Decrease quality if not at minimum } else { callback(); } }; // Get the current quality this.getCurrentQuality = function () { return this.quality; }; // Check if we are in the initial state this.isInitial = function () { return this.isInitial; }; // Reset to initial quality this.reset = function () { this.quality = 5; this.isInitial = true; }; })(); function getProfileId() { var profileLink = document.querySelector("ul.dropdown-menu a[href*='/en/profile/']"); if (profileLink) { var href = profileLink.href; var profileId = href.split("/").pop(); console.log("Profile ID found:", profileId); return profileId; } else { console.log("Profile link not found!"); return null; } } function selectWeapon(quality) { var weapon = document.querySelector(PREFIX.TANK + quality); if (!weapon) { weapon = document.querySelector(PREFIX.NAVY + quality); } return weapon; } function checkSpecialWeapon() { var specialWeapon = document.querySelector(PREFIX.SPECIAL_WEAPON); if (specialWeapon && !specialWeapon.classList.contains('disabled')) { console.log("Special weapon is available for use."); return specialWeapon; } console.log("Special weapon is not available."); return null; } function fighter(options) { var button = options.button; var icon = options.icon; var clearParentInterval = options.clearParentInterval; console.log("Starting fighter interval..."); var intervalId = setInterval(function () { console.log("Interval running..."); var energy = document.getElementById("energyBarT"); if (!energy) { console.log("Energy bar not found!"); return; } var numberEnergy = parseInt(energy.innerText, 10); console.log("Energy:", numberEnergy); var energyBar = document.getElementById("battleEnergy"); var countDown = document.querySelector(".countdown_row.countdown_amount"); var profileId = getProfileId(); if (!profileId) { console.log("Profile ID not found, stopping..."); return; } var fightButton = document.getElementById("battleFight" + profileId); if (!fightButton) { console.log("Fight button not found for profile ID:", profileId); return; } if (!countDown || countDown.innerText === "00:00:00" || countDown.innerText < "00:00:03") { console.log("Countdown ended or near zero, stopping..."); if (fightButton) { fightButton.innerText = "FIGHT"; } restoreDefaultButtonState(button, icon); clearParentInterval(); console.info("STOPPED"); return; } fightButton.innerText = "CLICKING"; var weapon = null; weapon = checkSpecialWeapon(); if (!weapon) { if (weaponQualityManager.isInitial) { console.log("Weapon not selected yet..."); weapon = selectWeapon(weaponQualityManager.getCurrentQuality()); if (!weapon) { console.log("No weapon found for quality 5. Trying quality 4..."); weaponQualityManager.pickNextQuality(function () { console.log("No weapon found for quality 4, stopping..."); restoreDefaultButtonState(button, icon); clearParentInterval(); }); weapon = selectWeapon(weaponQualityManager.getCurrentQuality()); } if (weapon) { console.log("Weapon found for quality " + weaponQualityManager.getCurrentQuality() + ", selecting..."); weapon.click(); } } } else { weapon.click(); } if (numberEnergy < 1001) { console.log("Energy less than 1001, trying to click energy bar..."); if (!energyBar) { console.log("Energy bar not found to click!"); fightButton.innerText = "FIGHT"; restoreDefaultButtonState(button, icon); clearParentInterval(); console.info("STOPPED NO MORE ENERGY"); return; } energyBar.click(); } else { console.log("Energy sufficient, clicking fight button..."); fightButton.click(); } }, 2500); return intervalId; } function restoreDefaultButtonState(button, icon) { console.log("Restoring default button state..."); icon.className = "fa fa-fighter-jet"; button.className = "btn btn-success"; button.blur(); } function appendChildrenToVs919() { console.log("Appending start/stop button to VS919 container..."); var container = document.querySelector("div.vs919"); if (!container) { console.log("VS919 container not found!"); return; } container.style.display = "flex"; var startStopButton = document.createElement("button"); startStopButton.title = "Fight"; startStopButton.className = "btn btn-success"; var icon = document.createElement("i"); icon.className = "fa fa-fighter-jet"; icon.style.pointerEvents = "none"; startStopButton.appendChild(icon); var interval = null; startStopButton.addEventListener("click", function (e) { console.log("Start/Stop button clicked..."); if (interval) { console.log("Stopping interval..."); restoreDefaultButtonState(e.target, icon); clearInterval(interval); interval = null; return; } console.log("Starting interval..."); icon.className = "fa fa-pause"; e.target.className = "btn btn-info"; e.target.blur(); interval = fighter({ button: e.target, icon: icon, clearParentInterval: function () { console.log("Clearing parent interval..."); clearInterval(interval); interval = null; } }); }); container.appendChild(startStopButton); } appendChildrenToVs919(); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址