// ==UserScript== // @name Gladiatus Tools // @namespace https://greasyfork.org/users/904482 // @version 0.5.0 // @description Set of tools and aids for the game Gladiatus // @author lpachecob // @grant none // @match *.gladiatus.gameforge.com/game/index.php* // @icon https://cdn.jsdelivr.net/gh/lpachecob/Gladiatus-Tools@main/images/favicon.ico // @license MIT // @downloadURL none // ==/UserScript== //global variables const getURL = window.location.search.split("&"); const oro = parseInt(document.getElementById("sstat_gold_val").innerText.replace(/\./g, '')); var dobleClickEvent = document.createEvent('MouseEvents'); dobleClickEvent.initEvent('dblclick', true, true); let sh = { get : ()=>{ for (let element of getURL) { if(element.includes("sh") == true){ return element; } } } } class GladiatusTools{ static SetTool(){ const mainMenu = document.getElementById("mainmenu"); if (getURL[0] == "?mod=guildMarket" && getURL[1] != "submod=control") { Mercado.Run(); } else if (getURL[0] == "?mod=guildMarket" && getURL[1] == "submod=control") { //comming soon } else if (getURL[0] == "?mod=auction") { AcutionHouseTools(); } else if (getURL[0] == "?mod=forge" && getURL[1] == "submod=smeltery") { SmelteryTimeSaverExtension(); } else if (getURL[0] == "?mod=forge" && getURL[1] == "submod=forge") { Herreria(); }else if(getURL[0] == "?mod=packages"){ Paquetes.UI(); Paquetes.MoverFiltros(); Paquetes.ExtendsInput(); } } static Run(){ Menu.Dibujar(); GladiatusTools.SetTool(); Notificaciones.Rotativos(); GuardarOro.Run(); ExtenderBotones.Paquetes(); window.addEventListener("load", () => { localStorage.TimeSaverExist = TimeSaver.Exist(); TimeSaver.setKeyForStop(JSON.parse(localStorage.TimeSaverExist)); TimeSaver.StopOnKey(); }); } } class insertOnPage{ // Antes que el propio elemento. static beforebegin(object, html){ object.insertAdjacentHTML("beforebegin", html); } //Justo dentro del elemento, antes de su primer elemento hijo. static afterbegin(object, html){ object.insertAdjacentHTML("afterbegin", html); } //Justo dentro del elemento, después de su último elemento hijo. static beforeend(object, html){ object.insertAdjacentHTML("beforeend", html); } //Después del propio elemento. static afterend(object, html){ object.insertAdjacentHTML("afterend", html); } } class Observer{ static ForRemovedNodes(ItemForWait, instructions){ const observer = new MutationObserver((mutationList) => { mutationList.forEach((mutation)=> { if(mutation.removedNodes.length){ instructions(); } }) }); // Opcions para el observer const observerOptions = { attributes: true, childList: true, subtree: true, characterData: false, attributeOldValue: false, characterDataOldValue: false }; observer.observe(ItemForWait, observerOptions); } } class Formatter{ static abbreviateNumber(number){ var SI_SYMBOL = ["", "k", "kk", "kkk", "kkkk", "kkkkk", "kkkkkk"]; // what tier? (determines SI symbol) var tier = Math.log10(Math.abs(number)) / 3 | 0; // if zero, we don't need a suffix if(tier == 0) return number; // get suffix and determine scale var suffix = SI_SYMBOL[tier]; var scale = Math.pow(10, tier * 3); // scale the number var scaled = number / scale; // format number and add suffix return scaled.toFixed(1) + suffix; } } class Menu{ static Dibujar(){ document.body.insertAdjacentHTML("afterbegin",` `); let menuOpen = document.getElementById("MenuOpen"); menuOpen.addEventListener("click", Menu.openNav); menuOpen.addEventListener("touchstart",Menu.openNav); let closeMenu = document.getElementById("CloseMenu"); closeMenu.addEventListener("click", Menu.closeNav); } static openNav() { document.getElementById("menuSidenav").style.display = "block"; } static closeNav() { document.getElementById("menuSidenav").style.display = "none"; } static addConfig(html){ html+= "
" insertOnPage.beforeend(document.getElementById("menuContent"),html); } } class Notificaciones{ static Rotativos(){ Menu.addConfig(`

Notificaciones

`); let MontosNotificar = document.getElementById("MontosNotificar"); let InputNotificarOro = document.getElementById("InputNotificarOro"); let MontosGuardados = []; if(localStorage.MontosGuardados == undefined){ localStorage.MontosGuardados = '["100000"]'; }else{ MontosGuardados = JSON.parse(localStorage.MontosGuardados) } InputNotificarOro.addEventListener("keypress",(input)=>{ if (input.key === 'Enter') { if (!MontosGuardados.includes(InputNotificarOro.value) && InputNotificarOro.value != "") { MontosGuardados.push(InputNotificarOro.value); InputNotificarOro.value = ""; localStorage.MontosGuardados = JSON.stringify(MontosGuardados.sort(function(a, b){return a - b})); window.location.reload() } } }); let NotificarOro = document.getElementById("NotificarOro"); //.checked indica si está activo o no if (localStorage.NotificarOro == undefined) { localStorage.NotificarOro = NotificarOro.checked } else { NotificarOro.checked = JSON.parse(localStorage.NotificarOro); } NotificarOro.addEventListener("change", () => { localStorage.NotificarOro = NotificarOro.checked; }) if (JSON.parse(localStorage.NotificarOro) == true) { Notificaciones.Mensaje(); Notificaciones.MostrarRotativosSeleccionados(); Notificaciones.EliminarRotativo(); } } static Mensaje(){ let MontosGuardados = JSON.parse(localStorage.MontosGuardados); let mensaje = ""; for(let monto of MontosGuardados){ if (Math.floor(oro / monto) >= 2) { mensaje += `Empaqueta ` + Math.floor(oro / monto) + ` rotativos de `+ Formatter.abbreviateNumber(monto)+`\n`; } else if (Math.floor(oro / monto) == 1) { mensaje += `Empaqueta ` + Math.floor(oro / monto) + ` rotativo de `+ Formatter.abbreviateNumber(monto)+`\n`; } } if (mensaje != "") { document.getElementById("mmonetbar").insertAdjacentHTML("beforeend",`
` + mensaje + `
`); } } static MostrarRotativosSeleccionados(){ let MontosGuardados = JSON.parse(localStorage.MontosGuardados); let indiceDeRotativoBorrar; let MontosNotificar = document.getElementById("MontosNotificar"); let contador = 0; for(let monto of MontosGuardados){ insertOnPage.beforeend(MontosNotificar,`
`+Formatter.abbreviateNumber(monto)+`
`) contador++; } } static EliminarRotativo(){ let MontosGuardados = JSON.parse(localStorage.MontosGuardados); let NotificaRotativoBorrar = document.getElementsByName("NotificaRotativoBorrar") for (let boton of NotificaRotativoBorrar) { boton.addEventListener("click",()=>{ MontosGuardados.splice(boton.attributes[1].value,1) localStorage.MontosGuardados = JSON.stringify(MontosGuardados.sort(function(a, b){return a - b})); window.location.reload() }) boton.addEventListener("touchstart",()=>{ MontosGuardados.splice(boton.attributes[1].value,1) localStorage.MontosGuardados = JSON.stringify(MontosGuardados.sort(function(a, b){return a - b})); window.location.reload() }) } } } class Mercado{ static Config(){ Menu.addConfig(`

Mercado de la Alianza

`); let MercadoAlianza = document.getElementById("MercadoAlianza"); let InputMercadoAlianza = document.getElementById("InputMercadoAlianza"); let MontosMercado = []; if(localStorage.MontosMercado == undefined){ localStorage.MontosMercado = '["100000"]'; }else{ MontosMercado = JSON.parse(localStorage.MontosMercado) } InputMercadoAlianza.addEventListener("keypress",(input)=>{ if (input.key === 'Enter') { if (!MontosMercado.includes(InputMercadoAlianza.value) && InputMercadoAlianza.value != "") { MontosMercado.push(InputMercadoAlianza.value); InputMercadoAlianza.value = ""; localStorage.MontosMercado = JSON.stringify(MontosMercado.sort(function(a, b){return a - b})); window.location.reload() } } }); } static MostrarRotativosSeleccionados(){ let MontosMercado = JSON.parse(localStorage.MontosMercado); let indiceDeRotativoBorrar; let MercadoAlianza = document.getElementById("MercadoAlianza"); let contador = 0; for(let monto of MontosMercado){ insertOnPage.beforeend(MercadoAlianza,`
`+Formatter.abbreviateNumber(monto)+`
`) contador++; } } static EliminarRotativo(){ let MontosMercado = JSON.parse(localStorage.MontosMercado); let NotificaRotativoBorrar = document.getElementsByName("MercadoRotativoBorrar") for (let boton of NotificaRotativoBorrar) { boton.addEventListener("click",()=>{ MontosMercado.splice(boton.attributes[1].value,1) localStorage.MontosMercado = JSON.stringify(MontosMercado.sort(function(a, b){return a - b})); window.location.reload() }) boton.addEventListener("touchstart",()=>{ MontosMercado.splice(boton.attributes[1].value,1) localStorage.MontosMercado = JSON.stringify(MontosMercado.sort(function(a, b){return a - b})); window.location.reload() }) } } static VentaRapida(){ let panelVenta = document.getElementById("sellForm"); let inputPrecio = document.getElementById("preis"); let inputDuracion = document.getElementById("dauer"); let botonVender = document.getElementsByName("anbieten")[0]; let marketInventory = document.getElementById("market_inventory"); let oro = parseFloat(document.getElementById("sstat_gold_val").textContent); let cajaVenta = document.getElementsByClassName("ui-droppable")[0]; let contentItem = document.getElementsByClassName("contentItem")[0]; insertOnPage.afterbegin(contentItem,`

Venta Rapida

Coloca un item y elige el precio para vender.

`); insertOnPage.beforebegin(panelVenta,`
`); let MontosMercado = JSON.parse(localStorage.MontosMercado); let ventaRapidaMenu = document.getElementById("VentaRapidaMenu"); for(let monto of MontosMercado){ insertOnPage.beforeend(ventaRapidaMenu,` `) }; insertOnPage.beforeend(ventaRapidaMenu,`
Elegir duración
`); let selectHora = document.getElementById("SelectHora"); if (localStorage.SelectHora == undefined) { localStorage.SelectHora = 1; selectHora.value = 1; } else { selectHora.value = localStorage.SelectHora; } selectHora.addEventListener("change", (event) => { localStorage.SelectHora = selectHora.value; }); let ventaRapidaMenuTitle = document.getElementById("VentaRapidaMenuTitle"); ventaRapidaMenuTitle.addEventListener("click", () => { if (ventaRapidaMenu.style.display == "none") { ventaRapidaMenu.style.display = "block"; } else { ventaRapidaMenu.style.display = "none"; } }); ventaRapidaMenuTitle.addEventListener("touchstart",()=>{ if (ventaRapidaMenu.style.display == "none") { ventaRapidaMenu.style.display = "block"; } else { ventaRapidaMenu.style.display = "none"; } }); let BotononesVender = document.getElementsByName("BotonVender") for (let boton of BotononesVender) { boton.addEventListener("click",()=>{ inputPrecio.value = boton.attributes[1].value; inputDuracion.value = localStorage.SelectHora; botonVender.click(); }) boton.addEventListener("touchstart",()=>{ inputPrecio.value = boton.attributes[1].value; inputDuracion.value = localStorage.SelectHora; botonVender.click(); }) } } static Comprar(){ let CompraTodo = document.getElementById("CompraTodo"); let TipoCompra = document.getElementById("TipoCompra"); let MontosMercado = JSON.parse(localStorage.MontosMercado); if (localStorage.TipoCompra == undefined) { localStorage.TipoCompra = 0; } else { TipoCompra.selectedIndex = localStorage.TipoCompra; } TipoCompra.addEventListener("change", (event) => { localStorage.TipoCompra = TipoCompra.selectedIndex; }); let marketTableChildren = document.getElementById("market_table").children[0].children[0].children let marketItems = []; for (let item of marketTableChildren) { if(item.tagName == "TR" && item.children[0].tagName == "TD" && item.children[1].children[0].children[0].style.color == "green"){ if(MontosMercado.includes(item.children[2].innerText.replace(/\./g, ''))){ marketItems.push(item) } } } CompraTodo.addEventListener("click",()=>{ switch(TipoCompra.selectedIndex){ case 0 : Mercado.Mayor_Menor(marketItems); break; case 1: Mercado.Menor_Mayor(marketItems); break default: console.error("No se pudo procesar la compra"); break; } }) } static Mayor_Menor(marketItems){ let aux = marketItems[0].children[2].innerText.replace(/\./g, '') let oro = parseInt(document.getElementById("sstat_gold_val").textContent.replace(/\./g, '')); let orden = [] for (let item of marketItems) { if(item.children[2].innerText.replace(/\./g, '') >= aux){ orden.unshift(item) } aux = item.children[2].innerText.replace(/\./g, ''); } for (let item of orden){ let valor = parseInt(item.children[2].innerText.replace(/\./g, '')) //; //console.log(item.children[2].innerText.replace(/\./g, '')) if(valor < oro){ item.children[5].children[0].click(); oro = oro - valor; } } } static Menor_Mayor(marketItems){ let aux = marketItems[0].children[2].innerText.replace(/\./g, '') let oro = parseInt(document.getElementById("sstat_gold_val").textContent.replace(/\./g, '')); let orden = [] for (let item of marketItems) { if(item.children[2].innerText.replace(/\./g, '') >= aux){ orden.push(item) } aux = item.children[2].innerText.replace(/\./g, ''); } for (let item of orden){ let valor = parseInt(item.children[2].innerText.replace(/\./g, '')) //; //console.log(item.children[2].innerText.replace(/\./g, '')) if(valor < oro){ item.children[5].children[0].click(); oro = oro - valor; } } } static Run(){ Mercado.Config(); Mercado.MostrarRotativosSeleccionados(); Mercado.EliminarRotativo(); Mercado.VentaRapida(); Mercado.Comprar(); } } function AcutionHouseTools() { let item = document.getElementsByTagName("TD"); let oro = parseInt(document.getElementById("sstat_gold_val").textContent.replace(/\./g, '')); let menu = document.getElementsByClassName("section-header")[1]; menu.insertAdjacentHTML( "beforebegin", ` ` ); let SectionMenuCompra = document.getElementById("MenuCompra"); /* SectionMenuCompra.insertAdjacentHTML('beforeend', `

Indica un precio máximo para comprar o compra todo lo que te alcance.

No se sobrepujará a los compañeros de alianza.

`); */ SectionMenuCompra.insertAdjacentHTML( "beforeend", `

Se comprará todo lo que alcance con el oro que tienes.

No se sobrepujará a los compañeros de alianza.

` ); SectionMenuCompra.insertAdjacentHTML( "beforeend", ` ` ); SectionMenuCompra.insertAdjacentHTML( "beforeend", ` ` ); let oroMaximo = document.getElementById("OroMaximo"); let botonComprar = document.getElementById("BotonComprar"); oroMaximo.addEventListener("input", () => { if (oroMaximo.value.length > 0) { botonComprar.title = "Se comprara la comida que alcance con: " + oroMaximo.value + " 🥇"; botonComprar.innerHTML = "\n Comprar \n"; } else if (oroMaximo.value.length == 0) { botonComprar.title = "Se comprará toda la comida que alcance con el oro que tengas"; botonComprar.innerHTML = "\n Comprar todo\n"; } }); botonComprar.addEventListener("click", () => { if (oroMaximo.value.length > 0) { //Proximamente } else if (oroMaximo.value.length == 0) { for (let isItem = 0; isItem < item.length; isItem++) { if(item[isItem].hasAttribute("width")==true){ let auction_bid_div = item[isItem].children[1].children[0].children[7].children; let auction_item_div = item[isItem].children[1].children[0].children[6].children[1].children[0]; let itemSplit = auction_item_div.attributes[6].textContent.substring(4,9); //console.log(auction_bid_div[2]); let costo = parseInt(auction_bid_div[2].value); if (costo < oro) { oro = oro - costo; //console.log(oro," - ",costo) let PujaDeAlguien; if ( auction_bid_div[0].innerText.split("\n")[0] == "No hay pujas." || auction_bid_div[0].innerText.split("\n")[0] == "Ya hay pujas existentes." ) { //items[i].children[3].click(); if(itemSplit != "Pollo"){ auction_bid_div[3].click(); } } } } } } }); botonComprar.addEventListener("touchstart",()=>{ if (oroMaximo.value.length > 0) { //Proximamente } else if (oroMaximo.value.length == 0) { for (let isItem = 0; isItem < item.length; isItem++) { if(item[isItem].hasAttribute("width")==true){ let auction_bid_div = item[isItem].children[1].children[0].children[7].children; let auction_item_div = item[isItem].children[1].children[0].children[6].children[1].children[0]; let itemSplit = auction_item_div.attributes[6].textContent.substring(4,9); //console.log(auction_bid_div[2]); let costo = parseInt(auction_bid_div[2].value); if (costo < oro) { oro = oro - costo; //console.log(oro," - ",costo) let PujaDeAlguien; if ( auction_bid_div[0].innerText.split("\n")[0] == "No hay pujas." || auction_bid_div[0].innerText.split("\n")[0] == "Ya hay pujas existentes." ) { //items[i].children[3].click(); if(itemSplit != "Pollo"){ auction_bid_div[3].click(); } } } } } } }); let menuCompraTitle = document.getElementById("MenuCompraTitle"); menuCompraTitle.addEventListener("click", () => { if (SectionMenuCompra.style.display == "none") { SectionMenuCompra.style.display = "block"; } else { SectionMenuCompra.style.display = "none"; } }); } function SmelteryTimeSaverExtension() { let inv = document.getElementById("inv") window.addEventListener("load", () => { if (document.getElementsByClassName("smelter-actions")[0] != undefined) { let inventario = document.getElementsByClassName("smelter-actions")[0]; let items = document.getElementsByClassName("ui-draggable"); let btnFundicion = FindBtn("Iniciar función"); let btnGuardarRecursos = FindBtn("Enviar todo a Horreum"); let mensaje = document.getElementsByClassName("gts-error-message")[0]; inventario.insertAdjacentHTML( "beforeend", ` Acciones Rapidas
Selecciona un inventario para fundir
` ); let selectInventario = document.getElementById("SelectInventario"); if (localStorage.selectInventario == undefined) { localStorage.selectInventario = selectInventario.selectedIndex } else { selectInventario.selectedIndex = localStorage.selectInventario; } selectInventario.addEventListener("change", () => { localStorage.selectInventario = selectInventario.selectedIndex; }) let inventoryTabs = document.getElementsByClassName("awesome-tabs"); let inventorySelected; for (let index = 4; index < inventoryTabs.length; index++) { if (inventoryTabs[index].text == localStorage.InventarioFundicion) { inventorySelected = inventoryTabs[index]; } } if(localStorage.GuardarRecursos == undefined){ localStorage.GuardarRecursos = false; } const observer = new MutationObserver((mutationList) => { mutationList.forEach((mutation)=> { if(mutation.removedNodes.length){ if(JSON.parse(localStorage.GuardarRecursos) == true){ inventorySelected.click(); btnFundicion.click(); for (let index = 9; index < items.length; index++) { items[index].click(); } localStorage.GuardarRecursos = false; } } }) }); // Opcions para el observer const observerOptions = { attributes: true, childList: true, subtree: true, characterData: false, attributeOldValue: false, characterDataOldValue: false }; observer.observe(inv, observerOptions); if(JSON.parse(localStorage.GuardarRecursos) == true){ inventorySelected.click(); btnFundicion.click(); for (let index = 9; index < items.length; index++) { items[index].click(); } localStorage.GuardarRecursos = false; } let GuardarFundir = document.getElementById("GuardarFundir"); GuardarFundir.addEventListener("click", () => { localStorage.GuardarRecursos = true; btnGuardarRecursos.click(); }); let fundirTodo = document.getElementById("FundirTodo"); fundirTodo.addEventListener("click",()=>{ inventorySelected.click(); btnFundicion.click(); for (let index = 9; index < items.length; index++) { items[index].click(); } }); mensaje.addEventListener("DOMNodeInserted", () => { window.location.reload(); }, false); } else { console.log("time saver extension not installed"); } }); function FindBtn(textContent) { let elements = document.getElementsByClassName("awesome-button"); let elementsArray = [].slice.call(elements); for (let index = 0; index < elementsArray.length; index++) { let element = elementsArray[index]; if (element.textContent === textContent) { return element; } } } function Observer(observar){ let observerReturn = [[],[]] const observer = new MutationObserver((mutationList) => { mutationList.forEach((mutation)=> { if(mutation.addedNodes.length){ observerReturn[0].push(mutation.addedNodes[0]); } if(mutation.removedNodes.length){ observerReturn[1].push(mutation.removedNodes[0]); } //console.log(mutation.type); }) }); // Opcions para el observer const observerOptions = { attributes: true, childList: true, subtree: true, characterData: false, attributeOldValue: false, characterDataOldValue: false }; observer.observe(observar, observerOptions); return observerReturn; } } function Herreria(){ /*let selectPrefix0 = document.getElementById("prefix0") selectPrefix0.hidden; selectPrefix0.insertAdjacentHTML("beforebegin",``); let inputPrefix = document.getElementById("inputPrefix"); inputPrefix.setAttribute("onkeyup",selectPrefix0.attributes.onkeyup.textContent); inputPrefix.setAttribute("onchange",selectPrefix0.attributes.onchange.textContent); let prefixList = document.getElementById("prefixList"); let prefijos = [[],[],[],[]] let prefijosOptgroup = document.getElementsByTagName("optgroup")[0].children for (let index = 0; index < prefijosOptgroup.length; index++) { prefijos[0].push(prefijosOptgroup[index].text) prefijos[1].push(prefijosOptgroup[index].value) prefijos[2].push(prefijosOptgroup[index].attributes["data-level"].textContent); prefijos[2].push(prefijosOptgroup[index].attributes["data-name"].textContent); } for (let index = 0; index < prefijos[0].length; index++) { var option = document.createElement('option'); option.value = prefijos[0][index]; option.setAttribute("data_value",prefijos[1][index]); prefixList.appendChild(option); } inputPrefix.addEventListener("change",()=>{ selectPrefix0.selectedIndex = prefijos[0].indexOf(inputPrefix.value); selectPrefix0.value = prefijos[1][prefijos[0].indexOf(inputPrefix.value)]; });*/ } class Paquetes { static filtros(){ let inputQry = document.getElementsByName("qry"); inputQry[0].setAttribute("list","customSearch"); inputQry[0].insertAdjacentHTML("afterend", ``); /*let GladiatusToolsMenu = document.getElementById("GladiatusToolsMenu"); GladiatusToolsMenu.insertAdjacentHTML("beforeend",` `);*/ } static UI(){ let inventoryBox = document.getElementsByClassName("inventoryBox")[0]; insertOnPage.afterbegin(inventoryBox,`
`) let buscarRotativos = document.getElementById("buscarRotativos"); let categoria = document.getElementById("categoria"); buscarRotativos.addEventListener("click",()=>{ Paquetes.PonerEnFavoritos(categoria.value) }) buscarRotativos.addEventListener("touchstart",()=>{ Paquetes.PonerEnFavoritos(categoria.value) }) if(localStorage.paquetesCategoria == undefined){ localStorage.paquetesCategoria = "Mercado"; }else{categoria.value = localStorage.paquetesCategoria} categoria.addEventListener("change",()=>{localStorage.paquetesCategoria = categoria.value}); } static PonerEnFavoritos(textContent){ let MercadoFavoritos = document.getElementById("MercadoFavoritos"); let rotativos = Paquetes.EncontrarRotativos(textContent); MercadoFavoritos.style.display = "block"; MercadoFavoritos.innerHTML = `

`; let mensaje = document.getElementById("mensaje"); if (rotativos.length > 0){ mensaje.innerText = "Objetos Encontrados!"; for (let item of rotativos) { MercadoFavoritos.append(item) } } else {mensaje.innerHTML = `
No se encontraron objetos, intenta nuevamente.

`;} } static EncontrarRotativos(textContent){ let rotativos = [] let packages = document.getElementById("packages"); //packages.children[1].children[2].children[0].attributes[6].textContent.includes("Oro") for (let item of packages.children) { if(!!item.children[1] == true && item.children[1].textContent == textContent ){ let atributes = item.children[2].children[0].attributes; for (let atribute of atributes) { if(atribute.name == "data-tooltip"){ if(atribute.textContent.includes('Oro","white"') == false){ rotativos.push(item) } } } } } return rotativos } static MoverFiltros(){ let filtros = document.getElementsByClassName("package-advance-filters")[0]; filtros.setAttribute("style","width: 500px;margin-left: auto;") let article = document.getElementsByTagName("article")[0]; let sectionHeaders = document.getElementsByClassName("section-header") for (let section of sectionHeaders) { if(section.innerHTML.includes("Paquetes")==true){ article.insertBefore(filtros,section) } } } static ExtendsInput(){ let qry = document.getElementsByName("qry")[0]; qry.setAttribute("list","Busqueda"); qry.type = "search" insertOnPage.afterend(qry,``); Menu.addConfig(`

Paquetes

`); let InputNombres = document.getElementById("InputNombres"); let NombresGuardados = []; if(localStorage.NombresGuardados == undefined){ localStorage.NombresGuardados = '[]'; }else{ NombresGuardados = JSON.parse(localStorage.NombresGuardados) } InputNombres.addEventListener("keypress",(input)=>{ if (input.key === 'Enter') { if (!NombresGuardados.includes(InputNombres.value) && InputNombres.value != "") { NombresGuardados.push(InputNombres.value); InputNombres.value = ""; localStorage.NombresGuardados = JSON.stringify(NombresGuardados.sort()); window.location.reload() } } }); Paquetes.MostrarNombresSeleccionados(); Paquetes.addOptionsToDatalist(); Paquetes.Eliminar(); } static MostrarNombresSeleccionados(){ let NombresGuardados = JSON.parse(localStorage.NombresGuardados); let indiceDeRotativoBorrar; let ListaNombres = document.getElementById("ListaNombres"); let contador = 0; for(let nombre of NombresGuardados){ insertOnPage.beforeend(ListaNombres,`
`+nombre+`
`) contador++; } } static Eliminar(){ let NombresGuardados = JSON.parse(localStorage.NombresGuardados); let NombreBorrar = document.getElementsByName("NombreBorrar") for(let boton of NombreBorrar) { boton.addEventListener("click",()=>{ NombresGuardados.splice(boton.attributes[1].value,1); localStorage.NombresGuardados = JSON.stringify(NombresGuardados.sort()); window.location.reload(); }) boton.addEventListener("touchstart",()=>{ NombresGuardados.splice(boton.attributes[1].value,1) localStorage.NombresGuardados = JSON.stringify(NombresGuardados.sort()); window.location.reload() }) } } static addOptionsToDatalist(){ let NombresGuardados = JSON.parse(localStorage.NombresGuardados); let Busqueda = document.getElementById("Busqueda"); for(let nombre of NombresGuardados){ insertOnPage.beforeend(Busqueda,``) } } } //style="width: 500px;margin-left: auto;" class TimeSaver{ static Exist(){ const timeSaverr = !!document.getElementsByClassName("auto-settings")[0] return timeSaverr; } static setKeyForStop(timeSaverExist){ if(timeSaverExist==true){ Menu.addConfig(`

TimeSaver

`); let timeSaverHotKeySelectedKey = document.getElementById("timeSaverHotKeySelectedKey"); let timeSaverHotKeyCheckbox = document.getElementById("timeSaverHotKeyCheckbox"); let timeSaverHotKeyConfirmation = document.getElementById("timeSaverHotKeyConfirmation"); let Btnconfirmar = document.getElementById("Btnconfirmar"); Btnconfirmar.addEventListener("click",()=>{Btnconfirmar.textContent = ""; timeSaverHotKeyConfirmation.hidden = false;}); if(localStorage.timeSaverHotKeyCheckbox == undefined){ localStorage.timeSaverHotKeyCheckbox = false; } else { timeSaverHotKeyCheckbox.checked = JSON.parse(localStorage.timeSaverHotKeyCheckbox); } timeSaverHotKeyCheckbox.addEventListener("change",()=>{localStorage.timeSaverHotKeyCheckbox=timeSaverHotKeyCheckbox.checked;}) if(localStorage.timeSaverHotKeySelectedKey == undefined){ localStorage.timeSaverHotKeySelectedKey = ""; } else { timeSaverHotKeySelectedKey.value = localStorage.timeSaverHotKeySelectedKey; } timeSaverHotKeySelectedKey.addEventListener("keydown",()=>{timeSaverHotKeySelectedKey.select(); Btnconfirmar.textContent = "✅"; }) timeSaverHotKeySelectedKey.addEventListener("change",()=>{localStorage.timeSaverHotKeySelectedKey = timeSaverHotKeySelectedKey.value;}) } } static StopOnKey(){ document.addEventListener('keyup', (e)=>{ let selectKey = localStorage.timeSaverHotKeySelectedKey; let useControl = JSON.parse(localStorage.timeSaverHotKeyCheckbox); if (useControl == true && e.ctrlKey && e.key === selectKey) { TimeSaver.StopBot(); } if (useControl == false && e.key === selectKey) { TimeSaver.StopBot(); } }, false); } static StopBot(){ let timeSaver = document.getElementsByClassName("auto-settings")[0] let botonPlay = timeSaver.children[3]; if (botonPlay.classList[2] == "show") { //bot desactivado botonPlay.click(); } } } class ExtenderBotones{ static Paquetes(){ let menue_packages = document.getElementById("menue_packages"); let url = window.location.search.split("&"); insertOnPage.afterend(menue_packages,` `); let menuBotonPaquetes = document.getElementById("menuBotonPaquetes"); let extenderPaquetes = document.getElementById("extenderPaquetes"); let menuAbierto = false; extenderPaquetes.addEventListener("click",()=>{ menuAbierto = !menuAbierto; if(menuAbierto == true){ menuBotonPaquetes.style.display = 'block'; } else { menuBotonPaquetes.style.display = 'none'; } }) extenderPaquetes.addEventListener("touchstart",()=>{ menuAbierto = !menuAbierto; if(menuAbierto == true){ menuBotonPaquetes.style.display = 'block'; } else { menuBotonPaquetes.style.display = 'none'; } }) } } class GuardarOro{ static UI(){ Menu.addConfig(`

Guardar Oro

`); let GuardarOroCheck = document.getElementById("GuardarOroCheck"); ; let TipoDeGuardado = document.getElementById("TipoDeGuardado") if (localStorage.GuardarOroCheck == undefined) { localStorage.GuardarOroCheck = GuardarOroCheck.checked } else { GuardarOroCheck.checked = JSON.parse(localStorage.GuardarOroCheck); } GuardarOroCheck.addEventListener("change", () => { localStorage.GuardarOroCheck = GuardarOroCheck.checked; }) if (localStorage.TipoDeGuardado == undefined) { localStorage.TipoDeGuardado = TipoDeGuardado.selectedIndex } else { TipoDeGuardado.selectedIndex = localStorage.TipoDeGuardado; } TipoDeGuardado.addEventListener("change", () => { localStorage.TipoDeGuardado = TipoDeGuardado.selectedIndex; location.reload(); }) if(TipoDeGuardado.selectedIndex == 0 || TipoDeGuardado.selectedIndex == 1){ insertOnPage.afterend(TipoDeGuardado,`