PageSourceSearch

https://www.shop-onoya.com/js/usr/aireco.js?2121

js shop-onoya.com collected 2026-10-09 00:19:38 UTC 7,928 bytes, 323 lines download raw bytes

1// ランキング AiReco slick化(データ読み込み待ち対応)+購入ボタン追加
2(function(){
3  'use strict';
4
5  function ready(fn){
6    if(window.jQuery) fn(window.jQuery);
7    else setTimeout(function(){ ready(fn); }, 30);
8  }
9
10  ready(function($){
11
12    var retryTimer = null;
13
14    function addRankingButton(){
15      var cartLink = document.querySelector('#goods_list_auto_load_area .block-list-add-cart-btn[href*="crsirefo_hidden="]');
16      var crsirefo = '';
17
18      if(!cartLink){
19        return false;
20      }
21
22      var crsirefoMatch = cartLink.href.match(/crsirefo_hidden=([^&]*)/);
23
24      if(!crsirefoMatch || !crsirefoMatch[1]){
25        return false;
26      }
27
28      crsirefo = crsirefoMatch[1];
29
30      document.querySelectorAll('#block_of_top_free4 .block-ranking-r--item')
31      .forEach(function(item){
32        if(item.querySelector('.js-ranking-buy-btn')){
33          return;
34        }
35
36        var link = item.querySelector('a[href]');
37        if(!link){
38          return;
39        }
40
41        var goodsMatch = link.href.match(/\/g\/g(\d+)\//);
42
43        if(!goodsMatch){
44          return;
45        }
46
47        var goods = goodsMatch[1];
48
49        var btn = document.createElement('a');
50        btn.href = '/shop/cart/cart.aspx?goods=' + goods + '&crsirefo_hidden=' + crsirefo;
51        btn.className = 'js-ranking-buy-btn js-animation-add-cart';
52        btn.textContent = '購入する';
53
54        link.insertAdjacentElement('afterend', btn);
55      });
56
57      return true;
58    }
59
60    function initRankingSlick(){
61      if(!$.fn || typeof $.fn.slick !== 'function'){
62        return false;
63      }
64
65      var initialized = false;
66
67      $('#block_of_top_free4 .block-ranking-lightningrecommend').each(function(){
68        var $root  = $(this);
69        var $track = $root.find('.block-ranking-r--items').first();
70        if(!$track.length) return;
71
72        var $slides = $track.children('li.block-ranking-r--item');
73        if($slides.length < 2) return;
74
75        if($track.hasClass('slick-initialized')){
76          try{
77            $track.slick('setPosition');
78          }catch(e){}
79          initialized = true;
80          return;
81        }
82
83        $track.slick({
84          autoplay: true,
85          infinite: true,
86          slidesToShow: 3,
87          slidesToScroll: 1,
88          centerMode: true,
89          initialSlide: 1,
90          arrows: true,
91          dots: false,
92          speed: 350,
93          swipeToSlide: true,
94          prevArrow: '<button type="button" class="slick-prev" aria-label="Previous"></button>',
95          nextArrow: '<button type="button" class="slick-next" aria-label="Next"></button>',
96          responsive: [
97            {
98              breakpoint: 950,
99              settings: {
100                slidesToShow: 2,
101                centerPadding: '40px'
102              }
103            },
104            {
105              breakpoint: 768,
106              settings: {
107                slidesToShow: 2,
108                centerPadding: '18%',
109                dots: true
110              }
111            },
112            {
113              breakpoint: 480,
114              settings: {
115                slidesToShow: 1,
116                initialSlide: 0,
117                centerPadding: '18%',
118                dots: true
119              }
120            }
121          ]
122        });
123
124        setTimeout(function(){
125          try{
126            $track.slick('setPosition');
127          }catch(e){}
128        }, 0);
129
130        setTimeout(function(){
131          try{
132            $track.slick('setPosition');
133          }catch(e){}
134        }, 300);
135
136        initialized = true;
137      });
138
139      return initialized;
140    }
141
142    function startRankingRetry(){
143
144      if(retryTimer){
145        clearInterval(retryTimer);
146      }
147
148      var count = 0;
149
150      retryTimer = setInterval(function(){
151        count++;
152
153        var slickInitialized = initRankingSlick();
154        var buttonAdded = addRankingButton();
155
156        if(slickInitialized && buttonAdded){
157          clearInterval(retryTimer);
158          retryTimer = null;
159          return;
160        }
161
162        if(count >= 40){
163          clearInterval(retryTimer);
164          retryTimer = null;
165        }
166      }, 250);
167    }
168
169    startRankingRetry();
170
171    $(window).on('load', function(){
172      initRankingSlick();
173      addRankingButton();
174    });
175
176    window.addEventListener('pageshow', function(){
177      startRankingRetry();
178    });
179
180  });
181})();
182
183
184
185// あなたへのおすすめ AiReco slick化(後読み込み対応)
186(function(){
187  'use strict';
188
189  function ready(fn){
190    if(window.jQuery) fn(window.jQuery);
191    else setTimeout(function(){ ready(fn); }, 30);
192  }
193
194  ready(function($){
195
196    var retryTimer = null;
197
198    function initRecommendSlick(){
199      if(!$.fn || typeof $.fn.slick !== 'function'){
200        return false;
201      }
202
203      var initialized = false;
204
205      $('#block_of_top_free5 .block-accessory-list, #koko .block-accessory-list').each(function(){
206
207        var target = document.getElementById('koko');
208
209        if(target && this.parentNode !== target){
210          target.appendChild(this);
211        }
212
213        var $root  = $(this);
214        var $track = $root.find('.block-goods-list-d').first();
215        if(!$track.length) return;
216
217        $root.find('.block-goods-list-d--add-cart a').text('購入する');
218
219        var $slides = $track.children('.block-goods-list-d--item');
220        if($slides.length < 2) return;
221
222        if($track.hasClass('slick-initialized')){
223          try{
224            $track.slick('setPosition');
225          }catch(e){}
226
227          initialized = true;
228          return;
229        }
230
231        $track.slick({
232          autoplay: true,
233          infinite: true,
234          slidesToShow: 3,
235          slidesToScroll: 1,
236          centerMode: true,
237          initialSlide: 1,
238          arrows: true,
239          dots: true,
240          speed: 350,
241          swipeToSlide: true,
242          prevArrow: '<button type="button" class="slick-prev" aria-label="Previous"></button>',
243          nextArrow: '<button type="button" class="slick-next" aria-label="Next"></button>',
244          responsive: [
245            {
246              breakpoint: 950,
247              settings: {
248                slidesToShow: 2,
249                centerPadding: '40px'
250              }
251            },
252            {
253              breakpoint: 768,
254              settings: {
255                slidesToShow: 2,
256                centerPadding: '18%'
257              }
258            },
259            {
260              breakpoint: 480,
261              settings: {
262                slidesToShow: 1,
263                initialSlide: 0,
264                centerPadding: '18%'
265              }
266            }
267          ]
268        });
269
270        setTimeout(function(){
271          try{
272            $track.slick('setPosition');
273          }catch(e){}
274        }, 0);
275
276        setTimeout(function(){
277          try{
278            $track.slick('setPosition');
279          }catch(e){}
280        }, 300);
281
282        initialized = true;
283      });
284
285      return initialized;
286    }
287
288    function startRecommendRetry(){
289
290      if(retryTimer){
291        clearInterval(retryTimer);
292      }
293
294      var count = 0;
295
296      retryTimer = setInterval(function(){
297        count++;
298
299        if(initRecommendSlick()){
300          clearInterval(retryTimer);
301          retryTimer = null;
302          return;
303        }
304
305        if(count >= 40){
306          clearInterval(retryTimer);
307          retryTimer = null;
308        }
309      }, 250);
310    }
311
312    startRecommendRetry();
313
314    $(window).on('load', function(){
315      initRecommendSlick();
316    });
317
318    window.addEventListener('pageshow', function(){
319      startRecommendRetry();
320    });
321
322  });
323})();

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.