diff --git a/lib/webViewInjectjavascript.ts b/lib/webViewInjectjavascript.ts index a2e8260..3645b7f 100644 --- a/lib/webViewInjectjavascript.ts +++ b/lib/webViewInjectjavascript.ts @@ -2,13 +2,15 @@ type InjectJavascriptData = ( a: string, b: string, c: string, - d: string + d: string, + e: string ) => string; export const injectJavascriptData: InjectJavascriptData = ( mapSwitch, iconSetting, stationMenu, - trainMenu + trainMenu, + uiSetting ) => { // 一番上のメニュー非表示 地図スイッチによって切り替え const topMenu = @@ -1247,11 +1249,17 @@ export const injectJavascriptData: InjectJavascriptData = ( const returnText1 = (isWanman ? "ワンマン " : "") + trainName + viaData; const returnText2 = (ToData ? ToData+"行 " : ToData)+ TrainNumber; 行き先情報.innerText = ""; - 行き先情報.insertAdjacentHTML('beforebegin', "
" + (ToData ? ToData + "行 " : ToData) + "
"); - 行き先情報.insertAdjacentHTML('beforebegin', "" + returnText1 + "
"); - 行き先情報.insertAdjacentHTML('beforebegin', "" + TrainNumber + (JRF ? "":"レ") + "
"); - 行き先情報.insertAdjacentHTML('beforebegin', "" + (hasProblem ? "‼️停止中‼️" : "") + "
"); - } + ${uiSetting === "tokyo" ? ` + 行き先情報.insertAdjacentHTML('beforebegin', "" + (ToData ? ToData + "行 " : ToData) + "
"); + 行き先情報.insertAdjacentHTML('beforebegin', "" + returnText1 + "
"); + 行き先情報.insertAdjacentHTML('beforebegin', "" + TrainNumber + (JRF ? "":"レ") + "
"); + 行き先情報.insertAdjacentHTML('beforebegin', "" + (hasProblem ? "‼️停止中‼️" : "") + "
"); + `: ` + 行き先情報.insertAdjacentHTML('beforebegin', "" + returnText1 + "
"); + 行き先情報.insertAdjacentHTML('beforebegin', "" + (ToData ? ToData + "行 " : ToData) + "
" + TrainNumber + (JRF ? "":"レ") + "
" + (hasProblem ? "‼️停止中‼️" : "") + "
"); + `} + } `; const textInsert = @@ -1293,58 +1301,62 @@ const setNewTrainItem = (element)=>{ const setStrings = () =>{ try { const elements = document.querySelectorAll('#disp > div > div > div[onclick]'); - const elementBaseBase = document.querySelectorAll('[id^="stationBlock"]'); - elementBaseBase.forEach(e=>{ //それぞれの駅ブロック横一列 - e.style.display = 'flex'; - e.style.height = "unset"; - e.style.flexDirection = 'row'; - //e.style.alignItems = "left"; - e.style.justifyContent = 'center'; - const x = e.querySelectorAll(':scope > div');//配下のdiv要素を選択 - //x[0] 登りブロック x[2] 下りブロック x[1] 駅ブロック - const aaa = (x2,pos) => { - x2.style.display = 'flex'; - x2.style.flexDirection = 'row'; - if(pos == "right"){ - x2.style.alignItems = 'flex-start'; - x2.style.justifyContent = 'flex-start'; - }else if(pos == "left"){ - x2.style.alignItems = 'flex-end'; - x2.style.justifyContent = 'flex-end'; + const setNewTrainItemUI = ()=>{ + const elementBaseBase = document.querySelectorAll('[id^="stationBlock"]'); + elementBaseBase.forEach(e=>{ //それぞれの駅ブロック横一列 + e.style.display = 'flex'; + e.style.height = "unset"; + e.style.flexDirection = 'row'; + //e.style.alignItems = "left"; + e.style.justifyContent = 'center'; + const x = e.querySelectorAll(':scope > div');//配下のdiv要素を選択 + //x[0] 登りブロック x[2] 下りブロック x[1] 駅ブロック + const aaa = (x2,pos) => { + x2.style.display = 'flex'; + x2.style.flexDirection = 'row'; + if(pos == "right"){ + x2.style.alignItems = 'flex-start'; + x2.style.justifyContent = 'flex-start'; + }else if(pos == "left"){ + x2.style.alignItems = 'flex-end'; + x2.style.justifyContent = 'flex-end'; + } + x2.style.flexWrap = 'wrap'; + x2.style.width = '100%'; + x2.style.height = "100%"; + } - x2.style.flexWrap = 'wrap'; - x2.style.width = '100%'; - x2.style.height = "100%"; - - } - const aaa2 = (x2) => { - x2.style.display = 'flex'; - x2.style.flexDirection = 'row'; - x2.style.alignItems = 'center'; - x2.style.justifyContent = 'center'; - x2.style.flexWrap = 'wrap'; - x2.style.width = '100%'; - x2.style.height = "unset"; - const x3 = x2.querySelectorAll(":scope > div"); - x3.forEach(i=>{ - i.style.position = "unset"; - i.style.display = "flex"; - i.style.flexDirection = "column"; - i.style.flex = "1"; - i.style.backgroundColor = "#00000000"; - i.querySelectorAll(":scope > *").forEach(j=>{ - j.style.width = "100%"; - j.style.textAlign = "center"; - j.style.margin = "5px"; - j.style.padding = "5px"; + const aaa2 = (x2) => { + x2.style.display = 'flex'; + x2.style.flexDirection = 'row'; + x2.style.alignItems = 'center'; + x2.style.justifyContent = 'center'; + x2.style.flexWrap = 'wrap'; + x2.style.width = '100%'; + x2.style.height = "unset"; + const x3 = x2.querySelectorAll(":scope > div"); + x3.forEach(i=>{ + i.style.position = "unset"; + i.style.display = "flex"; + i.style.flexDirection = "column"; + i.style.flex = "1"; + i.style.backgroundColor = "#00000000"; + i.querySelectorAll(":scope > *").forEach(j=>{ + j.style.width = "100%"; + j.style.textAlign = "center"; + j.style.margin = "5px"; + j.style.padding = "5px"; + }); }); - }); - } - aaa(x[0],"left"); - aaa2(x[1]); - aaa(x[2],"right"); - - }); + } + aaa(x[0],"left"); + aaa2(x[1]); + aaa(x[2],"right"); + + }); + } + + ${uiSetting === "tokyo" ? `setNewTrainItemUI();`: ``} for (let element of elements) { if(element.getAttribute('offclick')){ continue; } element.setAttribute('offclick',element.getAttribute('onclick')) @@ -1375,7 +1387,7 @@ const setStrings = () =>{ } ` : ""} nameReplace(列車名データ,列番データ,行き先情報,hasProblem); - setNewTrainItem(element); + ${uiSetting === "tokyo" ? `setNewTrainItem(element);`: ``} } try{ for(let d of document.getElementById('disp').childNodes){