Skip to content

Commit ea44bc9

Browse files
authored
v5.20: fix card price overlay never applying inside Global Chat
1 parent fb5eb89 commit ea44bc9

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

‎scripts/Utilities/Case Clicker Pricedata Overlay-2.7.user.js‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name Case Clicker Pricedata Overlay
33
// @namespace cco-pricedata
4-
// @version 5.19
4+
// @version 5.20
55
// @author rowan
66
// @credits zhiro for basescript, chunkycheese for pricedata
77
// @description shows inv/su calculated value (pricedata x quality x event multiplier + stickers), optional pricedata-based sort toggle, calculated price on cards (hover for original QS price), a copy-link button on trade/chat/other-SU cards, and an opt-out inventory-value leaderboard with Premier tracking.
@@ -1965,6 +1965,23 @@
19651965
hookLeaderboardPage();
19661966
}
19671967

1968+
// Lightweight sibling of scheduleTick() — same debounce shape, but only runs the one thing
1969+
// that's actually safe/useful outside <main>: overlaying the calculated price onto whatever
1970+
// skin cards showed up (e.g. a shared item/trade preview posted in Global Chat). Deliberately
1971+
// skips applySort()/injectScanButton()/autoScanStorageUnitIfNeeded()/etc. — those are meaningless
1972+
// outside the real inventory/SU pages and were the actual reason chat was excluded from the
1973+
// main tick loop in the first place (every chat message re-running the whole tick was the
1974+
// original bug this exclusion fixed). This only fixes the side effect that fix introduced:
1975+
// card price overlays never applying to anything rendered inside chat at all.
1976+
let chatTickTimer = null;
1977+
function scheduleChatTick() {
1978+
if (chatTickTimer) return;
1979+
chatTickTimer = setTimeout(() => {
1980+
chatTickTimer = null;
1981+
updateExtraCardPrices();
1982+
}, 50);
1983+
}
1984+
19681985
// ---------- Bootstrap ----------
19691986
function init() {
19701987
// Chat lives in its own <aside>/complementary panel, a SIBLING of <main> — observing
@@ -1976,6 +1993,16 @@
19761993
scheduleTick();
19771994
});
19781995
observer.observe(observeRoot, { childList: true, subtree: true });
1996+
1997+
// Separate, narrow-purpose observer for the chat aside (see scheduleChatTick's comment) —
1998+
// this is what actually fixes "skin cards shared in Global Chat never get priced": the main
1999+
// observer above never sees DOM changes here since <aside> isn't inside <main>.
2000+
const chatAside = document.querySelector('.mantine-AppShell-aside');
2001+
if (chatAside) {
2002+
const chatObserver = new MutationObserver(() => scheduleChatTick());
2003+
chatObserver.observe(chatAside, { childList: true, subtree: true });
2004+
}
2005+
19792006
hydrateSheetDataFromCache();
19802007
loadData();
19812008
scheduleSheetRefresh();

0 commit comments

Comments
 (0)