Skip to content

Commit

Permalink
charm pattern id to tool tip
Browse files Browse the repository at this point in the history
  • Loading branch information
gergelyszabo94 committed Dec 5, 2024
1 parent 386fec2 commit 15c7c06
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
19 changes: 16 additions & 3 deletions extension/src/contentScripts/steam/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ const setPatternInfo = (patternInfo) => {
};

// sticker wear to sticker icon tooltip
const setStickerInfo = (stickers) => {
const setStickerInfo = (stickers, charms) => {
if (stickers !== null) {
stickers.forEach((stickerInfo, index) => {
const wear = stickerInfo.wear !== undefined
Expand All @@ -407,6 +407,19 @@ const setStickerInfo = (stickers) => {
});
});
}

if (charms) {
const charm = charms[0];
document.querySelectorAll('.customStickers').forEach((customStickers) => {
const stickerSlots = customStickers.querySelectorAll('.stickerSlot');
const charmEl = stickerSlots[stickerSlots.length - 1];

if (charmEl !== undefined) {
const currentToolTipText = charmEl.getAttribute('data-tooltip');
charmEl.setAttribute('data-tooltip', `${currentToolTipText} - Pattern: #${charm.pattern}`);
}
});
}
};

// not used right now, inspecton server is a link now
Expand Down Expand Up @@ -455,7 +468,7 @@ const setFloatDBLinkURL = (item) => {
const updateFloatAndPatternElements = (item) => {
setFloatBarWithData(item.floatInfo);
setPatternInfo(item.patternInfo);
setStickerInfo(item.floatInfo.stickers);
setStickerInfo(item.floatInfo.stickers, item.floatInfo.charms);
setFloatDBLinkURL(item);
};

Expand Down Expand Up @@ -758,7 +771,7 @@ const addRightSideElements = () => {

// adds own sticker elements
const combinedAddons = [...item.stickers, ...item.charms];

combinedAddons.forEach((stickerInfo) => {
document.querySelectorAll('.customStickers').forEach((customStickers) => {
customStickers.innerHTML += DOMPurify.sanitize(`
Expand Down
15 changes: 14 additions & 1 deletion extension/src/utils/floatCaching.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const extractUsefulFloatInfo = (floatInfo) => {
const {
floatvalue, paintindex, paintseed, defindex,
// eslint-disable-next-line camelcase
origin_name, min, max, stickers, low_rank, high_rank,
origin_name, min, max, stickers, keychains, low_rank, high_rank,
} = { ...floatInfo };

let stickersModified = null;
Expand All @@ -77,6 +77,18 @@ const extractUsefulFloatInfo = (floatInfo) => {
});
}

let charmsModifeid = null;

if (keychains !== undefined) {
charmsModifeid = keychains.map((charm) => {
return {
...charm,
name: charm.market_hash_name.split('Charm | ')[1],
stickerId: charm.sticker_id,
};
});
}

return {
floatvalue,
paintindex,
Expand All @@ -87,6 +99,7 @@ const extractUsefulFloatInfo = (floatInfo) => {
min,
max,
stickers: stickersModified,
charms: charmsModifeid,
// eslint-disable-next-line camelcase
low_rank: low_rank !== undefined ? low_rank : null,
// eslint-disable-next-line camelcase
Expand Down

0 comments on commit 15c7c06

Please sign in to comment.