// ==UserScript== // @name Ajustar Ataque Auto // @author Lanuevasepia // @include http://*.grepolis.com/game/* // @include https://*.grepolis.com/game/* // @exclude view-source://* // @exclude https://classic.grepolis.com/game/* // @grant GM_setValue // @grant GM_getValue // @copyright 2024 // @description Ajustar Ataque Auto... // @version 0.0.2 // @namespace https://greasyfork.org/users/978964// @downloadURL https://update.greasyfork.org/scripts/486764/Ajustar%20Ataque%20Auto.user.js// @updateURL https://update.greasyfork.org/scripts/486764/Ajustar%20Ataque%20Auto.meta.js // @downloadURL https://update.greasyfork.icu/scripts/527271/Ajustar%20Ataque%20Auto.user.js // @updateURL https://update.greasyfork.icu/scripts/527271/Ajustar%20Ataque%20Auto.meta.js // ==/UserScript== //SCRIPT TO TIMMING ATTACKS OR SUPPORT COMMANDS var settingsTimming = GM_getValue("settingTimming", 0); documentLoaded(); loadCSS(); observerAjax(); attachScript("moveFrame", moveFrame.toString()) moveFrame = new moveFrame; function documentLoaded() { var interval = setInterval(function () { if ( document.readyState === "complete" && $(".tb_activities.toolbar_activities .middle")[0] ) { clearInterval(interval); loadbutton(); var gameChange = new MutationObserver(function (mutations) { }); gameChange.observe(document.getElementsByTagName("body")[0], { childList: true, }); var commandsObserver = new MutationObserver(function (mutations) { commandsChange(); }); commandsObserver.observe( document.getElementById("toolbar_activity_commands_list"), { attributes: true, subtree: true } ); } }, 100); } function commandsChange() { var foundAttack = false; var listaElementos; for (var listaObjetos of document.getElementsByClassName( "js-dropdown-item-list" )) { if ( listaObjetos.childElementCount != 0 && /movement/.test(listaObjetos.children[0].id) ) { foundAttack = true; listaElementos = listaObjetos; break; } } if (foundAttack && listaElementos.children != null) { for (var child of listaElementos.children) { if (child.children[0].children[1].children[2] == null) { var indicador = document.createElement("div"); indicador.className = "indicatorAankomst"; var tiempoTotal = Timestamp.toDate(child.dataset.timestamp); var tiempoHora = tiempoTotal.getHours(); if (tiempoHora < 10) tiempoHora = "0" + tiempoHora; var tiempoMin = tiempoTotal.getMinutes(); if (tiempoMin < 10) tiempoMin = "0" + tiempoMin; var tiempoSeg = tiempoTotal.getSeconds(); if (tiempoSeg < 10) tiempoSeg = "0" + tiempoSeg; var tiempoInfo = tiempoHora + ":" + tiempoMin + ":" + tiempoSeg; indicadorTexto = document.createElement("p"); indicadorTexto.innerHTML = tiempoInfo; indicador.appendChild(indicadorTexto); indicadorTexto.style.fontSize = "1.2em"; indicadorTexto.style.fontWeight = "bold"; var indicatorAjuste = document.createElement("div"); indicador.appendChild(indicatorAjuste); child.children[0].children[1].appendChild(indicador); var tipo = indicador.parentNode tipo = tipo.parentNode.firstElementChild.getAttribute("class"); tipo = tipo.search("support"); if (tipo != -1) { if (indicadorTexto.textContent != settingsTimming) { indicadorTexto.style.color = "red"; indicatorAjuste.setAttribute("style", "width:1em;background:red;margin-left: 0.3em;"); } else { indicadorTexto.style.color = "green"; indicatorAjuste.setAttribute("style", "width:1em;background:green;margin-left: 0.3em;"); } } else { let posi = (settingsTimming.substring(settingsTimming.length - 2, settingsTimming.length)); var resultado = settingsTimming.substring(0, settingsTimming.length - 2); if (posi == "00") { posi = 59; resultado = (resultado.substring(0, resultado.length - 3)) + (resultado.substring(resultado.length - 3, resultado.length - 1) - 1) + ":" } else { if (posi.substring(0, 1) == "0") { posi = "0" + ((posi.substring(1, posi.length)) - 1) } else { if (posi == 10) { posi = "09" } else { posi = posi - 1; } } } let ataque = resultado + posi; if (indicadorTexto.textContent != ataque) { indicadorTexto.style.color = "red"; indicatorAjuste.setAttribute("style", "width:1em;background:red;margin-left: 0.3em;"); } else { indicadorTexto.style.color = "green"; indicatorAjuste.setAttribute("style", "width:1em;background:green;margin-left: 0.3em;"); } } } } } } function loadbutton() { let icono = document.createElement("div"); icono.id = "GMESetupLink"; icono.className = "btn_settings circle_button"; let img = document.createElement("div"); img.style.margin = "6px 0px 0px 5px"; img.style.width = "22px"; img.style.height = "22px"; img.style.backgroundSize = "100%"; icono.style.top = "12px"; icono.style.right = "485px"; icono.style.zIndex = "10000"; icono.appendChild(img); document.getElementById("ui_box").appendChild(icono); $("#GMESetupLink").click(hacerMenu); } function hacerMenu() { var existeVentana = false; var existeObjeto = null; for (var objeto of document.getElementsByClassName("ui-dialog-title")) { if (objeto.innerHTML == "Hora del colono") { existeVentana = true; existeObjeto = objeto; } } if (!existeVentana) wnd = Layout.wnd.Create(Layout.wnd.TYPE_DIALOG, "GME Settings"); wnd.setContent(""); for (objeto of document.getElementsByClassName("ui-dialog-title")) { if (objeto.innerHTML == "GME Settings") { existeObjeto = objeto; } } wnd.setHeight(document.body.scrollHeight / 2 + 100); wnd.setTitle("Hora del colono"); var title = existeObjeto; var frame = title.parentElement.parentElement.children[1].children[4]; frame.innerHTML = ""; var html = document.createElement("html"); var body = document.createElement("div"); var head = document.createElement("head"); element = document.createElement("h3"); element.innerHTML = ""; body.appendChild(element); var list = document.createElement("ul"); list.appendChild(document.createElement("hr")); hacerCajaTexto(list, settingsTimming, "settingTimming", 400); var savebutton = crearBoton("settings_reload", "Guardar"); savebutton.style.position = "absolute"; savebutton.style.bottom = "0"; savebutton.style.right = "0"; body.appendChild(savebutton); var listitem = document.createElement("div"); listitem.innerHTML = '
'; listitem.style.position = "absolute"; listitem.style.top = "0"; listitem.style.right = "0"; body.appendChild(listitem); element.style.position = "absolute"; element.style.bottom = "0"; element.style.left = "0"; element.style.marginBottom = "0"; element.style.lineHeight = "1"; list.appendChild(element); body.appendChild(list); html.appendChild(head); html.appendChild(body); frame.appendChild(html); $(".Hora del colono").click(function () { wisselInstelling(this); }); $("#settings_reload").click(function () { GM_setValue("settingTimming", $("#settingTimming").val()); window.location.reload(); }); } function crearBoton(id, text) { var element = document.createElement("div"); element.className = "button_new"; element.id = id; element.style.margin = "2px"; var childElement = document.createElement("div"); childElement.className = "left"; element.appendChild(childElement); childElement = document.createElement("div"); childElement.className = "right"; element.appendChild(childElement); childElement = document.createElement("div"); childElement.className = "caption js-caption"; childElement.innerHTML = text + ''; element.style.float = "left"; element.appendChild(childElement); return element; } function hacerCajaTexto(list, setting, id, width) { var listitem = document.createElement("div"); listitem.className = "textbox"; listitem.style.width = width + "px"; if (setting == null) setting = ""; listitem.innerHTML = '