Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 24 additions & 31 deletions public/luatools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (_) { }
}
Expand Down