|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Case Clicker Pricedata Overlay |
3 | 3 | // @namespace cco-pricedata |
4 | | -// @version 5.19 |
| 4 | +// @version 5.20 |
5 | 5 | // @author rowan |
6 | 6 | // @credits zhiro for basescript, chunkycheese for pricedata |
7 | 7 | // @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 | 1965 | hookLeaderboardPage(); |
1966 | 1966 | } |
1967 | 1967 |
|
| 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 | + |
1968 | 1985 | // ---------- Bootstrap ---------- |
1969 | 1986 | function init() { |
1970 | 1987 | // Chat lives in its own <aside>/complementary panel, a SIBLING of <main> — observing |
|
1976 | 1993 | scheduleTick(); |
1977 | 1994 | }); |
1978 | 1995 | 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 | + |
1979 | 2006 | hydrateSheetDataFromCache(); |
1980 | 2007 | loadData(); |
1981 | 2008 | scheduleSheetRefresh(); |
|
0 commit comments