diff --git a/scripts/client-overrides/public/reading-tools.js b/scripts/client-overrides/public/reading-tools.js index c9082230..6bb703e2 100644 --- a/scripts/client-overrides/public/reading-tools.js +++ b/scripts/client-overrides/public/reading-tools.js @@ -24,8 +24,8 @@ controls.append(opener,ruby,panel);document.addEventListener('pointerdown',e=>{if(!controls.contains(e.target))closePanel()},true);document.addEventListener('keydown',e=>{if(e.key==='Escape'&&controls.dataset.open==='true'){closePanel();opener.focus()}}); const host=document.querySelector('body>header nav,body>header,#library>header');if(!document.getElementById('game')){if(host)host.append(controls);else document.body.prepend(controls)} - const homeHost=host||document.body,entryFrame=document.getElementById('game');function place(){if(entryFrame){const child=entryFrame.contentDocument;if(!child?.body)return;controls.classList.add('np-reading-compact');const updateRuby=event=>{const on=!!event?.detail?.enabled;ruby.setAttribute('aria-pressed',String(on));ruby.setAttribute('aria-label','ふりがな '+(on?'ON':'OFF'));ruby.title='ふりがな '+(on?'ON':'OFF')};if(!child.documentElement.dataset.npReadingEvents){child.documentElement.dataset.npReadingEvents='true';child.addEventListener('pointerdown',e=>{if(!controls.contains(e.target))closePanel()},true);child.addEventListener('keydown',e=>{if(e.key==='Escape'&&controls.dataset.open==='true'){closePanel();opener.focus()}},true);child.defaultView.addEventListener('nanpure-furigana-change',updateRuby)}if(controls.ownerDocument!==child)child.adoptNode(controls);child.body.append(controls);if(!child.getElementById('np-reading-controls-style')){const childStyle=style.cloneNode(true);childStyle.id='np-reading-controls-style';child.head.append(childStyle)}updateRuby({detail:{enabled:entryFrame.contentWindow?.NPFurigana?.getEnabled()}});return}const target=document.querySelector('#player:not([hidden])>nav')||homeHost;if(controls.parentElement!==target)target.append(controls)}new MutationObserver(place).observe(document.body,{subtree:true,attributes:true,attributeFilter:['hidden']});entryFrame?.addEventListener('load',place);window.addEventListener('resize',place);queueMicrotask(place); - const style=document.createElement('style');style.textContent='.np-reading-controls{position:relative;display:flex;align-items:center;flex-wrap:wrap;gap:6px;min-width:0}.np-reading-panel{display:flex;align-items:center;flex-wrap:wrap;gap:6px}.np-reading-open{display:none}.np-reading-language{display:flex;align-items:center;gap:4px}.np-reading-language select{font:inherit;max-width:148px;min-width:0;min-height:40px;border:1px solid #bdcbbb;border-radius:8px;background:#fffefa;color:inherit;padding:5px}.np-reading-compact{position:fixed;inset-block-start:8px;inset-inline-end:8px;z-index:10000;display:flex;align-items:center;gap:4px;padding:4px;background:#fffefaeF;border:1px solid #bdcbbb;border-radius:10px;box-shadow:0 2px 10px #20362f22}.np-reading-compact .np-reading-open,.np-reading-compact .np-reading-ruby{display:inline-flex;align-items:center;justify-content:center;min-width:34px;width:34px;min-height:34px;padding:3px;border:1px solid #bdcbbb;border-radius:7px;background:#fffefa;color:#285849;font:700 13px system-ui,sans-serif}.np-reading-compact .np-reading-ruby{font-size:0}.np-reading-compact .np-reading-ruby::after{content:\'ふ\';font-size:13px}.np-reading-compact .np-reading-panel{display:none}.np-reading-compact[data-open=true] .np-reading-panel{display:flex;position:absolute;inset-block-start:calc(100% + 5px);inset-inline-end:0;z-index:50;width:min(260px,calc(100vw - 24px));padding:10px;background:#fffefa;border:1px solid #bdcbbb;border-radius:10px;box-shadow:0 6px 24px #20362f33}.np-reading-compact .np-reading-language select{min-height:36px}#library>header,#player>nav{flex-wrap:wrap;gap:8px}#library>header .np-reading-controls{margin-inline-start:auto}@media(max-width:680px){#player>nav .np-reading-panel{display:none}#player>nav .np-reading-open{display:block;width:38px;min-height:38px;padding:5px;flex:none}#player>nav .np-reading-controls{flex:none}#player>nav .np-reading-controls[data-open=true] .np-reading-panel{display:flex;position:absolute;inset-block-start:calc(100% + 8px);inset-inline-end:0;z-index:50;width:min(300px,calc(100vw - 24px));padding:12px;background:#fffefa;border:1px solid #bdcbbb;border-radius:12px;box-shadow:0 6px 24px #20362f33}}@media print{.np-reading-controls{display:none!important}}';document.head.append(style); + const homeHost=host||document.body,entryFrame=document.getElementById('game');function place(){if(entryFrame){const child=entryFrame.contentDocument;if(!child?.body)return;controls.classList.add('np-reading-compact');const updateRuby=event=>{const on=!!event?.detail?.enabled;ruby.setAttribute('aria-pressed',String(on));ruby.setAttribute('aria-label','ふりがな '+(on?'ON':'OFF'));ruby.title='ふりがな '+(on?'ON':'OFF')};if(!child.documentElement.dataset.npReadingEvents){child.documentElement.dataset.npReadingEvents='true';child.addEventListener('pointerdown',e=>{if(!controls.contains(e.target))closePanel()},true);child.addEventListener('keydown',e=>{if(e.key==='Escape'&&controls.dataset.open==='true'){closePanel();opener.focus()}},true);child.defaultView.addEventListener('nanpure-furigana-change',updateRuby)}if(controls.ownerDocument!==child)child.adoptNode(controls);const target=child.querySelector('.site-header .header-actions')||child.querySelector('.site-header')||child.body;if(controls.parentElement!==target)target.append(controls);if(!child.getElementById('np-reading-controls-style')){const childStyle=style.cloneNode(true);childStyle.id='np-reading-controls-style';child.head.append(childStyle)}updateRuby({detail:{enabled:entryFrame.contentWindow?.NPFurigana?.getEnabled()}});return}const target=document.querySelector('#player:not([hidden])>nav')||homeHost;if(controls.parentElement!==target)target.append(controls)}new MutationObserver(place).observe(document.body,{subtree:true,attributes:true,attributeFilter:['hidden']});entryFrame?.addEventListener('load',place);window.addEventListener('resize',place);queueMicrotask(place); + const style=document.createElement('style');style.textContent='body[data-game="shirupure"]>header,body[data-game="shirupure"]>.game-intro{display:none!important}'+'.np-reading-controls{position:relative;display:flex;align-items:center;flex-wrap:wrap;gap:6px;min-width:0}.np-reading-panel{display:flex;align-items:center;flex-wrap:wrap;gap:6px}.np-reading-open{display:none}.np-reading-language{display:flex;align-items:center;gap:4px}.np-reading-language select{font:inherit;max-width:148px;min-width:0;min-height:40px;border:1px solid #bdcbbb;border-radius:8px;background:#fffefa;color:inherit;padding:5px}.np-reading-compact{position:relative;inset:auto;z-index:2;display:flex;align-items:center;gap:4px;flex:none;padding:0;background:transparent;border:0;border-radius:0;box-shadow:none}.np-reading-compact .np-reading-open,.np-reading-compact .np-reading-ruby{display:inline-flex;align-items:center;justify-content:center;min-width:34px;width:34px;min-height:34px;padding:3px;border:1px solid #bdcbbb;border-radius:7px;background:#fffefa;color:#285849;font:700 13px system-ui,sans-serif}.np-reading-compact .np-reading-ruby{font-size:0}.np-reading-compact .np-reading-ruby::after{content:\'ふ\';font-size:13px}.np-reading-compact .np-reading-panel{display:none}.np-reading-compact[data-open=true] .np-reading-panel{display:flex;position:absolute;inset-block-start:calc(100% + 5px);inset-inline-end:0;z-index:50;width:min(260px,calc(100vw - 24px));padding:10px;background:#fffefa;border:1px solid #bdcbbb;border-radius:10px;box-shadow:0 6px 24px #20362f33}.np-reading-compact .np-reading-language select{min-height:36px}#library>header,#player>nav{flex-wrap:wrap;gap:8px}#library>header .np-reading-controls{margin-inline-start:auto}@media(max-width:680px){#player>nav .np-reading-panel{display:none}#player>nav .np-reading-open{display:block;width:38px;min-height:38px;padding:5px;flex:none}#player>nav .np-reading-controls{flex:none}#player>nav .np-reading-controls[data-open=true] .np-reading-panel{display:flex;position:absolute;inset-block-start:calc(100% + 8px);inset-inline-end:0;z-index:50;width:min(300px,calc(100vw - 24px));padding:12px;background:#fffefa;border:1px solid #bdcbbb;border-radius:12px;box-shadow:0 6px 24px #20362f33}}@media print{.np-reading-controls{display:none!important}}';document.head.append(style); const frame=document.getElementById('game'); async function sync(){try{const child=frame?.contentWindow;if(!child?.NPI18n)return;await child.NPI18n.ready;if(child.NPI18n.get()!==NPI18n.get())await child.NPI18n.set(NPI18n.get());child.NPFurigana?.setEnabled(NPFurigana.getEnabled(),false)}catch{}} frame?.addEventListener('load',sync);