observerの設置変更
This commit is contained in:
parent
0ff05f911c
commit
cdea9a1e05
@ -23,9 +23,7 @@ export const injectJavascriptData = (
|
||||
`;
|
||||
|
||||
// 何これ
|
||||
const bootData =
|
||||
topMenu +
|
||||
`
|
||||
const bootData = `
|
||||
const setReload = () =>{
|
||||
try{
|
||||
document.getElementById('refreshIcon').click();
|
||||
@ -579,8 +577,7 @@ const setStrings = () =>{
|
||||
try {
|
||||
const elements =[];
|
||||
document.querySelectorAll('#disp div div div').forEach(d=>{
|
||||
if(d.onclick)if(d.onclick.toString().match("ShowTrainTimeInfo"))
|
||||
elements.push(d)
|
||||
if(d.onclick)elements.push(d)
|
||||
});
|
||||
for (let element of elements) {
|
||||
var 行き先情報 = element.getElementsByTagName("p")[0];
|
||||
@ -672,16 +669,12 @@ const setStrings = () =>{
|
||||
alert("にゃーん");
|
||||
}
|
||||
} catch (e) {}
|
||||
//setTimeout(setStrings,500);
|
||||
}
|
||||
const target = document.getElementById('disp'); // body要素を監視
|
||||
const observer = new MutationObserver( (mutations) => {
|
||||
// observer.disconnect(); // 監視を終了
|
||||
setStrings();
|
||||
});
|
||||
|
||||
const textInsert = new MutationObserver( (mutations) => setStrings());
|
||||
|
||||
// 監視を開始
|
||||
observer.observe(target, {
|
||||
textInsert.observe(document.getElementById('disp'), {
|
||||
attributes: true, // 属性変化の監視
|
||||
//attributeOldValue: true, // 変化前の属性値を matation.oldValue に格納する
|
||||
//characterData: true, // テキストノードの変化を監視
|
||||
@ -693,9 +686,8 @@ observer.observe(target, {
|
||||
|
||||
const makeTrainView = `
|
||||
|
||||
const modal_content = document.getElementById('modal_content'); // body要素を監視
|
||||
const modal_observer = new MutationObserver( (mutations) => {
|
||||
// observer.disconnect(); // 監視を終了
|
||||
const makeTrainView = new MutationObserver( (mutations) => {
|
||||
|
||||
for(let d of modal_content.getElementsByTagName("button") ){
|
||||
const data = d.onclick.toString().split("\\"")[1];
|
||||
d.onclick = () => window.ReactNativeWebView.postMessage(data)
|
||||
@ -703,7 +695,7 @@ const modal_observer = new MutationObserver( (mutations) => {
|
||||
});
|
||||
|
||||
// 監視を開始
|
||||
modal_observer.observe(modal_content, {
|
||||
makeTrainView.observe(document.getElementById('modal_content'), {
|
||||
//attributes: true, // 属性変化の監視
|
||||
//attributeOldValue: true, // 変化前の属性値を matation.oldValue に格納する
|
||||
//characterData: true, // テキストノードの変化を監視
|
||||
@ -712,17 +704,22 @@ modal_observer.observe(modal_content, {
|
||||
//subtree: true // 子孫ノードも監視対象に含める
|
||||
});
|
||||
`;
|
||||
const makeStationMenu =
|
||||
stationMenu == "true"
|
||||
? 'function PopUpMenu(event,id,name,pdf,map,url,chk){window.ReactNativeWebView.postMessage(JSON.stringify({type:"PopUpMenu",event,id,name,pdf,map,url,chk}));}'
|
||||
: ``;
|
||||
|
||||
const makeTrainMenu =
|
||||
//trainMenu == "true"
|
||||
true
|
||||
? `
|
||||
function ShowTrainTimeInfo(trainNum,limited){
|
||||
window.ReactNativeWebView.postMessage(JSON.stringify({type:"ShowTrainTimeInfo",trainNum,limited}));
|
||||
};
|
||||
`
|
||||
: ``;
|
||||
|
||||
const makeStationMenu =
|
||||
stationMenu == "true"
|
||||
? `
|
||||
//駅メニューダイアログの配置
|
||||
const setStationMenuDialog = () =>{
|
||||
|
||||
const setStationMenuDialog = new MutationObserver( (mutations) => {
|
||||
const data =[];
|
||||
document.querySelectorAll('#disp div div').forEach(d=>d.id.indexOf("st")!= -1 && data.push(d));
|
||||
|
||||
@ -738,15 +735,10 @@ const setStationMenuDialog = () =>{
|
||||
window.ReactNativeWebView.postMessage(JSON.stringify({type:"PopUpMenu",event:s[0],id:s[1],name:s[2],pdf:s[3],map:s[4],url:s[5],chk:s[6]}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const observer3 = new MutationObserver( (mutations) => {
|
||||
// observer3.disconnect(); // 監視を終了
|
||||
setStationMenuDialog();
|
||||
});
|
||||
|
||||
// 監視を開始
|
||||
observer3.observe(target, {
|
||||
setStationMenuDialog.observe(document.querySelector('#disp'), {
|
||||
attributes: true, // 属性変化の監視
|
||||
//attributeOldValue: true, // 変化前の属性値を matation.oldValue に格納する
|
||||
//characterData: true, // テキストノードの変化を監視
|
||||
@ -755,14 +747,10 @@ observer3.observe(target, {
|
||||
//subtree: true // 子孫ノードも監視対象に含める
|
||||
});
|
||||
`
|
||||
: // `
|
||||
// function ShowTrainTimeInfo(trainNum,limited){
|
||||
// window.ReactNativeWebView.postMessage(JSON.stringify({type:"ShowTrainTimeInfo",trainNum,limited}));
|
||||
// };
|
||||
// `
|
||||
``;
|
||||
: ``;
|
||||
return (
|
||||
bootData +
|
||||
topMenu +
|
||||
makeTrainView +
|
||||
trainIconMaker +
|
||||
textInsert +
|
||||
|
Loading…
Reference in New Issue
Block a user