您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds pet leveling info to your own profile page
当前为
// ==UserScript== // @name GazelleGames pet leveling info // @namespace v3rrrr82xk1c96vvo1c6 // @match https://gazellegames.net/user.php?id=* // @grant GM.getValue // @grant GM.setValue // @grant GM.deleteValue // @version 1.2.1 // @description Adds pet leveling info to your own profile page // @run-at document-start // @inject-into content // @license MIT // ==/UserScript== (async function () { "use strict"; const ownUserID = new Promise(async (resolve) => { const yourID = await GM.getValue("you"); if (yourID) { // Cached user ID resolve(yourID); } else { // Not cached, get it from page once it loads window.addEventListener("DOMContentLoaded", () => { const yourID = new URLSearchParams(document.body.querySelector("#nav_userinfo a.username").search).get("id"); GM.setValue("you", yourID); resolve(yourID); }); } }); const them = new URLSearchParams(location.search).get("id"); // Only runs on your own user page if (await ownUserID !== them) { return; } let apiKey = await GM.getValue("apiKey"); if (!apiKey) { if (!(apiKey = prompt("Please enter an API key with the 'Items' permission to use this script."))) { return; } GM.setValue("apiKey", apiKey); } const endpoint = `https://${location.host}/api.php?request=items&include_info=true&type=users_equipped`; const options = { method: "GET", mode: "same-origin", credentials: "omit", redirect: "error", referrerPolicy: "no-referrer", headers: { "X-API-Key": apiKey } }; const equipment = await (await fetch(endpoint, options)).json(); if (equipment.status !== "success") { if (equipment.status === 401) { GM.deleteValue("apiKey"); } return; } const pets = []; for (const equip of equipment.response) { const type = equip.item.equipType; if (type && String(type) === "18" && equip.experience && equip.experience > 0) { pets.push({ name: equip.item.name, xp: parseInt(equip.experience, 10), lv: parseInt(equip.level, 10), id: String(equip.itemid) }); } } if (!pets.length) return; const box = document.createElement("div"); const innerBox = document.createElement("div"); const list = document.createElement("ul"); box.className = "box_personal_history"; innerBox.className = "box"; list.className = "stats nobullet"; innerBox.innerHTML = '<div class="head colhead_dark">Pet Leveling</div>'; innerBox.append(list); box.append(innerBox); function totalXP(lv) { return Math.ceil((lv * lv * 625) / 9); } for (const pet of pets) { const li = document.createElement("li"); const li2 = document.createElement("li"); const li3 = document.createElement("li"); const shopLink = document.createElement("a"); const strong = document.createElement("strong"); li2.style.paddingLeft = li3.style.paddingLeft = "10px"; shopLink.href = `/shop.php?ItemID=${pet.id}`; shopLink.title = "Shop for this pet"; const nextLevel = pet.lv + 1; const missingXP = totalXP(nextLevel) - pet.xp; const days = Math.floor(missingXP / 24); const hours = missingXP % 24; let timeString = ""; if (days) { const s = (days === 1) ? "" : "s"; timeString += `${days} day${s}`; } if (hours) { const s = (hours === 1) ? "" : "s"; timeString += ` ${hours} hour${s}`; } else if (!timeString) { timeString = "0 hours"; // ??? } strong.append(pet.name); shopLink.append(strong); li.append(shopLink); li2.append(timeString); li3.append(`Level ${pet.lv} → ${nextLevel}`); list.append(li, li2, li3); } function insert() { document.getElementsByName("user_info")[0]?.insertAdjacentElement("afterend", box); } insert(); if (!box.isConnected) { window.addEventListener("DOMContentLoaded", insert); } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址