PageSourceSearch

https://www.advertimes.com/wp-content/themes/swell_advertimes/buil…/advertimes_silveregg.js?ver=20260622100059

js advertimes.com collected 2026-09-24 17:41:35 UTC 14,473 bytes, 337 lines download raw bytes

1const silveregg_baseurl = `https://${silveregg_data.domain}/pycre5/jsonp`
2function trimText(text, maxLength) {
3  const ellipsis = "..."
4  if (text.length > maxLength) {
5    return text.substring(0, maxLength - ellipsis.length) + ellipsis
6  }
7  return text
8}
9
10// 使用例
11function makeSilvereggQuery(extraParams) {
12  let mergeParams = Object.assign(
13    {
14      merch: silveregg_data.merchant,
15    },
16    extraParams
17  )
18
19  if (mergeParams.prod) {
20    // prodが存在する場合は最初に持ってくる
21    const { prod, ...rest } = mergeParams
22    mergeParams = { prod, ...rest }
23  }
24
25  // パラメーターの値が配列の場合は、同じキーが複数回出てくる
26  const queryString = Object.entries(mergeParams)
27    .filter(([k, v]) => !!v)
28    .map(([key, value]) => {
29      if (Array.isArray(value)) {
30        return value.map((v) => `${key}=${encodeURIComponent(v)}`).join("&")
31      } else {
32        return `${key}=${encodeURIComponent(value)}`
33      }
34    })
35    .join("&")
36
37  return queryString
38}
39
40function pingCallback() {
41  console.log("recommend click")
42}
43function cvCallback() {
44  console.log("recommend scroll")
45}
46
47function sendSilvereggPing(item, spec, rqid) {
48  let query = makeSilvereggQuery({
49    prod: item,
50    spec: spec,
51    cref: rqid,
52    callback: "pingCallback",
53    cookie: silveregg_data.cookie,
54  })
55  insertScript(`${silveregg_baseurl}/click?${query}`)
56}
57
58function silvereggCallback(args) {
59  // console.log("args", args)
60  if (args.items) {
61    const area_id = silveregg_data.area_id
62    const listContainer = document.getElementById(area_id)
63    if (listContainer) {
64      let content = ""
65      switch (area_id) {
66        case "silveregg_normal":
67          content = args.items
68            .map((item) => createPostListItem(item[0], args.spec, args.rqid))
69            .join("")
70          break
71        case "silveregg_category_column":
72          content = args.items
73            .map((item) =>
74              createCategoryColumnPost(item[0], args.spec, args.rqid)
75            )
76            .join("")
77          break
78        case "silveregg_single_column":
79          content = args.items
80            .map((item) =>
81              createSingleColumnPost(item[0], args.spec, args.rqid)
82            )
83            .join("")
84          break
85      }
86      listContainer.insertAdjacentHTML("beforeend", content)
87      var slidesPerViewValue = window.innerWidth < 992 ? 1 : 2
88      new Swiper(".advertimes__silveregg_swiper", {
89        // オプションをここに設定
90        loop: true,
91        slidesPerView: slidesPerViewValue, // デバイスの幅に応じた値を使用
92        spaceBetween: 0, // スライド間の間隔
93        pagination: {
94          el: ".swiper-pagination",
95        },
96        navigation: {
97          nextEl: ".swiper-button-next",
98          prevEl: ".swiper-button-prev",
99        },
100      })
101    } else {
102      console.log(`Container with id #${area_id} not found.`)
103    }
104  }
105}
106
107// HTMLを生成する関数
108function createPostListItem(item, spec, rqid) {
109  const onClick = `onclick="sendSilvereggPing('${item._id}','${spec}','${rqid}')"`
110  return (
111    `
112    <li class="p-postList__item">
113      <div class="p-postList__link">
114        <a class="p-postList__thumb c-postThumb shadow-none" href="${item.ct_url}" data-elem-name="thumbnail" ${onClick}>
115          <figure class="c-postThumb__figure">
116            <img width="800" height="450" src="${item.img_url}" alt="" class="c-postThumb__img u-obf-cover">
117          </figure>
118        </a>
119        <div class="p-postList__body opacity-10">
120          <div class="d-flex flex-wrap gap-5">
121            <div class="flex-grow d-flex flex-wrap gap-10-5">
122            ` +
123    item.tag
124      .split(",")
125      .filter((v) => !!v)
126      .slice(0, 3)
127      .map((tag) => {
128        return `<a class="advertimes-tag-cloud bg-gray px-5 px-lg-10 m-0 fs-10 fs-lg-12 font-weight-bold rounded-pill" href="/tags/${tag}">#${tag}</a>`
129      })
130      .join("") +
131    `
132            </div>
133          </div>
134          <h2 class="p-postList__title">
135            <a href="${item.ct_url}" data-elem-name="headline" ${onClick}>${item.title}</a>
136          </h2>
137          <div class="p-postList__meta justify-content-end">
138					<div class="p-postList__times c-postTimes u-thin">
139	          <time class="c-postTimes__posted fs-12 opacity-10 text-gray" datetime="${item.price_string}" aria-label="公開日">${item.price_string}</time></div>
140				</div>
141        </div>
142      </div>
143    </li>
144  `
145  )
146}
147
148function createCategoryColumnPost(item, spec, rqid) {
149  const onClick = `onclick="sendSilvereggPing('${item._id}','${spec}','${rqid}')"`
150  return (
151    `
152  <li class="p-postList__item swiper-slide p-postList__authorBox border-none">
153    <div class="p-postList__body px-10 py-20 bg-gray d-flex flex-column justify-content-between">
154        <div class="p-column__tags">
155            <div class="flex-grow d-flex flex-wrap gap-10-5">
156            ` +
157    item.tag
158      .split(",")
159      .filter((v) => !!v)
160      .slice(0, 3)
161      .map((tag) => {
162        return `<a class="advertimes-tag-cloud bg-white px-5 px-lg-10 m-0 fs-10 fs-lg-12 font-weight-bold rounded-pill" href="javascript:void(0)">#${tag}</a>`
163      })
164      .join("") +
165    `
166            </div>            
167        </div>
168        <div class="d-flex align-items-center mt-10">
169            <div class="p-authorBox__l p-advertimes-authorBox__l rounded-circle overflow-hidden">
170                <a class="d-block" href="/author/${
171                  item.price_string
172                }/" data-elem-name="thumbnail" ${onClick} >
173                    <img src="${item.img_url}"
174                        class="post_avatar no-rate avatar-100 avatar-default" height="100" width="100"
175                        style="width: 100px; height: 100px;" alt="avatar"> </a>
176            </div>
177            <div class="p-postList__title p-authorBox__title fs-16 mt-0">
178                <a href="${item.ct_url}/" data-elem-name="headline" ${onClick}> 
179                ${trimText(item.title, 24)}
180                </a>
181                <div class="p-postList__meta">
182                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="17" viewBox="0 0 16 17" fill="none">
183                        <g clip-path="url(#clip0_2804_55156)">
184                            <path
185                                d="M15.8455 4.35189L12.3405 0.847426C12.1442 0.651118 11.7952 0.651118 11.5916 0.847426L2.08753 10.3502C2.08753 10.3502 2.06571 10.3575 2.05844 10.372C2.03662 10.3938 2.02935 10.4229 2.00754 10.4447C2.00027 10.4592 1.99299 10.4738 1.97845 10.4883C1.96391 10.5174 1.94209 10.5465 1.93482 10.5756L0.0296495 15.9922C-0.0357953 16.1813 0.00783456 16.3921 0.153267 16.5375C0.247799 16.6393 0.38596 16.6975 0.524121 16.6975H0.51685C0.582295 16.7047 0.640468 16.6975 0.698641 16.6757L6.11602 14.7635C6.18873 14.7344 6.26145 14.6908 6.31235 14.6399L15.8527 5.10076C16.0491 4.88991 16.0491 4.56273 15.8527 4.35189H15.8455ZM1.91301 13.8183L2.65471 11.7098L4.99618 14.0509L2.88013 14.7926L1.91301 13.8183Z"
186                                fill="#858181"></path>
187                        </g>
188                        <defs>
189                            <clipPath id="clip0_2804_55156">
190                                <rect width="16" height="16" fill="white" transform="translate(0 0.700195)"></rect>
191                            </clipPath>
192                        </defs>
193                    </svg>
194                    <div class="p-column-display-name fs-12 font-weight-bold">
195                        <a href="/author/${
196                          item.price_string
197                        }/" data-elem-name="subtitle" ${onClick}>
198                        ${trimText(item.author, 30)}
199    </a>
200                    </div>
201                </div>
202            </div>
203        </div>
204        <div class="d-flex justify-content-center gap-20 mt-20">
205            <div class="is-style-btn_line btn_link_small dark_blue_ m-0">
206                <a class="rounded fs-12 fs-lg-14 font-weight-bold lh-16 shadow bg-primary text-white"
207                    href="${
208                      item.ct_url
209                    }" data-elem-name="button" ${onClick}>コラムを読む</a>
210            </div>
211            <div class="is-style-btn_line btn_link_small dark_blue_ m-0">
212                <a class="rounded fs-12 fs-lg-14 font-weight-bold lh-16 shadow" href="/author/${
213                  item.price_string
214                }/" data-elem-name="button">全コラム一覧</a>
215            </div>
216        </div>
217    </div>
218</li>
219            `
220  )
221}
222
223function createSingleColumnPost(item, spec, rqid) {
224  const onClick = `onclick="sendSilvereggPing('${item._id}','${spec}','${rqid}')"`
225  return `
226  <li class="p-postList__item w-100 w-lg-50 mb-10">
227    <div class="p-postList__body p-column">
228        <div class="d-flex align-items-center">
229            <div class="p-authorBox__l p-advertimes-authorBox__l rounded-circle overflow-hidden">
230                <a class="d-block" href="/author/${item.price_string}/" data-elem-name="thumbnail" ${onClick}>
231                    <img src="${item.img_url}"
232                        class="post_avatar no-rate avatar-100 avatar-default" height="100" width="100"
233                        style="width: 100px; height: 100px;" alt="avatar">
234                        </a>
235            </div>
236            <div class="p-postList__title p-authorBox__title fs-16 mt-0">
237                <a href="${item.ct_url}" data-elem-name="headline" ${onClick}> 
238                ${item.title} 
239                </a>
240                <div class="p-postList__meta d-lg-none d-flex">
241                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="17" viewBox="0 0 16 17" fill="none">
242                        <g clip-path="url(#clip0_2804_55156)">
243                            <path
244                                d="M15.8455 4.35189L12.3405 0.847426C12.1442 0.651118 11.7952 0.651118 11.5916 0.847426L2.08753 10.3502C2.08753 10.3502 2.06571 10.3575 2.05844 10.372C2.03662 10.3938 2.02935 10.4229 2.00754 10.4447C2.00027 10.4592 1.99299 10.4738 1.97845 10.4883C1.96391 10.5174 1.94209 10.5465 1.93482 10.5756L0.0296495 15.9922C-0.0357953 16.1813 0.00783456 16.3921 0.153267 16.5375C0.247799 16.6393 0.38596 16.6975 0.524121 16.6975H0.51685C0.582295 16.7047 0.640468 16.6975 0.698641 16.6757L6.11602 14.7635C6.18873 14.7344 6.26145 14.6908 6.31235 14.6399L15.8527 5.10076C16.0491 4.88991 16.0491 4.56273 15.8527 4.35189H15.8455ZM1.91301 13.8183L2.65471 11.7098L4.99618 14.0509L2.88013 14.7926L1.91301 13.8183Z"
245                                fill="#858181"></path>
246                        </g>
247                        <defs>
248                            <clipPath id="clip0_2804_55156">
249                                <rect width="16" height="16" fill="white" transform="translate(0 0.700195)"></rect>
250                            </clipPath>
251                        </defs>
252                    </svg>
253                    <div class="p-column-display-name fs-12 font-weight-bold">
254                        <a href="${item.ct_url}" data-elem-name="subtitle" ${onClick}>${item.author}</a>
255                    </div>
256                </div>
257            </div>
258        </div>
259        <div class="p-postList__meta d-none d-lg-flex">
260            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="17" viewBox="0 0 16 17" fill="none">
261                <g clip-path="url(#clip0_2804_55156)">
262                    <path
263                        d="M15.8455 4.35189L12.3405 0.847426C12.1442 0.651118 11.7952 0.651118 11.5916 0.847426L2.08753 10.3502C2.08753 10.3502 2.06571 10.3575 2.05844 10.372C2.03662 10.3938 2.02935 10.4229 2.00754 10.4447C2.00027 10.4592 1.99299 10.4738 1.97845 10.4883C1.96391 10.5174 1.94209 10.5465 1.93482 10.5756L0.0296495 15.9922C-0.0357953 16.1813 0.00783456 16.3921 0.153267 16.5375C0.247799 16.6393 0.38596 16.6975 0.524121 16.6975H0.51685C0.582295 16.7047 0.640468 16.6975 0.698641 16.6757L6.11602 14.7635C6.18873 14.7344 6.26145 14.6908 6.31235 14.6399L15.8527 5.10076C16.0491 4.88991 16.0491 4.56273 15.8527 4.35189H15.8455ZM1.91301 13.8183L2.65471 11.7098L4.99618 14.0509L2.88013 14.7926L1.91301 13.8183Z"
264                        fill="#858181"></path>
265                </g>
266                <defs>
267                    <clipPath id="clip0_2804_55156">
268                        <rect width="16" height="16" fill="white" transform="translate(0 0.700195)"></rect>
269                    </clipPath>
270                </defs>
271            </svg>
272            <div class="p-column-display-name fs-12 font-weight-bold">
273                <a href="${item.ct_url}" data-elem-name="subtitle" ${onClick}>${item.author}</a>
274            </div>
275        </div>
276    </div>
277</li>
278`
279}
280
281function insertScript(url) {
282  const script = document.createElement("script")
283  script.src = url
284  document.body.appendChild(script)
285}
286
287;(function () {
288  // レコメンド取得処理
289  if (silveregg_data.spec) {
290    const query = makeSilvereggQuery({
291      prod: silveregg_data.prod,
292      spec: silveregg_data.spec,
293      num: silveregg_data.num,
294      bcat: silveregg_data.bcat,
295      cat: silveregg_data.cat,
296      xcat: silveregg_data.xcat,
297      xprod: silveregg_data.xprod,
298      cust: silveregg_data.cust,
299      cookie: silveregg_data.cookie,
300      callback: "silvereggCallback",
301    })
302    insertScript(`${silveregg_baseurl}/recommend?${query}`)
303  }
304
305  // レコメンドCV通知
306  let cv_flag = false
307  if (silveregg_data.prod) {
308    cv_flag = true
309    window.addEventListener("scroll", function () {
310      const docHeight = document.documentElement.scrollHeight
311      const windowHeight = window.innerHeight
312      const scrollTop = window.scrollY || window.pageYOffset
313      const scrollPercent = (scrollTop / (docHeight - windowHeight)) * 100
314
315      if (scrollPercent >= 50 && cv_flag) {
316        // 一度だけ通知
317        cv_flag = false
318
319        // スクロールされた割合が50%以上になったらシルバーエッグにCV通知
320        let q = makeSilvereggQuery({
321          prod: silveregg_data.prod,
322          sku: silveregg_data.prod,
323          order: silveregg_data.uuid,
324          qty: 1,
325          price: 1,
326          device: silveregg_data.device,
327          cust: silveregg_data.cust
328            ? silveregg_data.cust
329            : silveregg_data.cookie,
330          cookie: silveregg_data.cookie,
331          callback: "cvCallback",
332        })
333        insertScript(`${silveregg_baseurl}/purchase?${q}`)
334      }
335    })
336  }
337})()

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.