/* * 地図画面判定 */ var script_name = location.pathname; var nmap_flag = script_name.includes('nmap.htm'); var dtl_flag = script_name.includes('/map/'); if( nmap_flag == true || dtl_flag == true ){ var map_flag = true; } /* * 吹き出し調整 */ window.addEventListener("load",function(){ // 地図画面以外のとき処理終了 if( map_flag !== true ){ return; } setMO(callback, '#ZdcEmapMap'); }); /* * 監視対象に指定の変更が発生したとき実行 * * @param mutations 発生した変更内容を表す配列 */ function callback(mutations){ // 発生した変更内容 mutations.forEach( mutation => { // 追加されたノードごとに mutation.addedNodes.forEach( node => { // divタグのとき(大文字でないと動かないので注意) if(node.nodeName==='DIV') { // 要素を利用してnodeの中から目印のタグを取得 const color = node.style.backgroundColor; if(color === 'rgb(236, 236, 224)'){ var child = node.childNodes; // これより深い階層はこの段階では取得できない for (var i = 0; i < child.length; i++) { for (var j = 0; j < child[i].childNodes.length; j++) { // idを付与 child[i].childNodes[j].setAttribute('id', 'div_' + i + '_' + j); } } setMO(callback2, '#div_4_1'); } } }); }); } function callback2(mutations){ // 発生した変更内容 mutations.forEach( mutation => { // 追加されたノードごとに mutation.addedNodes.forEach( node => { // divタグのとき(大文字でないと動かないので注意) if(node.nodeName==='DIV') { // nodeの中からimgタグを取得 const img_tag = node.querySelectorAll('img'); // 店舗アイコンのimgタグにclass=shop_iconを付与 img_tag[0].setAttribute('class', 'shop_icon'); } }); }); // 全店舗アイコンを取得 const btn = document.querySelectorAll('.shop_icon'); // ロードされたら for (var i = 0; i < btn.length; i++) { btn[i].addEventListener('load',()=>{ // いずれかの店舗アイコンをクリックされたとき for (var j = 0; j < btn.length; j++) { btn[j].addEventListener('click',()=>{ console.log('クリックされた'); setMO(callback3, '#div_4_3'); }); } }); } } function callback3(mutations){ // 発生した変更内容 mutations.forEach( mutation => { // 追加されたノードごとに mutation.addedNodes.forEach( node => { // 既存吹き出しの残骸を特定 var div_tag = document.querySelectorAll('#div_4_3'); var grandchild_ = div_tag[0].childNodes[0].childNodes[0].childNodes; for (var j = 0; j < grandchild_.length; j++) { grandchild_[j].setAttribute('id', 'div_4_3_' + j); } // 非表示 document.querySelector('#div_4_3_1').style.visibility = 'hidden'; // 既存吹き出しの残骸(しっぽ) var span_tag = div_tag[0].childNodes[1].querySelectorAll('span'); // 非表示 span_tag[0].style.visibility = 'hidden'; }); }); } /* * MutationObserverを作成 */ function setMO(callback_function_name, selector){ // Observerインスタンスを生成 const mutationObserver = new MutationObserver(callback_function_name); // 監視対象ノードを設定 const target_node = document.querySelector(selector); // options // childList node の直接の子の変更 // subtree node のすべての子孫に対する変更 // attributes node の属性の変更 // attributeFilter 指定したものだけを監視するための、属性の配列 // characterData node.data (テキストコンテンツ) を監視するかどうか const option = { childList: true , subtree: true , attributes: false // , attributeFilter: false , characterData: false }; // インスタンスに設定 mutationObserver.observe(target_node, option); } /* * タブ色調整 * フリーワード検索結果が住所のみの場合に * 駅タブをグレーにする */ window.addEventListener("load",function(){ var script_name = location.pathname; var fw_flag = script_name.includes('search_fw.htm'); // フリーワード検索結果画面以外のとき処理終了 if( fw_flag !== true ){ return; } // 駅タブのspanタグ const count_span = document.querySelector('#ZdcEmapSearchFWTab1 span'); // 駅タブの件数 const count_text = count_span.textContent; // 0件のとき if(count_span.textContent === '0件'){ // 駅タブのonクラスを削除 document.querySelector('#ZdcEmapSearchFWTab1').setAttribute('class', ''); } });