Background

Mirador is an IIIF-compatible image viewer that allows side-by-side comparison of multiple IIIF manifests. When displaying manifests published by multiple institutions in a single view, each window title shows the manifest’s label as-is.

However, there are cases where you want to display a custom name as the window title for your own project. For example, when the manifest’s label is a long string containing individual volume information, but you want to display a short name indicating the collection.

Constraint: The Manifest Contents Must Not Be Changed

Since external manifests published by other institutions are loaded and displayed, modifying their contents should be avoided. While it is possible to intercept fetch or rewrite Mirador’s internal state to replace the label in the manifest JSON, this amounts to modifying the manifest itself.

What should be changed is only the title display (DOM) of the window rendered by Mirador on screen, while keeping the manifest data itself in its original form.

Approaches Tried and Results

1. Rewriting Internal State via Mirador.actions.receiveManifest

s}t)ovi};Mrafiervusr.(vaptassmerdodutararobanruterstiipe.cefddddredaJii=setsssbtneoptess[dnao(t[mJ.trfomaslceuranoahneninb(c.ifeMtgfe=liieesrotstJ=anStISdtIdOcoad]Nurt].s.e=pta{(&aoc)&trmt;rsTimueioae(tnn;JlsiSe.fO;reNels.catsebstie[rvlmieanMngaiinffieyfs(etmsIatdn(]im.fajenssiotfnse[s&mt&aInd!i,ofveuesprtdrIaidtd]ed.dejJnss[oomnna))n))i;;festId]){

Result: Did not work. In the UMD build of Mirador 4 distributed via unpkg, Mirador.actions is undefined, and this API was not available.

2. Intercepting window.fetch

vw}ai;rnr}de)ooti}r;rwufei.rr}tgfn(e)uiettvjr;rntoiuasenacrtrrotlhilnnurFgej.ree=iMrslnstnaeoapcfapsnbnohul[peennFuo=lws=cernettlsJ=R;wic]eSeioh).Otsnn.tNipdc{e.too(axplnwultaes.rl(rMefl()sa(e,t.epJtht([ScoihtuOhpseerN;t,nxl.i(t]souf);tnru;rslni),cntg{oiipoftnyi(o(jntsseo)xn.t)t),he{{n(function(}r)e;sponse){

Result: Works, but amounts to modifying the manifest contents. Since the JSON received by Mirador itself is rewritten, the modified label is also displayed in the information panel. Rejected due to concerns about modifying other institutions’ manifests.

3. Traversing and Replacing All Text Nodes in the DOM

vvw}aahrrii}lfwnenao(oldndke(oee;nd.roend.o=endoed=dVoeacwVluaaumlleekunee=tr...tccnrureisexmtat(otN)meoTTd=ire=te(=le)eW)o;a)rlik{geirn(acloLnatbaeiln)er{,NodeFilter.SHOW_TEXT);

Result: Impact scope too wide. Not only the window title but all occurrences of the same label text, including metadata displays in the manifest information panel, were replaced.

4. Targeting Only the h2 Element in the Window Top Bar (Adopted)

Mirador 4’s window top bar has the following DOM structure:

<n/a<nvd/ai<<dvcvh/!i>l2h-vac2->slc>sal=sa"ss.=s."=l.."aW.Mbi.uenmildiTorywapTdooogprrB-aawprih-nyrd-oorowot-o"ttoapMr-uibiaaT-ryl.pa.ob.ge"rl>a=p"hy-h2Mu"i>Typography-noWrap.">

By targeting only this h2 element for replacement, the window title display can be controlled without changing the manifest contents or metadata display at all.

Final Implementation

Add a titles parameter to the URL, specifying custom titles separated by semicolons for each manifest.

mirador/index.html?manifest=<URL1>;<URL2>&titles=<Title1>;<Title2>

Building the Title Map

vi}afrvf}aotvrrvi}iaaftrtrtlsiv(ie[tatttM"lriilatettepiAillMtreea=lr=VVpeaaa[{sy0lld}";uue;]=eeci)o&v=d&a<{erdUvsmeRa[acIr"noCstido[ifem"teUpmlsRoaetInnsACei"ronf]rmte.ap(ssyomtp.na"llen]ieni)tntf(g(e{"tts;hit"tA)&lr;&erAairyr[<aiy]t[)ii]t]l)=e;Atrirtalye.Vlaelnuget;h;i++){

Specify titles in the same order and count as the manifest parameter. Build a map with manifest URLs as keys and custom titles as values.

DOM Replacement Processing

i}fvvvf}f}f}so}(aaauuutb)OrrrnvvvvO}rnvivor}oniroscs;bcaaaab)ecafabe)bcferehujsrotrrrrjvivi};ttrrspc;stperibetebieafafui(eloei(l.vltcopsoswmrcrrrrorrcran..}rorasedrtrlentsset(enneeovctqf)vnecurLe.earas.m!oosppneeauoi};epeb.iekcvgt==ukitrrurrlltrmierfrslTsos:e=eeeelediiileeaaa.enrEh.caicbtyTrtsstytggtspccidneya(2ohcmrs:tsmiR=tts=lii.uleenitrSch.beeeier(im=eaa=(ennplammesseh2tsdTrbrtutrepsttwwMaautceerc.l(.eeuievreiarnltee[ssalls;ennofeftxrlm=(eu,tdeao..])[phTtt=nocuetvees(elo=wcrwm;.w[=&(issnrtnxCeRrscd,ereeiafim&{t.deEocto(e)ehoMInMm.nnodiml=locartCncptecanuuegdir]dstoeectcAiotolcTdupsltneofE.][yrsgnu(hlonenalium)tlattweammpi(egm)(lntntcemle.a;tsSsscaieg)tte;f(etaeaeenlni(tthndoiRhnu"(ni(roRteco)as(i]fn{etn.ht=n)Tue.nentff!.ap=.cm2.eitpgg.O{euemjoll=gti)trr{m(letsb({nsssr:a=eirr.,erathts)}ct[oictoa{icoecEoe;;{tImngoe0Endmu{upel>rr}idi.irm)lo(stl)eev;o;dlniee(r)tc(a;m0;en]aagnrmr-ohrce)rblitee)w=mieen((enstni=;lpTt{swl=a(ut{n=dliBci;=l)rBdLatyhd!=,;nyoriclIe)m;Iw.seedds"cd-otTs(u{[su(tr:i,"lmts"oimmeirtmpgte5iRdioi-irr0re]nmrbnu))ap.g:aaae;;dlj"drl,oas)to)rcoirhs"en{t"2{u)))l)"b,;e;)trMr{eaetpeu[:rmnit;dr]ue})};);

The key points are the following three:

  1. store.subscribe – Monitors Mirador’s Redux store and detects when manifest loading is complete. Gets the original label from the store to identify replacement targets.
  2. MutationObserver – Since the DOM is updated every time Mirador re-renders with React, it detects changes and replaces the title again.
  3. observer.disconnect() / observer.observe() – Pauses the observer during replacement processing to prevent the MutationObserver from re-firing due to its own DOM changes and creating an infinite loop.

Summary

AspectResult
Manifest JSONNo changes (kept as original)
Mirador internal stateNo changes
Information panel metadataNo changes (original label is displayed)
Window top bar titleReplaced with custom title

This allows presenting display names suited to your project’s context while respecting the IIIF manifests published by external institutions. It is a simple approach that can be achieved using only standard DOM APIs without Mirador’s plugin mechanism.