Skip to content

Commit

Permalink
Skinport Charm support
Browse files Browse the repository at this point in the history
  • Loading branch information
GODrums committed Oct 18, 2024
1 parent f860c4a commit 77551c8
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "betterfloat",
"displayName": "BetterFloat",
"version": "2.8.1",
"version": "2.8.2",
"description": "Enhance your experience on CSFloat.com, Skinport.com & Skinbid.com!",
"author": "Rums",
"license": "CC BY NC SA 4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/background/messages/refreshPrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const handler: PlasmoMessaging.MessageHandler<PriceBody, PriceResponse> = async
if (responseJson?.data) {
chrome.storage.local.set({
[`${pricesURL}`]: JSON.stringify(responseJson.data),
[`${source}-update`]: responseJson.time,
[`${source}-update`]: Date.now(), // responseJson.time,
});
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/contents/skinport_script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,12 @@ export async function patternDetections(container: Element, item: Skinport.Item)
if (item.name.includes('Case Hardened')) {
await caseHardenedDetection(container, item);
} else if ((item.name.includes('Crimson Web') || item.name.includes('Emerald Web')) && item.name.startsWith('★')) {
await webDetection(container, item);
webDetection(container, item);
}
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function webDetection(container: Element, item: Skinport.Item) {
export function webDetection(container: Element, item: Skinport.Item) {
const itemHeader = container.querySelector('.TradeLock-lock');
if (!itemHeader) return;
}
Expand Down Expand Up @@ -625,6 +625,12 @@ async function caseHardenedDetection(container: Element, item: Skinport.Item) {
// true: remove item, false: display item
function applyFilter(item: Skinport.Listing, container: Element) {
const spFilter: SPFilter = localStorage.getItem('spFilter') ? JSON.parse(localStorage.getItem('spFilter') ?? '') : DEFAULT_FILTER;
// since it's a new setting, we need to check if it exists
if (spFilter.types.charm === undefined) {
spFilter.types.charm = true;
// and store it back
localStorage.setItem('spFilter', JSON.stringify(spFilter));
}
const targetName = spFilter.name.toLowerCase();
// if true, item should be filtered
const nameCheck = targetName !== '' && !item.full_name.toLowerCase().includes(targetName);
Expand Down
14 changes: 11 additions & 3 deletions src/lib/helpers/skinport_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getBuffItem } from '~contents/skinport_script';
import type { ItemStyle } from '~lib/@typings/FloatTypes';
import type { Skinport } from '~lib/@typings/SkinportTypes';
import { ICON_BUFF, ICON_C5GAME, ICON_STEAM, ICON_YOUPIN, MarketSource } from '~lib/util/globals';
import { waitForElement } from '~lib/util/helperfunctions';
import { getCharmColoring, waitForElement } from '~lib/util/helperfunctions';
import { getSetting } from '~lib/util/storage';

export function addPattern(container: Element, item: Skinport.Item) {
Expand All @@ -17,9 +17,17 @@ export function addPattern(container: Element, item: Skinport.Item) {
if (parts.length > 2) {
parts = parts.slice(0, parts[0].indexOf('-') > -1 ? 1 : 2);
}
return `${parts.join(' ')} <br> Pattern: <span style="color: mediumpurple; font-weight: 600; font-size: 13px;">${item.pattern}</span>`;
return parts.join(' ');
};
itemText.innerHTML = santizeText(itemText.textContent);

const getPatternStyle = () => {
if (item.category === 'Charm') {
const badgeProps = getCharmColoring(item.pattern, item.name);
return `color: ${badgeProps[0]}; font-weight: 600; font-size: 13px;border-radius: 7px; padding: 2px 5px; margin-top: 4px`;
}
return 'color: mediumpurple; font-weight: 600; font-size: 13px;';
};
itemText.innerHTML = `${santizeText(itemText.textContent)} <br> Pattern: <span style="${getPatternStyle()}">${item.pattern}</span>`;
}

export async function addTotalInventoryPrice(data: Skinport.InventoryListed | Skinport.InventoryAccount) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/websockethandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function handleListed(data: Skinport.Item[]) {
if (item.marketHashName.includes('Case Hardened') && item.category === 'Knife' && (await getSetting('sp-csbluegem'))) {
await addBlueBadge(element, item);
} else if ((item.marketHashName.includes('Crimson Web') || item.marketHashName.includes('Emerald Web')) && item.category === 'Gloves') {
await webDetection(element, item);
webDetection(element, item);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/inline/LiveFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const LiveFilter: React.FC = () => {
localStorage.setItem('spFilter', JSON.stringify(DEFAULT_FILTER));
};

const filterLabels = ['Knife', 'Gloves', 'Agent', 'Weapon', 'Collectible', 'Container', 'Sticker', 'Equipment', 'Pass'];
const filterLabels = ['Knife', 'Gloves', 'Agent', 'Weapon', 'Collectible', 'Container', 'Sticker', 'Charm', 'Equipment', 'Pass'];

useEffect(() => {
let count = 0;
Expand Down
1 change: 1 addition & 0 deletions src/lib/util/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export const DEFAULT_FILTER = {
sticker: true,
equipment: true,
pass: true,
charm: true,
},
new: false,
};
Expand Down

0 comments on commit 77551c8

Please sign in to comment.