Created
March 19, 2023 12:04
-
-
Save FormallyMyles/46673cb34b61691a1835650f7474dbf5 to your computer and use it in GitHub Desktop.
Fix blank steam icons (if you reinstalled steam) on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Script based on https://github.com/mrsimb/steam_blank_icon_fix | |
// This version uses the embedded URLs to avoid using steamdb.info (and use the CDN) | |
// See original repo for usage | |
const steamIconsPath = "C:/Program Files (x86)/Steam/steam/games"; | |
const searchPath = String(Deno.args[0] || "."); | |
console.log(`Steam icons path: "${steamIconsPath}"`); | |
console.log(`Searching shortcuts in: "${searchPath}"\n`); | |
for await (const entry of Deno.readDir(searchPath)) { | |
if (!entry.isFile || !entry.name.endsWith(".url")) { | |
continue; | |
} | |
const linkContent = await Deno.readTextFile(entry.name); | |
const gameId = linkContent.match(/rungameid\/(.+)/m)?.[1]; | |
const hash = linkContent.match(/games\\(.+)/m)?.[1]; | |
console.info("hash: " + hash); | |
if (!gameId) { | |
continue; | |
} | |
const iconUrl = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/" + gameId + "/" + hash; | |
const iconName = iconUrl?.match(/(\w|\d)+.ico/)?.[0]; | |
const hasIconPath = !!linkContent.match(/IconFile=.+/m); | |
const hasIconFile = iconName && | |
await Deno.stat(steamIconsPath + "/" + iconName).catch(() => {}); | |
const status = [!hasIconPath && "unlinked", !hasIconFile && "file missing"] | |
.filter(Boolean) | |
.join(", ") || "ok"; | |
if (!hasIconPath) { | |
const linkContentFixed = linkContent.replace( | |
/IconFile=$/m, | |
`IconFile=${steamIconsPath}/${iconName}`, | |
); | |
await Deno.writeTextFile(entry.name, linkContentFixed); | |
} | |
if (!hasIconFile && iconUrl) { | |
const iconBuffer = await fetch(iconUrl).then((res) => res.arrayBuffer()); | |
await Deno.writeFile( | |
steamIconsPath + "/" + iconName, | |
new Uint8Array(iconBuffer), | |
); | |
} | |
console.group(entry.name); | |
console.log(gameId, iconName); | |
console.log(status + "\n"); | |
console.groupEnd(); | |
} | |
console.log("Done!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment