PageSourceSearch

https://madamefigaro.jp/society-business/wp-content/themes/madamef…/assets/js/pager-ad-loader.js?ver=1.0.154

js madamefigaro.jp collected 2026-10-02 05:25:38 UTC 3,097 bytes, 99 lines download raw bytes

1/**
2 * Pager Ad Loader
3 * ページャーブロック表示時に広告を動的読み込み
4 *
5 * @package madameFIGARO.jp
6 * @since 1.0.0
7 */
8(function() {
9    'use strict';
10
11    // 既に読み込まれた広告を管理
12    const loadedAds = new Set();
13
14    /**
15     * IntersectionObserver設定
16     */
17    const observerOptions = {
18        root: null,
19        rootMargin: '200px',  // 200px手前で読み込み開始
20        threshold: 0
21    };
22
23    const observer = new IntersectionObserver(function(entries) {
24        entries.forEach(function(entry) {
25            if (!entry.isIntersecting) {
26                return;
27            }
28
29            const pager = entry.target;
30            const adType = pager.dataset.showAd;
31            const postId = parseInt(pager.dataset.postId, 10);
32            const position = parseInt(pager.dataset.pagerPosition, 10);
33            const adKey = adType + '-' + postId + '-' + position;
34
35            // 既に読み込み済みならスキップ
36            if (loadedAds.has(adKey)) {
37                return;
38            }
39
40            console.log('Pager ad triggered:', adType, 'postID:', postId, 'position:', position);
41
42            // 広告表示処理
43            if (adType === 'infinity-page') {
44                // Infinity-Page枠を定義(div id: FIGARO_*_Article_Infinity-Page_300x250-{postId}-{position})
45                if (typeof dynamic_pagerInfinityPageAD === 'function') {
46                    dynamic_pagerInfinityPageAD(postId, position);
47                } else {
48                    console.error('dynamic_pagerInfinityPageAD function not found');
49                }
50            }
51
52            // 読み込み済みとしてマーク
53            loadedAds.add(adKey);
54
55            // 監視解除
56            observer.unobserve(pager);
57        });
58    }, observerOptions);
59
60    /**
61     * 初期化関数
62     */
63    function init() {
64        // data-show-ad属性を持つページャーブロックを全て監視
65        const pagers = document.querySelectorAll('.whatpager-pager[data-show-ad]');
66
67        console.log('Pager ad loader initialized. Found', pagers.length, 'ad pagers');
68
69        pagers.forEach(function(pager) {
70            observer.observe(pager);
71        });
72    }
73
74    /**
75     * 指定要素内のページャーブロックを監視対象に追加
76     * (無限スクロール等で動的に追加された記事用)
77     *
78     * @param {HTMLElement} container - 検索対象のコンテナ要素
79     */
80    function observePagers(container) {
81        if (!container) return;
82        var pagers = container.querySelectorAll('.whatpager-pager[data-show-ad]');
83        pagers.forEach(function(pager) {
84            observer.observe(pager);
85        });
86    }
87
88    // グローバルに公開(無限スクロールから呼び出し用)
89    window.figaroPagerAdLoader = {
90        observePagers: observePagers
91    };
92
93    // DOM読み込み後に初期化
94    if (document.readyState === 'loading') {
95        document.addEventListener('DOMContentLoaded', init);
96    } else {
97        init();
98    }
99})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.