Add support for searching and downloading mods from Thunderstore

This commit is contained in:
2026-03-23 19:36:32 +01:00
parent b5eef93ffd
commit 41d84b18b7
5 changed files with 184 additions and 5 deletions

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="244"
height="244"
viewBox="0 0 64.558333 64.558333"
version="1.1"
id="svg1"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs1" />
<g
id="layer1"
transform="translate(-1.5875,-1.5875005)">
<path
style="fill:none;stroke:#ffffff;stroke-width:6.35;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="M 62.970833,33.866667 H 4.7625"
id="path1" />
<path
style="fill:none;stroke:#ffffff;stroke-width:6.35;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1"
d="M 33.866666,62.970833 V 4.7625005"
id="path2" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 838 B

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<title>Silk Fly Launcher</title>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'; img-src 'self' https://*.nexusmods.com" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'; img-src 'self' https://*.nexusmods.com https://*.thunderstore.io" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
@@ -180,6 +180,7 @@
<li id="endorsements" onclick="changeSort('endorsements')">by rating count</li>
<li id="createdAt" onclick="changeSort('createdAt')">by date of creation</li>
<li id="updatedAt" onclick="changeSort('updatedAt')">by date of updating</li>
<li id="size" onclick="changeSort('size')">by size</li>
</div>
</div>
<button class="default-button square-button" onclick="inverseSort()"><img class="icons" id="sort-order-image" src="assets/icons/sort-order-1.svg" /></button>

View File

@@ -312,6 +312,73 @@ async function navigate(page) {
view.appendChild(thunderstoreModsTemplateCopy);
toggleSelectedListButton("sort-menu", thunderstoreSortFilter);
setSortOrderButton();
const { thunderstoreModsInfo, thunderstoreTotalCount } = await mods.getMods(page);
thunderstoreModsTotalCount = thunderstoreTotalCount;
if (thunderstoreModsInfo == undefined) {
break;
}
for (const mod of thunderstoreModsInfo) {
if (mod.name == undefined) {
continue;
}
const modTemplateCopy = modTemplate.content.cloneNode(true);
if (mod.name) {
const modTitleText = modTemplateCopy.getElementById("mod-title");
modTitleText.innerText = mod.name.replaceAll("_", " ");
}
if (mod.author) {
const modAuthorText = modTemplateCopy.getElementById("mod-author");
modAuthorText.innerText = `by ${mod.author}`;
}
if (mod.endorsements) {
const modEndorsementsNumber = modTemplateCopy.getElementById("mod-endorsements-number");
if (mod.endorsements > 1) {
modEndorsementsNumber.innerText = `${mod.endorsements} likes`;
} else {
modEndorsementsNumber.innerText = `${mod.endorsements} like`;
}
}
if (mod.downloads) {
const modDownloadsNumber = modTemplateCopy.getElementById("mod-downloads-number");
if (mod.downloads > 1) {
modDownloadsNumber.innerText = `${mod.downloads} downloads`;
} else {
modDownloadsNumber.innerText = `${mod.downloads} download`;
}
}
if (mod.summary) {
const modDescriptionText = modTemplateCopy.getElementById("mod-description");
modDescriptionText.innerText = mod.summary;
}
if (mod.pictureUrl) {
const modPicture = modTemplateCopy.getElementById("mod-icon");
modPicture.src = mod.pictureUrl;
}
if (mod.version && mod.updatedAt) {
const modVersionText = modTemplateCopy.getElementById("mod-version");
modVersionText.innerText = `V${mod.version} last updated on ${mod.updatedAt.slice(0, 10)}`;
}
const modUrl = `https://new.thunderstore.io/c/hollow-knight-silksong/p/${mod.author}/${mod.name}`;
const modLinkButton = modTemplateCopy.getElementById("external-link");
modLinkButton.href = modUrl;
modLinkButton.addEventListener("click", function (event) {
event.preventDefault();
const modLink = modLinkButton.href;
electronAPI.openExternalLink(modLink);
});
modDownloadButton = modTemplateCopy.getElementById("download-mod-button");
modDownloadButton.addEventListener("click", function (event) {
event.preventDefault();
const modDownloadLink = `https://thunderstore.io/package/download/${mod.author}/${mod.name}/${mod.version}`;
thunderstore.download(modDownloadLink, mod.modId);
});
thunderstoreModsContainer.appendChild(modTemplateCopy);
}
break;
case "general-settings":
title.innerText = "Settings";
@@ -815,7 +882,7 @@ function changeModsPage(offsetChange) {
thunderstoreOffset = Math.floor(thunderstoreOffset / 10) * 10;
if (lastThunderstoreOffset != thunderstoreOffset) {
lastThunderstoreOffset = thunderstoreOffset;
searchNexusMods();
searchThunderstoreMods();
}
}
}