Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Steam Market Sticker Container #279

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 12 additions & 2 deletions src/lib/components/market/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function generateStickerInlineHTML(itemInfo: ItemInfo, asset: rgAsset): string[]
function generateKeychainInlineHTML(itemInfo: ItemInfo, asset: rgAsset): string[] {
const description = getKeychainDescription(itemInfo, asset);

if (!description || description.type !== 'html' || !description.value.includes('sticker')) {
if (!description || description.type !== 'html' || description.value.includes('sticker')) {
return [];
}

Expand All @@ -107,6 +107,11 @@ function generateKeychainInlineHTML(itemInfo: ItemInfo, asset: rgAsset): string[
export function inlineStickersAndKeychains(itemNameBlock: JQuery<Element>, itemInfo: ItemInfo, asset: rgAsset) {
if (!itemNameBlock) return;

// Remove Steam's inspect button
itemNameBlock.parent().find('.market_listing_row_action')?.parent().remove();
// Remove Steam's stickers and keychains
itemNameBlock.parent().find('.market_listing_row_details')?.remove();

if (itemNameBlock.find('.csfloat-stickers-container').length) {
// Don't inline stickers if they're already inlined
return;
Expand All @@ -117,11 +122,16 @@ export function inlineStickersAndKeychains(itemNameBlock: JQuery<Element>, itemI
return;
}

const elementId = `listing_${itemInfo.m}_csfloat`;

itemNameBlock.prepend(`
<div class="csfloat-stickers-container">
<div class="csfloat-stickers-container" id="${elementId}">
${blobs.reduce((acc, v) => acc + v, '')}
</div>
`);

// Add Steam's item popover on-hover
CreateItemHoverFromContainer(g_rgAssets, elementId, asset.appid, asset.contextid, asset.id, asset.amount);
}

/**
Expand Down
12 changes: 10 additions & 2 deletions src/lib/components/market/item_row_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ export class ItemRowWrapper extends FloatElement {
// dialogs opening.
MarketCheckHash();
}

// Make sure the parent containers can overflow
const parentContainer = $J(this).parent();
if (parentContainer) {
parentContainer.css('overflow', 'visible');
parentContainer.parent().css('overflow', 'visible');
}
}

render() {
Expand All @@ -161,8 +168,9 @@ export class ItemRowWrapper extends FloatElement {
return html`
<div class="float-row-wrapper">
${this.renderFloatBar()}
<span> Float: ${this.itemInfo.floatvalue.toFixed(14)} ${renderClickableRank(this.itemInfo)} </span>
<br />
<span style="display: block;">
Float: ${this.itemInfo.floatvalue.toFixed(14)} ${renderClickableRank(this.itemInfo)}
</span>
Paint Seed:
${formatSeed(this.itemInfo)}${fadePercentage !== undefined
? html`<br />
Expand Down
20 changes: 15 additions & 5 deletions src/lib/types/steam.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,18 @@ export interface TradeInventory {
success: boolean;
}

export type SteamAssets = {
[appId in AppId]: {
[contextId in ContextId]: {[assetId: string]: rgAsset};
};
};

// Declares globals available in the Steam Page Context
declare global {
const $J: typeof $;
const g_rgListingInfo: {[listingId: string]: ListingData};
const g_rgWalletInfo: WalletInfo | undefined; // Not populated when user is signed-out
const g_rgAssets: {
[appId in AppId]: {
[contextId in ContextId]: {[assetId: string]: rgAsset};
};
};
const g_rgAssets: SteamAssets;
const g_ActiveInventory: CInventory | undefined; // Only populated on Steam inventory pages
const g_steamID: string;
const g_oSearchResults: CAjaxPagingControls;
Expand All @@ -250,6 +252,14 @@ declare global {
const MoveItemToTrade: (el: HTMLElement) => void; // Only populated on create offer pages
const g_rgCurrentTradeStatus: CurrentTradeStatus;
const ShowItemInventory: (appID: AppId, contextID: ContextId, AssetID?: number) => void;
const CreateItemHoverFromContainer: (
g_rgAssets: SteamAssets,
elementId: string,
appid: AppId,
contextid: string,
id: string,
amount: number
) => void;
}

export {};
Loading