NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Lok Drago Details // @namespace // @version 1.0 // @match https://www.leagueofkingdoms.com/drago/detail/* // @match https://tofunft.com/collection/drago/* // @match https://tofunft.com/discover/items?contracts=76175* // @match https://tofunft.com/user/* // @match https://opensea.io/collection/lokdrago-polygon/* // @require https://code.jquery.com/jquery-3.6.0.min.js // @grant GM_setClipboard // @license MIT // ==/UserScript== document.addEventListener('keydown', e => { if (e.code === 'KeyD' && e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) { const hoveredLink = document.querySelector('a:hover'); if (hoveredLink) { const linkURL = hoveredLink.href; const linkText = hoveredLink.textContent; const myLink = `<a href="${linkURL}" target="dragostats">${linkText}</a>`; console.log(linkURL); // Copy the link to the clipboard GM_setClipboard(myLink, 'text'); // Open the link in a new window with the target "dragostats" const url = new URL(linkURL); const id = url.pathname.split("/").pop(); const newWindow = window.open(`https://www.leagueofkingdoms.com/drago/detail/${id}`, 'dragostats'); } } }); async function getOwnerEth(tokenId) { const address = '0xab226c1d6a4362423405816851748f1f866f5583'; const options = { method: 'GET', headers: { accept: 'application/json' } }; let response = await fetch('https://eth-mainnet.g.alchemy.com/nft/v3/kqGz32epjZ7ZaIIIXeKunPNzxU3FJRjP/getOwnersForNFT?contractAddress=' + address + '&tokenId=' + tokenId, options); let res = await response.json(); const owner = res.owners[0]; return owner; } async function getOwnerPolygon(tokenId) { const address = '0x9E8Ea82e76262E957D4cC24e04857A34B0D8f062'; const options = { method: 'GET', headers: { accept: 'application/json' } }; let response = await fetch('https://polygon-mainnet.g.alchemy.com/nft/v3/ADNI3KNVzuSD2zqo0-6igzEyLz5kMDwy/getOwnersForNFT?contractAddress=' + address + '&tokenId=' + tokenId, options); let res = await response.json(); const owner = res.owners[0]; return owner; } let processedIds = []; (async function() { 'use strict'; let id; if (window.location.href.startsWith('https://www.leagueofkingdoms.com/drago/detail')) { // Get the ID from the URL const url = new URL(window.location.href); id = url.pathname.split("/").pop(); } if (typeof id !== 'undefined') { const statsResponse = await fetch("https://lok-nft.leagueofkingdoms.com/api/market/detail", { "headers": { "accept": "application/json, text/plain, */*", "accept-language": "fr,en;q=0.9", "content-type": "application/json;charset=UTF-8", "sec-ch-ua": "\"Google Chrome\";v=\"113\", \"Chromium\";v=\"113\", \"Not-A.Brand\";v=\"24\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"Windows\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-site" }, "referrer": "https://marketplace.leagueofkingdoms.com/", "referrerPolicy": "strict-origin-when-cross-origin", "body": `{\"tokenId\":\"${id}\",\"address\":\"\"}`, "method": "POST", "mode": "cors", "credentials": "omit" }); const stats = await statsResponse.json(); let wowner = '' wowner = await getOwnerPolygon(id) if (wowner == '') { wowner = await getOwnerEth(id) } let wallet = '' if (wowner != '') { wallet = wowner } else { wallet = stats.drago.owner } if (stats.drago?.owner != undefined) { } else { jQuery('div.category_line').html(` ID: incorrect`); return } const inventoryResponse = await fetch("https://lok-nft.leagueofkingdoms.com/api/drago/inventory", { "headers": { "accept": "application/json, text/plain, */*", "accept-language": "fr,en;q=0.9", "content-type": "application/json;charset=UTF-8", "sec-ch-ua": "\"Google Chrome\";v=\"113\", \"Chromium\";v=\"113\", \"Not-A.Brand\";v=\"24\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"Windows\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "cross-site" }, "referrer": "https://drago.defuraai.repl.co/", "referrerPolicy": "strict-origin-when-cross-origin", "body": `{\"address\":\"${wallet}\",\"includeRent\":true}`, "method": "POST", "mode": "cors", "credentials": "omit" }); const inventory = await inventoryResponse.json(); let xp = 'Unknown'; let breed = 'Unknown'; let fusion = 'Unknown'; let lvl = 'Unknown'; let grade = 'Unknown';; let parents = 'Unknown'; if (inventory.myDragos.length != 0) { for (let drago in inventory.myDragos) { if (inventory.myDragos[drago].tokenId == id) { xp = inventory.myDragos[drago].xp lvl = inventory.myDragos[drago].level breed = inventory.myDragos[drago].breed if (inventory.myDragos[drago]?.grade) { grade = inventory.myDragos[drago].grade } fusion = inventory.myDragos[drago].fusion parents = inventory.myDragos[drago].parents break } } jQuery('div.category_line').html(` ID: ${id} - lvl: ${lvl} - xp: ${xp} - Breed: ${breed} - fusion: ${fusion} - parents: ${parents}`); } } async function processPElements() { let timedelay = 0 const pElements = $('p.chakra-text.css-e1irop'); for (let i = 0; i < pElements.length; i++) { const pElement = $(pElements[i]); const id = pElement.text().match(/\d+/)[0]; if (processedIds.includes(id)) { continue; // skip this iteration if the ID has already been processed } processedIds.push(id); // add the ID to the processedIds array setTimeout(async () => { const statsResponse = await fetch("https://lok-nft.leagueofkingdoms.com/api/market/detail", { "headers": { "accept": "application/json, text/plain, */*", "accept-language": "fr,en;q=0.9", "content-type": "application/json;charset=UTF-8", "sec-ch-ua": "\"Google Chrome\";v=\"113\", \"Chromium\";v=\"113\", \"Not-A.Brand\";v=\"24\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"Windows\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-site" }, "referrer": "https://marketplace.leagueofkingdoms.com/", "referrerPolicy": "strict-origin-when-cross-origin", "body": `{\"tokenId\":\"${id}\",\"address\":\"\"}`, "method": "POST", "mode": "cors", "credentials": "omit" }); const stats = await statsResponse.json(); let wowner = ''; wowner = await getOwnerPolygon(id); if (wowner == '') { wowner = await getOwnerEth(id); } let wallet = ''; if (wowner != '') { wallet = wowner; } else { wallet = stats.drago.owner; } if (stats.drago?.owner != undefined) { // do nothing } else { jQuery('div.category_line').html(` ID: incorrect`); return } const inventoryResponse = await fetch("https://lok-nft.leagueofkingdoms.com/api/drago/inventory", { "headers": { "accept": "application/json, text/plain, */*", "accept-language": "fr,en;q=0.9", "content-type": "application/json;charset=UTF-8", "sec-ch-ua": "\"Google Chrome\";v=\"113\", \"Chromium\";v=\"113\", \"Not-A.Brand\";v=\"24\"", "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": "\"Windows\"", "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "cross-site" }, "referrer": "https://drago.defuraai.repl.co/", "referrerPolicy": "strict-origin-when-cross-origin", "body": `{\"address\":\"${wallet}\",\"includeRent\":true}`, "method": "POST", "mode": "cors", "credentials": "omit" }); const inventory = await inventoryResponse.json(); let xp = 'Unknown'; let breed = 'Unknown'; let fusion = 'Unknown'; let lvl = 'Unknown'; let grade = 'Unknown';; let parents = 'Unknown'; let lvlxp=0;let levelxp=0;let xpp=0 if (inventory.myDragos.length != 0) { for (let drago in inventory.myDragos) { if (inventory.myDragos[drago].tokenId == id) { xp = inventory.myDragos[drago].xp lvl = inventory.myDragos[drago].level if (lvl >19) { lvl = "💥" + lvl } breed = inventory.myDragos[drago].breed if (inventory.myDragos[drago]?.grade) { grade = inventory.myDragos[drago].grade } fusion = inventory.myDragos[drago].fusion parents = inventory.myDragos[drago].parents let ilevel = lvl while (ilevel >= 2) { levelxp += ilevel * 4000 ilevel = ilevel - 1 } lvlxp = lvl * 4000 + 4000 levelxp = xp - levelxp xpp = Math.round(levelxp / lvlxp * 100) break } } } const existingDiv = pElement.next('.chakra-stack.css-ac088g'); let divElement; if (existingDiv.length) { // If it exists, replace its content divElement = existingDiv; divElement.html(`lvl: ${lvl} - xp: ${xpp}% - Breed: ${breed} - fusion: ${fusion} - parents: ${parents}`); } else { const divElement = $(`<div class="chakra-stack css-ac088g">lvl: ${lvl} - xp: ${xpp}% - Breed: ${breed} - fusion: ${fusion} - parents: ${parents}</div>`); pElement.after(divElement); } }, timedelay); timedelay=timedelay+300 } } const callback = function(mutationsList, observer) { processPElements(); }; const observer = new MutationObserver(callback); const config = { childList: true, subtree: true }; observer.observe(document.body, config); processPElements(); })();