From 715ac4b50aad24278912974b002e555f3e5036e4 Mon Sep 17 00:00:00 2001 From: Clem <58120735+clemdotla@users.noreply.github.com> Date: Sun, 1 Mar 2026 23:02:04 +0100 Subject: [PATCH] Use DOM to detect DLC and skip Steam API call Checking the DOM for the purple DLC box then getting parentid/name using dom again. Skipping a full steam api call Starts line 5256 --- public/luatools.js | 55 ++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/public/luatools.js b/public/luatools.js index 1ab029d..68c7b1e 100644 --- a/public/luatools.js +++ b/public/luatools.js @@ -5252,42 +5252,35 @@ startPolling(appid); }; - // First check if it's a DLC - fetch('https://store.steampowered.com/api/appdetails?appids=' + appid + '&filters=basic') - .then(function (res) { - return res.json(); - }) - .then(function (data) { - if (data && data[appid] && data[appid].success && data[appid].data) { - const info = data[appid].data; - if (info.type === 'dlc' && info.fullgame && info.fullgame.appid) { - showDlcWarning(appid, info.fullgame.appid, info.fullgame.name); - return; - } - } - // Not a DLC (or failed to check), proceed with database check - return fetchGamesDatabase().then(function (db) { - try { - const key = String(appid); - const gameData = db && db[key] ? db[key] : null; - if (gameData && gameData.playable === 0) { - // warning modal - showLuaToolsPlayableWarning('This game may not work, support for it wont be given in our discord', function () { - continueWithAdd(); - }, function () { }); - } else { + // Check if this is a dlc + const isdlc = !!document.querySelector(".game_area_dlc_bubble"); + const parentdiv = document.querySelector('.glance_details a[href*="/app/"]') + + if (isdlc && parentdiv) { + const id = parseInt(parentdiv.href.match(/app\/(\d+)\//)?.[1] ?? "") + const name = parentdiv.innerText ?? "name not found"; + + showDlcWarning(appid, id, name); + } else { + // Not a dlc (or failed) ? Then continue normally + return fetchGamesDatabase().then(function (db) { + try { + const gameData = db?.[String(appid)] ?? null; + if (gameData?.playable === 0) { + // warning modal + showLuaToolsPlayableWarning('This game may not work, support for it wont be given in our discord', function () { continueWithAdd(); - } - } catch (_) { + }, function () { }); + } else { continueWithAdd(); } - }); - }) - .catch(function (err) { - backendLog('LuaTools: DLC check failed: ' + err); - continueWithAdd(); + } catch (_) { + continueWithAdd(); + } }); + } + } } catch (_) { } }