window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-JWK3QQTE2X');
var scriptAdded = false;
window.addEventListener('scroll', function() {
// スクロールが検知されたら実行
if (!scriptAdded) {
// 新しい script 要素を作成
var newScript = document.createElement('script');
newScript.src = 'https://www.googletagmanager.com/gtag/js?id=G-JWK3QQTE2X';
newScript.async = true;
// head 要素に追加
var head = document.head || document.getElementsByTagName('head')[0];
head.appendChild(newScript);
// スクリプトが追加されたことを記録
scriptAdded = true;
}
});
var lazyloadads = false;
function load_gads(){
var ad = document.createElement('script');
ad.type = 'text/javascript';
ad.async = true;
ad.dataset.adClient = 'ca-pub-9120995133302056';
ad.src = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
var sc = document.getElementsByTagName('script')[0];
sc.parentNode.insertBefore(ad, sc);
}
function lazy_load_gads(){
if (lazyloadads) {
return;
}
lazyloadads = true;
window.removeEventListener('scroll', lazy_load_gads);
window.removeEventListener('mousemove', lazy_load_gads);
window.removeEventListener('mousedown', lazy_load_gads);
window.removeEventListener('touchstart', lazy_load_gads);
window.removeEventListener('keydown', lazy_load_gads);
load_gads();
}
document.addEventListener('DOMContentLoaded',()=>{
window.addEventListener('scroll', lazy_load_gads);
window.addEventListener('mousemove', lazy_load_gads);
window.addEventListener('mousedown', lazy_load_gads);
window.addEventListener('touchstart', lazy_load_gads);
window.addEventListener('keydown', lazy_load_gads);
});