diff --git a/assets/originData/yosan.ts b/assets/originData/yosan.ts index 7fc99ac..172e481 100644 --- a/assets/originData/yosan.ts +++ b/assets/originData/yosan.ts @@ -8,7 +8,6 @@ export default [ {"Station_JP" : "丸亀", "Station_EN" : "Marugame", "MyStation" : "5", "StationNumber" : "Y10", "DispNum" : "3", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/marugame.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.292006,133.793175", "JrHpUrl" : "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/marugame/"}, {"Station_JP" : "多度津", "Station_EN" : "Tadotsu", "MyStation" : "6", "StationNumber" : "Y12", "DispNum" : "3", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/tadotsu.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.271088,133.756735", "JrHpUrl" : "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/tadotsu/"}, {"Station_JP" : "海岸寺", "Station_EN" : "Kaiganji", "MyStation" : "7", "StationNumber" : "Y13", "DispNum" : "2", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/kaiganji.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.253932,133.729307", "JrHpUrl" : ""}, - {"Station_JP" : "津島ノ宮", "Station_EN" : "Tsushimanomiya", "MyStation" : "8", "StationNumber" : "Y13-x", "DispNum" : "3", "StationTimeTable" : "https://www.jr-shikoku.co.jp/03_news/pdf/20260714_20260805_tsushima-kaki-taisai.pdf", "StationMap":"https://maps.app.goo.gl/dS7waHbBeVRLZxUu9?g_st=ic", "JrHpUrl" : ""}, {"Station_JP" : "詫間", "Station_EN" : "Takuma", "MyStation" : "8", "StationNumber" : "Y14", "DispNum" : "3", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/takuma.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.220826,133.692737", "JrHpUrl" : "http://www.jr-shikoku.co.jp/01_trainbus/kakueki/takuma/"}, {"Station_JP" : "高瀬", "Station_EN" : "Takase", "MyStation" : "9", "StationNumber" : "Y16", "DispNum" : "2", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/takase.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.184083,133.711397", "JrHpUrl" : ""}, {"Station_JP" : "本山", "Station_EN" : "Motoyama", "MyStation" : "10", "StationNumber" : "Y18", "DispNum" : "2", "StationTimeTable" : "http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/motoyama.pdf", "StationMap":"https://www.google.co.jp/maps/place/34.146075,133.686473", "JrHpUrl" : ""}, diff --git a/lib/webViewInjectjavascript.ts b/lib/webViewInjectjavascript.ts index bad1bf1..56445ee 100644 --- a/lib/webViewInjectjavascript.ts +++ b/lib/webViewInjectjavascript.ts @@ -1094,134 +1094,6 @@ const setNewTrainItem = (element,hasProblem,type)=>{ } } - -// 公式サイトの予讃線マスターには通常、臨時駅の津島ノ宮が含まれない。 -// 津島ノ宮は交換設備のない棒線駅なので、独立した stationBlock は作らず、 -// 海岸寺—詫間の駅間中央レーンへ「みの」と同じ小駅マーカーを複製する。 -// 公式の位置データも「海岸寺~詫間」単位のため、この構造なら列車位置を -// 分割せず、そのまま正しく表示できる。 -const injectTsushimanomiyaStation = () => { - const disp = document.getElementById('disp'); - if (!disp || disp.querySelector('[data-jrs-tsushimanomiya="bar-station"]')) return; - - const stationBlocks = Array.from(disp.querySelectorAll(':scope > [id^="stationBlock"]')); - const findStationBlock = (jpName, enName) => stationBlocks.find((block) => { - const stationArea = block.children[1]; - const text = ((stationArea && stationArea.textContent) || '').replace(/\\s/g, ''); - return text.includes(jpName) || text.toLowerCase().includes(enName.toLowerCase()); - }); - const kaiganjiBlock = findStationBlock('海岸寺', 'Kaiganji'); - const takumaBlock = findStationBlock('詫間', 'Takuma'); - if (!kaiganjiBlock || !takumaBlock) return; - const hasBetweenLayout = (element) => { - if (!element) return false; - const parts = element.querySelectorAll( - ':scope > [id^="Up"], :scope > [id^="Id"], :scope > [id^="Down"]' - ); - return parts.length >= 3; - }; - // まず駅名を含む正式な駅間行を探し、見つからない場合だけ - // 海岸寺から詫間までの兄弟要素を構造検査しながら走査する。 - let betweenBlock = Array.from(disp.children).find((element) => { - const id = element.id || ''; - return id.includes('海岸寺') && id.includes('詫間') && hasBetweenLayout(element); - }); - if (!betweenBlock) { - let candidate = kaiganjiBlock.nextElementSibling; - while (candidate && candidate !== takumaBlock && candidate.parentElement === disp) { - if (hasBetweenLayout(candidate)) { - betweenBlock = candidate; - break; - } - candidate = candidate.nextElementSibling; - } - } - if (!betweenBlock) return; - - const targetCenterLane = betweenBlock.querySelector(':scope > [id^="Id"]'); - if (!targetCenterLane) return; - - // 同じ予讃線上の棒線駅「みの」をテンプレートにする。駅間中央レーンの - // 直下だけを調べ、列車の行先表示などに含まれる「みの」は拾わない。 - const barStationMarkers = Array.from(disp.querySelectorAll( - ':scope > [id*="~"] > [id^="Id"] > div' - )); - const minoMarker = barStationMarkers.find((marker) => { - const text = ((marker.textContent || '').replace(/\\s/g, '')); - return text.includes('みの') || text.toLowerCase().includes('mino'); - }); - if (!minoMarker) return; - - const stationMarker = minoMarker.cloneNode(true); - stationMarker.setAttribute('data-jrs-tsushimanomiya', 'bar-station'); - - const replaceText = (root, from, to) => { - const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT); - let node; - while ((node = walker.nextNode())) { - if (node.nodeValue && node.nodeValue.includes(from)) { - node.nodeValue = node.nodeValue.split(from).join(to); - } - } - }; - replaceText(stationMarker, 'みの', '津島ノ宮'); - replaceText(stationMarker, 'Mino', 'Tsushimanomiya'); - // 駅番号が Y / 15 の別テキストノードで組まれている表示に対応する。 - replaceText(stationMarker, '15', '13-x'); - - const tsushimaPdf = 'https://www.jr-shikoku.co.jp/03_news/pdf/20260714_20260805_tsushima-kaki-taisai.pdf'; - const rewriteStationValue = (source) => source - .split('みの').join('津島ノ宮') - .split('Mino').join('Tsushimanomiya') - .split('Y15').join('Y13-x'); - [stationMarker, ...stationMarker.querySelectorAll('*')].forEach((element) => { - Array.from(element.attributes || []).forEach((attribute) => { - const value = rewriteStationValue(attribute.value); - if (value !== attribute.value) element.setAttribute(attribute.name, value); - }); - }); - // 複製元と同じIDが残ると駅メニューが誤認するため、ルートIDは必ず固有化する。 - stationMarker.id = 'stY13-x津島ノ宮'; - - // 複製元で付与済みのアプリ側ハンドラーやバッジを持ち越さない。 - // 棒線駅は内側にも駅クリック用要素を持つ版があり、そのままだと内側の - // 「みの」ハンドラーが先に発火するため、クリック対象は外側の1つに統一する。 - stationMarker.removeAttribute('offclick'); - stationMarker.querySelectorAll('*').forEach((element) => { - element.removeAttribute('onclick'); - element.removeAttribute('offclick'); - element.onclick = null; - if ((element.id || '').indexOf('st') === 0) element.removeAttribute('id'); - }); - stationMarker.querySelectorAll('.trainstatus').forEach((badge) => badge.remove()); - stationMarker.setAttribute( - 'onclick', - \"PopUpMenu(event,'13-x','津島ノ宮','\" + tsushimaPdf - + \"','https://maps.app.goo.gl/dS7waHbBeVRLZxUu9?g_st=ic','','1')\" - ); - stationMarker.addEventListener('click', (event) => { - event.preventDefault && event.preventDefault(); - event.stopImmediatePropagation && event.stopImmediatePropagation(); - window.ReactNativeWebView.postMessage(JSON.stringify({ - type: 'PopUpMenu', - event: String(event || ''), - id: '13-x', - name: '津島ノ宮', - pdf: tsushimaPdf, - map: 'https://maps.app.goo.gl/dS7waHbBeVRLZxUu9?g_st=ic', - url: '', - chk: '1' - })); - return false; - }, true); - - // 海岸寺~詫間の中央レーンには空のプレースホルダーが残る版がある。 - // append すると空区画+津島ノ宮の2ブロックになるため、中央内容を置き換える。 - while (targetCenterLane.firstChild) { - targetCenterLane.removeChild(targetCenterLane.firstChild); - } - targetCenterLane.appendChild(stationMarker); -}; //列番付与 const setStrings = () =>{ try { @@ -1307,7 +1179,6 @@ const setStrings = () =>{ }); } - try { injectTsushimanomiyaStation(); } catch(e) {} ${uiSetting === "tokyo" ? `setNewTrainItemUI();`: ``} for (let element of elements) { if(element.getAttribute('offclick')){ continue; }