`; document.body.insertAdjacentHTML('afterbegin', pfxHtml); const script = document.createElement('script'); script.setAttribute('data-ca-profitx-pageid', `${settings.pfx_pageid}`); script.src = `https://cdn.caprofitx.com/media/${settings.pfx_mediaid}/pfx.js`; script.type = 'text/javascript'; script.charset = 'utf-8'; script.setAttribute('data-ca-profitx-js', ''); script.async = true; document.getElementsByTagName("body")[0].appendChild(script); } function mayDisplayAdCustom(){ const urlObj = new URL(window.location.href); const currentHostname = urlObj.hostname; const referrerObj = document.referrer === "" ? null : new URL(document.referrer); const referrerHostname = referrerObj?.hostname || ""; if (isExternalTraffic()) { console.log("external traffic"); return false; } if (!isGalleryPage()) { console.log("not gallery page"); return false; } return true; // 画像ページかどうかのチェック function isGalleryPage() { return window.location.pathname.includes('/articles/gallery/'); } // 外部流入かどうかのチェック function isExternalTraffic() { return currentHostname !== referrerHostname; } } function withinCooldownPeriod(prefix, cooldownHour) { const KEY = `${prefix}_timestamp`; const cooldownTimestampStr = localStorage.getItem(KEY); const currentTime = new Date().getTime(); // 初回の場合 if (!cooldownTimestampStr) { localStorage.setItem(KEY, currentTime.toString()); return false; } const cooldownTimestamp = Number(cooldownTimestampStr); const withinCooldown = currentTime - cooldownTimestamp < cooldownHour * 60 * 60 * 1000 && currentTime - cooldownTimestamp > 1000; // 冷却期間が終了している場合は、今回表示するので、再び冷却期間をスタートさせる if (!withinCooldown) { localStorage.setItem(KEY, currentTime.toString()); } return withinCooldown; } if (!mayDisplayAdCustom()) return false; if (withinCooldownPeriod(`pfx_page${settings.pfx_pageid}_internal`, settings.frequency_cap)) { console.log("within cooldown period for internal traffic in separate tags"); return; } window.adShared = window.adShared || {}; window.adShared.pfx = 0.90; // 90%の確率でPFXを表示 window.adShared.fluct = 0.10; // 10%の確率でmicroAd社を表示 const randomValue = Math.random(); // 0から1のランダムな数を生成 if (randomValue < window.adShared.pfx) { pfx(); } else { // 5%の確率でmicroAd社 microAd(); } } // リトライ機能付きの実行関数 const executeWithRetry = function (fn, maxRetries = 5, delay = 100) { let retryCount = 0; function attempt() { try { fn(); } catch (e) { retryCount++; console.log(`Attempt ${retryCount} failed: ${e}`); if (retryCount < maxRetries) { console.log(`Retrying in ${delay}ms... (${retryCount}/${maxRetries})`); setTimeout(attempt, delay); } else { console.log(`All ${maxRetries} attempts failed. Last error: ${e}`); } } } attempt(); } // リトライ機能付きでinsertHTMLを実行 executeWithRetry(insertHTML);
マイページ

北海道

もっと見る
アクセスランキング
  • 最新
  • 24時間
  • 週間