您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Provides some general additions to Elethor
当前为
// ==UserScript== // @name Elethor General Purpose // @description Provides some general additions to Elethor // @namespace https://www.elethor.com/ // @version 1.0.6 // @author Anders Morgan Larsen (Xortrox) // @match https://elethor.com/* // @match https://www.elethor.com/* // @run-at document-start // @grant none // ==/UserScript== (function() { const moduleName = 'Elethor General Purpose'; const playerHealthBarElementDefinition = '.progress.is-medium.is-danger'; const playerHealthBarTextElementDefinition = '.is-fight-health'; function getBattleHealthPercentage() { const playerHealth = document.querySelector(playerHealthBarElementDefinition); if (!playerHealth) { return 0; } return playerHealth.value / playerHealth.max * 100; } function initializeUpdateBattleHealthPercentage() { if (window.elethorExtrasInterval) { clearInterval(window.elethorExtrasInterval); } window.elethorExtrasInterval = setInterval(() => { const playerHealthText = document.querySelector(playerHealthBarTextElementDefinition); const healthPercentage = getBattleHealthPercentage(); if (playerHealthText && healthPercentage && !isNaN(healthPercentage)) { let percentageDisplay; if (playerHealthText.children.length === 0) { percentageDisplay = document.createElement('span'); playerHealthText.appendChild(percentageDisplay); } else { percentageDisplay = playerHealthText.children[0]; } if (percentageDisplay) { percentageDisplay.innerText = ` (${healthPercentage.toFixed(3)}%)`; } } }, 500); console.log(`[${moduleName}] Battle Percentage initialized.`); } function initializeToastKiller() { document.addEventListener('click', function(e) { if (e.target && e.target.className && e.target.className.includes && e.target.className.includes('toasted') ) { e.target.remove(); } }); console.log(`[${moduleName}] Toast Killer initialized.`); } function initializeXHRHook() { let rawOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function() { if (!this._hooked) { this._hooked = true; setupHook(this); } rawOpen.apply(this, arguments); } function setupHook(xhr) { if (window.elethorGeneralPurposeOnUserLoad) { const e = new Event('EGPXHR'); e.xhr = xhr; window.elethorGeneralPurposeOnUserLoad.dispatchEvent(e); } } window.elethorGeneralPurposeOnUserLoad = new EventTarget(); console.log(`[${moduleName}] XHR Hook initialized.`); } function initializeUserLoadListener() { elethorGeneralPurposeOnUserLoad.addEventListener('EGPXHR', function (e) { if (e && e.xhr && e.xhr.responseURL.endsWith('/game/user')) { console.log('User load request:', e); } }); console.log(`[${moduleName}] User Load Listener initialized.`); } (function run() { initializeUpdateBattleHealthPercentage(); initializeToastKiller(); initializeXHRHook(); initializeUserLoadListener(); console.log(`[${moduleName}] Loaded.`); })(); })();