NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name OGame: Combat Debug Info // @namespace http://tampermonkey.net/ // @version 0.1 // @description Shows debugging info in combat reports // @author RiV- // @match https://*.ogame.gameforge.com/game/*page=messages* // @grant none // @license MIT // @copyright 2020, RiV- (https://openuserjs.org/users/RiV-) // ==/UserScript== (function() { 'use strict'; var $ = "jQuery" in window ? window.jQuery : null; var Main = { Ready: function () { $(document).ajaxSuccess(Main.Content); }, Content: function (event, xhr, options) { let url; try { url = new URL(options.url).searchParams; } catch (e) { url = null; } let msgID; if (url && (msgID = url.get("messageId"))) { let detailMsg = $(".overlayDiv > .detail_msg[data-msg-id='" + msgID + "']"); if (detailMsg.data("messageType") === 25) { Main.Display(detailMsg); } } }, Display: function (detailMsg) { $(detailMsg).find("> div > div > div > script").each((i, element) => { if (element.textContent.match("var combatData")) { let API = JSON.parse(element.textContent.split("jQuery.parseJSON('")[1].split("');")[0]); let processTime = API.debugData.combatmicroend - API.debugData.combatmicrostart; let processTimeText = processTime < 1 ? Math.round(processTime * 1000) + "ms" : (Math.round(processTime * 100) / 100) + "s"; $(detailMsg).find(".detailReport").after( $("<br>", {"class": "clearfloat"}), $("<div>", {"class": "section_title"}).append( $("<div>", {"class": "c-left"}), $("<div>", {"class": "c-right"}), $("<span>", {"class": "title_txt", "text": "Debugging"}) ), $("<div>", {css: {padding: "5px 10px"}}).append( $("<span>", {"text": "Processed in " + processTimeText}), $("<br>"), $("<span>", {"text": "Expedition: " + API.isExpedition}), $("<br>"), $("<span>", {"text": "Deathstar destroyed (Hamill maneuver): " + API.deathstarDestroyed}), $("<br>"), $("<textarea>", {"text": JSON.stringify(API, null, 2), css: {width: "95%", height: "150px", marginTop: "5px", fontSize: "12px", fontFamily: "monospace"}}) ) ); } }); } }; $(Main.Ready); })();