import {mountExchangeDesign} from '/codex-exchange.js'; const host=document.querySelector('#market'); const fetcher=(url,options)=>{const parsed=new URL(url,location.href);if(location.hostname==='127.0.0.1'&&parsed.hostname==='cp.dunerealms.com'&&parsed.pathname.startsWith('/api/jarvis/'))url='/preview-api'+parsed.pathname+parsed.search;return fetch(url,options);}; mountExchangeDesign(host,{context:'public',fetcher}); const root=host.querySelector('.codex-exchange'),legend=root.querySelector('.codex-exchange-legend');legend.open=false; root.querySelector('.jarvis-victory')?.remove();root.querySelector('.exchange-card-gallery')?.closest('details')?.remove(); const tools=root.querySelector('.codex-exchange-tools'),fields=[...tools.querySelectorAll('.codex-exchange-field')],advanced=document.createElement('details'),summary=document.createElement('summary'),advancedFields=document.createElement('div');advanced.className='market-advanced';summary.textContent='Edition & season filters';advancedFields.className='market-advanced-fields';advancedFields.append(...fields.slice(3));advanced.append(summary,advancedFields);tools.replaceChildren(...fields.slice(0,3),advanced); // Keep native listing actions and lore: the new shell only changes presentation. const categories=root.querySelector('.codex-exchange-categories'),label=document.createElement('h2');label.className='market-category-title';label.textContent='Browse the Exchange';categories.prepend(label); const tip=document.createElement('div');tip.className='market-help';tip.innerHTML='Your goods. Your next chapter.
Browse here, trade through the existing Exchange. Item details show exactly what is on offer.
My listings & purchases →';categories.append(tip); function enhance(){for(const card of root.querySelectorAll('.exchange-card')){ if(card.dataset.realmEnhanced)continue;card.dataset.realmEnhanced='true'; const lore=card.querySelector('.item-lore-card'),quality=lore?.dataset.quality; if(quality&&quality!=='unknown'){ card.dataset.quality=quality;const strip=document.createElement('div');strip.className='market-item-quality'; const name=document.createElement('span');name.textContent=lore.querySelector('.item-lore-identity strong')?.textContent||quality;strip.append(name); const mk=lore.querySelector('.item-lore-identity em')?.textContent;if(mk&&!mk.includes('not registered')){const mark=document.createElement('em');mark.textContent=mk;strip.append(mark);} card.querySelector('header').after(strip); } }} new MutationObserver(enhance).observe(root.querySelector('.codex-exchange-cards'),{childList:true});enhance();