From dfa32e71f92b215c60c44f59fcf01391a828495a Mon Sep 17 00:00:00 2001 From: Step7750 Date: Sat, 11 May 2024 20:16:54 -0600 Subject: [PATCH 1/4] Removes CSMoney Screenshot Buttons Functionality isn't supported anymore, will make way for CSFloat screenshot integration in the future. --- README.md | 2 +- src/lib/bridge/handlers/execute_script.ts | 5 +- src/lib/bridge/handlers/fetch_skin_model.ts | 28 ---- src/lib/bridge/handlers/handlers.ts | 2 - src/lib/bridge/handlers/types.ts | 1 - src/lib/components/market/skin_viewer.ts | 167 -------------------- src/lib/page_scripts/market_listing.ts | 1 - src/lib/page_scripts/utils.ts | 2 - src/lib/types/extension_globals.ts | 1 - src/model_frame.html | 14 -- src/model_frame.js | 5 - webpack.config.js | 1 - 12 files changed, 3 insertions(+), 226 deletions(-) delete mode 100644 src/lib/bridge/handlers/fetch_skin_model.ts delete mode 100644 src/lib/components/market/skin_viewer.ts delete mode 100644 src/model_frame.html delete mode 100644 src/model_frame.js diff --git a/README.md b/README.md index caa13420..76720ced 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ CSFloat has an extension for Firefox/Chrome that lets you fetch floats directly ## Features +* Assists in verifying trades for CSFloat Market * Allows you to retrieve the float, paint seed, and float rank of any market or inventory item -* Allows you to fetch the 3D model and screenshot of the item directly on the page * Fetches all floats on the page quickly and automatically on page load * User-definable filters to highlight items with low floats or certain paint seeds * Shows market item stickers at a glance and their wear diff --git a/src/lib/bridge/handlers/execute_script.ts b/src/lib/bridge/handlers/execute_script.ts index 2d60d880..a9705527 100644 --- a/src/lib/bridge/handlers/execute_script.ts +++ b/src/lib/bridge/handlers/execute_script.ts @@ -15,10 +15,9 @@ export const ExecuteScriptOnPage = new PrivilegedHandler( await chrome.scripting.executeScript({ target: {tabId: sender.tab?.id as number}, world: 'MAIN', - args: [chrome.runtime.id, chrome.runtime.getURL('src/model_frame.html')], - func: function ExtensionId(extensionId, modelFrameUrl) { + args: [chrome.runtime.id], + func: function ExtensionId(extensionId) { window.CSFLOAT_EXTENSION_ID = extensionId; - window.CSFLOAT_MODEL_FRAME_URL = modelFrameUrl; }, }); diff --git a/src/lib/bridge/handlers/fetch_skin_model.ts b/src/lib/bridge/handlers/fetch_skin_model.ts deleted file mode 100644 index 8d364642..00000000 --- a/src/lib/bridge/handlers/fetch_skin_model.ts +++ /dev/null @@ -1,28 +0,0 @@ -import {SimpleHandler} from './main'; -import {RequestType} from './types'; - -export interface FetchSkinModelRequest { - inspectLink: string; -} - -export interface FetchSkinModelResponse { - modelLink: string; - screenshotLink: string; - - error?: string; -} - -export const FetchSkinModel = new SimpleHandler( - RequestType.FETCH_SKIN_MODEL, - async (req) => { - return fetch(`https://money.csgofloat.com/model?url=${req.inspectLink}`).then((resp) => { - return resp.json().then((data) => { - if (resp.ok) { - return data; - } else { - throw new Error(data.error); - } - }) as Promise; - }); - } -); diff --git a/src/lib/bridge/handlers/handlers.ts b/src/lib/bridge/handlers/handlers.ts index 2416a508..0aef750f 100644 --- a/src/lib/bridge/handlers/handlers.ts +++ b/src/lib/bridge/handlers/handlers.ts @@ -6,7 +6,6 @@ import {StorageGet} from './storage_get'; import {StorageSet} from './storage_set'; import {RequestHandler} from '../types'; import {FetchPendingTrades} from './fetch_pending_trades'; -import {FetchSkinModel} from './fetch_skin_model'; import {StorageRemove} from './storage_remove'; import {RequestType} from './types'; import {FetchExtensionFile} from './fetch_extension_file'; @@ -27,7 +26,6 @@ export const HANDLERS_MAP: {[key in RequestType]: RequestHandler} = { [RequestType.STORAGE_SET]: StorageSet, [RequestType.STORAGE_REMOVE]: StorageRemove, [RequestType.FETCH_PENDING_TRADES]: FetchPendingTrades, - [RequestType.FETCH_SKIN_MODEL]: FetchSkinModel, [RequestType.FETCH_EXTENSION_FILE]: FetchExtensionFile, [RequestType.ANNOTATE_OFFER]: AnnotateOffer, [RequestType.EXTENSION_VERSION]: ExtensionVersion, diff --git a/src/lib/bridge/handlers/types.ts b/src/lib/bridge/handlers/types.ts index eaef6d6c..ad03d9ab 100644 --- a/src/lib/bridge/handlers/types.ts +++ b/src/lib/bridge/handlers/types.ts @@ -7,7 +7,6 @@ export enum RequestType { STORAGE_SET, STORAGE_REMOVE, FETCH_PENDING_TRADES, - FETCH_SKIN_MODEL, FETCH_EXTENSION_FILE, ANNOTATE_OFFER, EXTENSION_VERSION, diff --git a/src/lib/components/market/skin_viewer.ts b/src/lib/components/market/skin_viewer.ts deleted file mode 100644 index 94b72c39..00000000 --- a/src/lib/components/market/skin_viewer.ts +++ /dev/null @@ -1,167 +0,0 @@ -import {FloatElement} from '../custom'; -import {CustomElement, InjectAppend, InjectionMode} from '../injectors'; -import {css, html, HTMLTemplateResult, nothing} from 'lit'; -import {FetchSkinModel, FetchSkinModelResponse} from '../../bridge/handlers/fetch_skin_model'; -import {state} from 'lit/decorators.js'; -import {ClientSend} from '../../bridge/client'; - -import '../common/ui/steam-button'; -import {cache} from 'decorator-cache-getter'; -import {getMarketInspectLink} from './helpers'; -import {rgAsset, ListingData} from '../../types/steam'; -import {AppId, ContextId} from '../../types/steam_constants'; -import {isSkin} from '../../utils/skin'; - -enum Showing { - NONE, - MODEL, - SCREENSHOT, -} - -@CustomElement() -@InjectAppend('#searchResultsRows .market_listing_row', InjectionMode.CONTINUOUS) -export class SkinViewer extends FloatElement { - private response: FetchSkinModelResponse | undefined; - - static styles = [ - ...FloatElement.styles, - css` - .btn-container { - margin: 7px 0 5px 80px; - } - - .iframe-3d { - margin-top: 10px; - width: 100%; - height: 500px; - border-width: 0; - } - - img.screenshot { - width: 100%; - } - `, - ]; - - @cache - get listingId(): string | undefined { - const id = $J(this).parent().attr('id'); - const matches = id?.match(/listing_(\d+)/); - if (!matches || matches.length < 2) { - return; - } - - return matches[1]; - } - - get listingInfo(): ListingData | null { - return g_rgListingInfo[this.listingId!]; - } - - get asset(): rgAsset | undefined { - if (!this.listingInfo) return; - - return g_rgAssets[AppId.CSGO][ContextId.PRIMARY][this.listingInfo.asset.id!]; - } - - get inspectLink(): string | undefined { - return getMarketInspectLink(this.listingId!); - } - - @state() - private loading = false; - - @state() - private showing: Showing = Showing.NONE; - - async connectedCallback() { - super.connectedCallback(); - } - - loadingIfApplicable(text: string, type: Showing) { - if (this.showing == type && this.loading) { - return 'Loading...'; - } else { - return text; - } - } - - protected render() { - if (!this.inspectLink) { - return html``; - } - - if (this.asset && !isSkin(this.asset)) { - return nothing; - } - - return html` -
- - - -
- ${this.showing === Showing.MODEL && this.response?.modelLink - ? html` -
- -
- ` - : nothing} - - `; - } - - async fetchModel() { - this.loading = true; - try { - this.response = await ClientSend(FetchSkinModel, { - inspectLink: this.inspectLink, - }); - } catch (e: any) { - alert(`Failed to fetch skin model: ${e.toString()}`); - } - this.loading = false; - } - - private toggle(type: Showing) { - if (this.showing === type) { - this.showing = Showing.NONE; - } else { - this.showing = type; - } - } - - async toggle3D() { - if (this.loading) return; - - this.toggle(Showing.MODEL); - - if (!this.response) { - await this.fetchModel(); - } - } - - async toggleScreenshot() { - if (this.loading) return; - - this.toggle(Showing.SCREENSHOT); - - if (!this.response) { - await this.fetchModel(); - } - } -} diff --git a/src/lib/page_scripts/market_listing.ts b/src/lib/page_scripts/market_listing.ts index f78b66d0..a7d31f6b 100644 --- a/src/lib/page_scripts/market_listing.ts +++ b/src/lib/page_scripts/market_listing.ts @@ -1,6 +1,5 @@ import {init} from './utils'; import '../components/market/item_row_wrapper'; -import '../components/market/skin_viewer'; import '../components/market/utility_belt'; init('src/lib/page_scripts/market_listing.js', main); diff --git a/src/lib/page_scripts/utils.ts b/src/lib/page_scripts/utils.ts index 6b4421b9..1c1a1280 100644 --- a/src/lib/page_scripts/utils.ts +++ b/src/lib/page_scripts/utils.ts @@ -25,12 +25,10 @@ async function initiateFirefox(scriptPath: string) { // We want to inject the ID of the extension const id = browser.runtime.id; - const modelUrl = browser.runtime.getURL('src/model_frame.html'); const entryScript = document.createElement('script'); entryScript.appendChild( document.createTextNode(` window.CSFLOAT_EXTENSION_ID = '${id}'; - window.CSFLOAT_MODEL_FRAME_URL = '${modelUrl}'; `) ); document.head.appendChild(entryScript); diff --git a/src/lib/types/extension_globals.ts b/src/lib/types/extension_globals.ts index 8f9b0402..a4d66fb2 100644 --- a/src/lib/types/extension_globals.ts +++ b/src/lib/types/extension_globals.ts @@ -3,6 +3,5 @@ export {}; declare global { interface Window { CSFLOAT_EXTENSION_ID: string; - CSFLOAT_MODEL_FRAME_URL: string; } } diff --git a/src/model_frame.html b/src/model_frame.html deleted file mode 100644 index 1b48c31c..00000000 --- a/src/model_frame.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/model_frame.js b/src/model_frame.js deleted file mode 100644 index 9d528cf7..00000000 --- a/src/model_frame.js +++ /dev/null @@ -1,5 +0,0 @@ -window.onload = function () { - const url = new URL(location.href); - const iframe = document.getElementById('model-frame'); - iframe.src = decodeURI(url.searchParams.get('url')); -}; diff --git a/webpack.config.js b/webpack.config.js index 80417a13..494e15bc 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -92,7 +92,6 @@ module.exports = (env) => { new CopyPlugin({ patterns: [ {from: 'icons', to: 'icons', context: '.'}, - {from: 'src/model_frame.html', to: 'src/', context: '.'}, {from: 'src/global.css', to: 'src/', context: '.'}, {from: 'src/background_ff.html', to: 'src/', context: '.'}, {from: 'src', to: 'raw/', context: '.'}, From 5fe006bcbef091ba640d9c3d89228ee6dca3cccb Mon Sep 17 00:00:00 2001 From: Step7750 Date: Sat, 11 May 2024 20:17:11 -0600 Subject: [PATCH 2/4] fixes package description --- manifest.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 155f78ac..b8f93c32 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "CSFloat Market Checker", "short_name": "CSFloat", "version": "4.2.5", - "description": "Shows the float value, paint seed, and screenshots of Counter-Strike (CS:GO & CS2) items on the Steam Market or Inventories", + "description": "Shows the float value, paint seed, and more of Counter-Strike (CS:GO & CS2) items on the Steam Market or Inventories", "icons": { "16": "icons/16.png", "48": "icons/48.png", diff --git a/package.json b/package.json index 02c2c669..089e13a9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "csfloat-extension", "version": "4.2.5", - "description": "Dedicated API for fetching the float value, paint seed, and screenshots of CS:GO items on the Steam Market or Inventories", + "description": "Dedicated API for fetching the float value, paint seed, and more of CS:GO items on the Steam Market or Inventories", "main": ".eslintrc", "directories": { "lib": "src/lib" From 57eeb7812c9c21d0199637d7b9ae428ef2f4cf6e Mon Sep 17 00:00:00 2001 From: Step7750 Date: Sat, 11 May 2024 20:19:02 -0600 Subject: [PATCH 3/4] Improved Margins on Float Rows in SCM Listings --- src/lib/components/market/item_row_wrapper.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/components/market/item_row_wrapper.ts b/src/lib/components/market/item_row_wrapper.ts index e3f79c4a..9bddc069 100644 --- a/src/lib/components/market/item_row_wrapper.ts +++ b/src/lib/components/market/item_row_wrapper.ts @@ -1,4 +1,4 @@ -import {html, nothing} from 'lit'; +import {css, html, nothing} from 'lit'; import {state} from 'lit/decorators.js'; import {CustomElement, InjectAppend, InjectionMode} from '../injectors'; @@ -17,6 +17,15 @@ import {pickTextColour} from '../../utils/colours'; @CustomElement() @InjectAppend('#searchResultsRows .market_listing_row .market_listing_item_name_block', InjectionMode.CONTINUOUS) export class ItemRowWrapper extends FloatElement { + static styles = [ + ...FloatElement.styles, + css` + .float-row-wrapper { + margin-bottom: 5px; + } + `, + ]; + @cache get listingId(): string | undefined { const id = $J(this).parent().find('.market_listing_item_name').attr('id'); @@ -144,7 +153,7 @@ export class ItemRowWrapper extends FloatElement { const fadePercentage = this.asset && getFadePercentage(this.asset, this.itemInfo); return html` -
+
Float: ${this.itemInfo.floatvalue.toFixed(14)} ${renderClickableRank(this.itemInfo)}
Paint Seed: ${formatSeed(this.itemInfo)}${fadePercentage !== undefined From 6900a5be95a32b1301c967c845534ad2d7e19fc2 Mon Sep 17 00:00:00 2001 From: Step7750 Date: Sat, 11 May 2024 20:20:13 -0600 Subject: [PATCH 4/4] removes web resource that doesn't exist anymore --- manifest.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/manifest.json b/manifest.json index b8f93c32..29e5bd5f 100644 --- a/manifest.json +++ b/manifest.json @@ -55,10 +55,6 @@ "matches": ["*://*.steamcommunity.com/*"] }, "web_accessible_resources": [ - { - "resources": ["src/model_frame.html", "src/model_frame.js"], - "matches": ["https://steamcommunity.com/*"] - }, { "resources": ["src/version.txt"], "matches": ["https://csfloat.com/*"]