{"campaigns":[{"id":1,"edireco_service_id":"bd100331ds1","edireco_area_id":"acc100331r1","deduplication":false,"item_count":15,"filter_conditions":["size.eq/user.attr1"],"relation_settings":[{"relation_setting_id":12028,"item_type":"user_id"},{"relation_setting_id":12030,"item_type":"item_id"}],"callback":"function(body) {\n    var target = document.querySelector('[id*=\"b-dash_ai_recommend_top\"]');\n    var details = body.details;\n\n    /* ------------------------------------------------------------\n     * 共通: 画像サイズ変更\n     * ------------------------------------------------------------ */\n    function convertImageUrl(url) {\n    if (!url) return '';\n\n    // .jpg → _400x.jpg に変換（大文字JPGも対応）\n    return url.replace(/\\.jpg(\\?.*)?$/i, '_400x.jpg$1');\n    }\n\n    /* ------------------------------------------------------------\n     * 共通: 価格フォーマット\n     * ------------------------------------------------------------ */\n    function formatPrice(price) {\n        var numStr = String(price).replace(/[^0-9]/g, '');\n        var formatted = numStr.replace(/(\\d)(?=(\\d{3})+$)/g, '$1,');\n        return '¥' + formatted;\n    }\n\n    /* ------------------------------------------------------------\n     * セールアイコン生成（定価がある場合のみ）\n     * ------------------------------------------------------------ */\n    function buildIconsHtml(compareAtPrice) {\n        if (!compareAtPrice) return '';\n        return '\u003cspan class=\"c-label__icon c-label__icon--list c-label__icon--sale\"\u003eSALE\u003c/span\u003e';\n    }\n\n    /* ------------------------------------------------------------\n     * セール価格 / 通常価格のHTML生成\n     * compareAtPrice が null → 通常価格\n     * ------------------------------------------------------------ */\n    function buildPriceHtml(price, compareAtPrice) {\n        var taxLabel = '\u003cspan class=\"gfe-tax\"\u003e税込\u003c/span\u003e';\n\n        /* 通常価格（定価なし） */\n        if (!compareAtPrice) {\n            return (\n                '\u003cspan class=\"p-ranking__listPrice c-card__listPrice c-card__listPrice--inline\"\u003e' +\n                    formatPrice(price) +\n                '\u003c/span\u003e' +\n                taxLabel\n            );\n        }\n\n        /* セール（定価あり） */\n        var compareHtml =\n            '\u003cspan class=\"p-ranking__listPrice c-card__listPrice c-card__listPrice--inline c-text--delete\"\u003e' +\n                '\u003cspan class=\"money\"\u003e' + formatPrice(compareAtPrice) + '\u003c/span\u003e' +\n            '\u003c/span\u003e';\n\n        var saleHtml =\n            '\u003cspan class=\"p-ranking__listPriceSale c-card__listPriceSale c-card__listPriceSale--inline\"\u003e' +\n                formatPrice(price) +\n            '\u003c/span\u003e' +\n            taxLabel;\n\n        return compareHtml + saleHtml;\n    }\n\n    /* ------------------------------------------------------------\n     * HTML構築\n     * ------------------------------------------------------------ */\n    var html = '\u003cdiv class=\"l-wrapper__inner l-block__inner c-flex -jc-sb\"\u003e';\n    html +=     '\u003cmain class=\"l-main l-main--column\"\u003e';\n    html +=         '\u003csection class=\"p-ranking c-card u-margin__block\"\u003e';\n    html +=             '\u003ch2 class=\"c-title c-text__align--center\"\u003eあなたへのおすすめ\u003c/h2\u003e';\n    html += '      \u003cdiv style=\"position:relative;\"\u003e';\n    html +=             '\u003cul class=\"p-ranking__list c-flex -fxw-w\" style=\"justify-content: space-between\"\u003e';\n    html += '        \u003cli style=\" position:absolute; left:3px; top:30%; z-index:10; list-style:none; \"\u003e';\n    html += '          \u003cimg src=\"https://www.j-lounge.jp/cdn/shop/t/104/assets/slickArrow-prev.svg\" class=\"prevBtn\" style=\"width:32px; cursor:pointer;\" onclick=\"scrollRanking(-1)\"\u003e';\n    html += '        \u003c/li\u003e';\n    html += '        \u003cli style=\" position:absolute; right:-6px; top:30%; z-index:10; list-style:none;width: 40px;  \"\u003e';\n    html += '          \u003cimg src=\"https://www.j-lounge.jp/cdn/shop/t/104/assets/slickArrow-next.svg\" class=\"nextBtn\" style=\"width:32px; cursor:pointer;\" onclick=\"scrollRanking(1)\"\u003e';\n    html += '        \u003c/li\u003e';\n   \n\n    for (var i = 0; i \u003c details.length; i++) {\n        var detail = details[i];\n\n        /* --- セール判定ロジック --- */\n        var price = detail.sprice;\n        var compareAtPrice = detail.price || null;\n\n        html += '\u003cli class=\"p-ranking__listItem c-card__listItem c-card__listItem--ranking\" style=\"padding-bottom:1em\"\u003e';\n\n        html +=     '\u003ca class=\"c-link\" ' +\n                        'href=\"' + detail.page_addr + '?variant=' + detail.brand + '\" ' +\n                        'serv=\"' + body.serv + '\" ' +\n                        'area=\"' + body.area + '\" ' +\n                        'req=\"' + body.req + '\" ' +\n                        'item=\"' + detail.item_id + '\" ' +\n                        'data-appmate=\"\"\u003e';\n\n        html +=         '\u003cdiv class=\"p-ranking__listImage c-card__listImage\"\u003e';\n\n        html +=             '\u003cimg class=\"lazyloaded\" ' +\n                                'src=\\\"' + convertImageUrl(detail.img_addr) + '\\\" ' +\n                                'alt=\"' + detail.title + '\" ' +\n                                'style=\"display: block;\" ' +\n                                'loading=\"lazy\"\u003e';\n\n        /* --- セールアイコン --- */\n        html +=             '\u003cdiv class=\"p-ranking__listIcon c-card__listIcon c-flex -fxw-w -ai-c\"\u003e' +\n                                buildIconsHtml(compareAtPrice) +\n                            '\u003c/div\u003e';\n\n        html +=         '\u003c/div\u003e';\n\n        html +=         '\u003cdiv class=\"p-ranking__listDetail c-card__listDetail\"\u003e';\n\n        if (detail.desc) {\n            html +=         '\u003ch3 class=\"p-ranking__listBrand c-card__listBrand\"\u003e' +\n                                detail.desc +\n                            '\u003c/h3\u003e';\n        }\n\n        html +=             '\u003cp class=\"p-ranking__listText c-card__listText\"\u003e' +\n                                detail.title +\n                            '\u003c/p\u003e';\n\n        /* --- セール / 通常価格 --- */\n        html +=             buildPriceHtml(price, compareAtPrice);\n\n        html +=         '\u003c/div\u003e';\n        html +=     '\u003c/a\u003e';\n        html += '\u003c/li\u003e';\n    }\n\n    html +=             '\u003c/ul\u003e';\n    html +=         '\u003c/div\u003e';\n    html +=         '\u003c/section\u003e';\n    html +=     '\u003c/main\u003e';\n    html += '\u003c/div\u003e';\n\n    target.innerHTML = html;\n    window.scrollRanking = function(dir) {\n    const ul = target.querySelector('.p-ranking__list');\n    if (!ul) return;\n    const scrollAmount = 300;\n    ul.scrollBy({ left: dir * scrollAmount, behavior: 'smooth' });\n    };\n    target.addEventListener('click', sendRecClick, false);\n}","env":"","operator":"pre_match","value":"https://www.j-lounge.jp/"}]}