window.addEventListener('DOMContentLoaded', function () { var ua = navigator.userAgent; if (localStorage.getItem('aaac_i_ima') != undefined && localStorage.getItem('aaac_i_ima') > (new Date().getTime())) { return; } var exclude_flag = false; var exclude_class = null; var aaa_xhr_success = function (data, link_url, view_url, vt_url , vt_time) { if (typeof data == 'string') { data = JSON.parse(data); } if ( !((Math.random() * 100) < data['rate']) || (!data['article']['movie']) || (!data['prop']['movie']) ) { return; } var vt_flag = false; if (!(typeof vt_url !== "undefined" && typeof vt_time !== "undefined")){ var vt_url = false; var vt_time = false; vt_flag = true; } var audio_flag = false; if (data['article']['audio_flag'] === 1){ audio_flag = true; var audio_reset_flag = false; } var appendIframe = function(){ var oct_iframe = document.createElement('iframe'); oct_iframe.id = 'octopus_vtfrm'; oct_iframe.src = vt_url; oct_iframe.display = 'none'; oct_iframe.setAttribute('width', '1'); oct_iframe.setAttribute('height', '1'); document.body.appendChild(oct_iframe); } var movie_width = data['prop']['movie'].match(/^\d+/)[0]; var movie_height = data['prop']['movie'].match(/\d+$/)[0]; var resizeWindow = function(){ var v_width = (window.innerWidth * 0.8 - 40); var v_height = (window.innerHeight * 0.8 - 55 - 70); if(v_height <= 0 ) { v_width = 0; v_height = 0; document.getElementById('ima_i_button_outer').style.display = 'none'; if (audio_flag){ document.getElementById('ima_i_muted_switch').style.display = 'none'; } } else if ((v_width / v_height) < (movie_width / movie_height)){ v_height = v_width * movie_height / movie_width; document.getElementById('ima_i_button_outer').style.display = 'flex'; if (audio_flag){ document.getElementById('ima_i_muted_switch').style.display = 'block'; } } else { v_width = v_height * movie_width / movie_height; document.getElementById('ima_i_button_outer').style.display = 'flex'; if (audio_flag){ document.getElementById('ima_i_muted_switch').style.display = 'block'; } } document.getElementById('ima_i_video_outer').style.width = v_width + 'px'; document.getElementById('ima_i_video_outer').style.height = v_height + 'px'; }; if (document.referrer.match(/https?:\/\/([^\/]+)(?:\/|$)/) && location.hostname === document.referrer.match(/https?:\/\/([^\/]+)(?:\/|$)/)[1]){ localStorage.setItem('aaac_i_ima', new Date().getTime() + (data['cookie'] * 1000)); var diff; var lastTime = 0; var wrap = document.createElement('div'); wrap.style.setProperty('margin', '0', 'important'); wrap.style.setProperty('border', 'none', 'important'); wrap.style.setProperty('padding', '0', 'important'); wrap.style.setProperty('position', 'fixed', 'important'); wrap.style.setProperty('min-width', 'auto', 'important'); wrap.style.setProperty('max-width', 'none', 'important'); wrap.style.setProperty('min-height', 'auto', 'important'); wrap.style.setProperty('max-height', 'none', 'important'); wrap.style.setProperty('z-index', '1000000000000', 'important'); wrap.style.setProperty('left', '0', 'important'); wrap.style.setProperty('top', '0', 'important'); wrap.style.setProperty('right', '0', 'important'); wrap.style.setProperty('bottom', '0', 'important'); if (audio_flag){ var audio_html = ''; } else { var audio_html = ''; } wrap.innerHTML = '
' + '' + '
' + '

広告×

' + '
'+ audio_html +'
' + '
' + '
閉じる
' + '
開く
' + '
' + '
' + '
'; document.body.appendChild(wrap); var video = document.querySelector('#ima_i_video'); document.querySelector('#ima_i_close').addEventListener('click', function (event) { event.stopPropagation(); window.removeEventListener('resize', resizeWindow); clearInterval(set_timer); document.body.removeChild(wrap); }); document.querySelector('#ima_i_close2').addEventListener('click', function (event) { event.stopPropagation(); window.removeEventListener('resize', resizeWindow); clearInterval(set_timer); document.body.removeChild(wrap); }); document.querySelector('#ima_i_open').addEventListener('click', function (event) { var XHR = new XMLHttpRequest(); XHR.open('POST', data['click'], true); XHR.send(''); window.open(link_url); }); if (audio_flag){ document.querySelector('#ima_i_muted_switch').addEventListener('click', function (event) { event.stopPropagation(); if (video.muted == true){ if (!audio_reset_flag){ video.currentTime = 0; lastTime = 0; audio_reset_flag = true; } video.muted = false; document.getElementById('ima_i_muted_switch').setAttribute('src', 'https://srv1.aaacompany.net/om/i/s_on.png'); } else { video.muted = true; document.getElementById('ima_i_muted_switch').setAttribute('src', 'https://srv1.aaacompany.net/om/i/s_off.png'); } }); } var set_timer = setInterval(function () { diff = video.currentTime - lastTime; lastTime = video.currentTime; if (diff < 0){ if (vt_time === 999 && !vt_flag){ appendIframe(); var XHR = new XMLHttpRequest(); XHR.open('POST', data['view'], true); XHR.send(''); vt_flag = true; } } if (!vt_flag && ((audio_reset_flag && (vt_time - 5) < video.currentTime) || (!audio_reset_flag && vt_time < video.currentTime))){ appendIframe(); var XHR = new XMLHttpRequest(); XHR.open('POST', data['view'], true); XHR.send(''); vt_flag = true; } }, 1000 / 30); window.addEventListener('resize', resizeWindow); document.getElementById('ima_i_video_outer').style.height = (document.querySelector('#ima_i_open').clientHeight - 70 - 55) + 'px'; resizeWindow(); } else { var href_str; if (location.href.indexOf('#') === -1){ href_str = location.href; } else { href_str = location.href.substring(0, location.href.indexOf("#")); } var re = new RegExp('^'+ href_str.split('.').join('\\.').split('?').join('\\?') +'#'); var elFunc = function(e){ var element = e.target; while (element !== undefined && element !== null && element.tagName !== 'HTML' && element.tagName !== 'A') { element = element.parentElement; } if (element.tagName ==='A' && element.href !== undefined && element.href !== '' && !element.href.match(re) && !element.href.match(/^javascript:/) && !(element.href.match(/https?:\/\/([^\/]+)(?:\/|$)/) && location.hostname === element.href.match(/https?:\/\/([^\/]+)(?:\/|$)/)[1]) && (!(exclude_flag === true && element.classList.contains(exclude_class)))) { e.preventDefault(); var target_attr; if(element.target == '_blank'){ target_attr = ' target="_blank"'; } else { target_attr = ''; } localStorage.setItem('aaac_i_ima', new Date().getTime() + (data['cookie'] * 1000)); if (audio_flag){ var audio_html = ''; } else { var audio_html = ''; } var wrap = document.createElement('div'); wrap.style.setProperty('margin', '0', 'important'); wrap.style.setProperty('border', 'none', 'important'); wrap.style.setProperty('padding', '0', 'important'); wrap.style.setProperty('position', 'fixed', 'important'); wrap.style.setProperty('min-width', 'auto', 'important'); wrap.style.setProperty('max-width', 'none', 'important'); wrap.style.setProperty('min-height', 'auto', 'important'); wrap.style.setProperty('max-height', 'none', 'important'); wrap.style.setProperty('z-index', '1000000000000', 'important'); wrap.style.setProperty('left', '0', 'important'); wrap.style.setProperty('top', '0', 'important'); wrap.style.setProperty('right', '0', 'important'); wrap.style.setProperty('bottom', '0', 'important'); wrap.innerHTML = '
' + '' + '
' + '

広告×

' + '
'+ audio_html +'
' + '
' + '閉じる' + '
開く
' + '
' + '
' + '
'; document.body.appendChild(wrap); var video = document.querySelector('#ima_i_video'); document.querySelector('#ima_i_close').addEventListener('click', function (event) { event.stopPropagation(); window.removeEventListener('resize', resizeWindow); clearInterval(set_timer); document.body.removeChild(wrap); }); document.querySelector('#ima_i_close2').addEventListener('click', function (event) { event.stopPropagation(); window.removeEventListener('resize', resizeWindow); clearInterval(set_timer); document.body.removeChild(wrap); }); document.querySelector('#ima_i_open').addEventListener('click', function (event) { var XHR = new XMLHttpRequest(); XHR.open('POST', data['click'], true); XHR.send(''); window.open(link_url); }); if (audio_flag){ document.querySelector('#ima_i_muted_switch').addEventListener('click', function (event) { event.stopPropagation(); var video = document.querySelector('#ima_i_video'); if (video.muted == true){ if (!audio_reset_flag){ video.currentTime = 0; lastTime = 0; audio_reset_flag = true; } video.muted = false; document.getElementById('ima_i_muted_switch').setAttribute('src', 'https://srv1.aaacompany.net/om/i/s_on.png'); } else { video.muted = true; document.getElementById('ima_i_muted_switch').setAttribute('src', 'https://srv1.aaacompany.net/om/i/s_off.png'); } }); } var set_timer = setInterval(function () { diff = video.currentTime - lastTime; lastTime = video.currentTime; if (diff < 0){ if (vt_time === 999 && !vt_flag){ appendIframe(); var XHR = new XMLHttpRequest(); XHR.open('POST', data['view'], true); XHR.send(''); vt_flag = true; } } if (!vt_flag && ((audio_reset_flag && (vt_time - 5) < video.currentTime) || (!audio_reset_flag && vt_time < video.currentTime))){ appendIframe(); var XHR = new XMLHttpRequest(); XHR.open('POST', data['view'], true); XHR.send(''); vt_flag = true; } }, 1000 / 30); document.removeEventListener('click', elFunc); window.addEventListener('resize', resizeWindow); document.getElementById('ima_i_video_outer').style.height = (document.querySelector('#ima_i_open').clientHeight - 70 - 55) + 'px'; resizeWindow(); } } } document.addEventListener('click', elFunc); } var oct_xhr_success = function (json_data) { if (typeof json_data == 'string') { json_data = JSON.parse(json_data); } if ( typeof json_data['click_url'] === "undefined" || json_data['click_url'] == '' || typeof json_data['view_url'] === "undefined" || json_data['view_url'] == '' || (!/(\?|&)_article=\d+($|&)/.test(json_data['click_url'])) ) { return; } var article_id = json_data['click_url'].match(/(\?|&)_article=(\d+)($|&)/)[2]; var json_url = 'https://srv1.aaacompany.net/om_res.php?spot=83134&article=' + article_id + '&_=' + new Date().getTime(); var xhr = new XMLHttpRequest(); xhr.ontimeout = function () { console.error("The aaacompany request timed out."); }; xhr.onload = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { aaa_xhr_success(xhr.response, json_data['click_url'], json_data['view_url'], json_data['vt_url'], json_data['vt_time']); } else { console.error(xhr.statusText); } } }; xhr.open("GET", json_url, true); xhr.timeout = 3000; xhr.responseType = 'json'; xhr.send(null); }; (function () { var isIos = function () { var b, c, d; b = window.navigator.userAgent.toLowerCase(); c = 0 <= b.indexOf('iphone'); d = 0 <= b.indexOf('ipod'); b = 0 <= b.indexOf('ipad'); return c || d || b ? !0 : !1 }; var iPhoneModels = { 479: "iphone3", 480: "iphone4", 568: "iphone5", 667: "iphone6", 736: "iphone6p", 737: "iphone6" }; var displayMinSize = 479; var displayMaxSize = 737; var getModelName = function (b) { return !1 === isIos() ? '' : iPhoneModels[displayMinSize > b ? displayMinSize : displayMaxSize < b ? displayMaxSize : b] }; var i_type = getModelName(window.screen.height); var json_url = 'https://ap.octopuspop.com/deliver/?_spot=83134&_iphone_type=' + i_type + '&_ver=' + new Date().getTime(); var xhr = new XMLHttpRequest(); xhr.ontimeout = function () { console.error("The octopus request timed out."); }; xhr.onload = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { oct_xhr_success(xhr.response); } else { console.error(xhr.statusText); } } }; xhr.open("GET", json_url, true); xhr.timeout = 3000; xhr.responseType = 'json'; xhr.send(null); })(); });