Created
April 7, 2022 11:03
-
-
Save LRENZ/5e643df1104988ab2df4af5cbab8dff4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.at_exp_earn_version = window.at_earn_exp_version || {}; | |
window.at_exp_club_shopping_version = window.at_exp_club_shopping_version|| {}; | |
window.at_earn_more_text_click = "init"; | |
window.at_club_shopping_show_more_text_click = "init"; | |
function getRandom(arr, n) { | |
var result = new Array(n), | |
len = arr.length, | |
taken = new Array(len); | |
if (n > len) | |
throw new RangeError("getRandom: more elements taken than available"); | |
while (n--) { | |
var x = Math.floor(Math.random() * len); | |
result[n] = arr[x in taken ? taken[x] : x]; | |
taken[x] = --len in taken ? taken[len] : len; | |
} | |
return result; | |
} | |
function parseStrToDom(str) { | |
var el = document.createElement("div"); | |
el.innerHTML = str; | |
return el; | |
} | |
function applyHTML(selector, html,position,index) { | |
let el = document.querySelector(selector); | |
if(html.indexOf(el.id)!=-1){ | |
console.log("same slot, do nothing") | |
console.log(el) | |
console.log(html) | |
return | |
} | |
//console.log(el) | |
if (el) { | |
el.innerHTML = html; | |
//el.replaceWith(parseStrToDom(html)) | |
} | |
} | |
function search(nameKey, myArray) { | |
for (var i = 0; i < myArray.length; i++) { | |
if (myArray[i].index === nameKey) { | |
return myArray[i]; | |
} | |
} | |
} | |
var earn_selector = [ | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1)", | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2)", | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3)", | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4)", | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5)", | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6)", | |
]; | |
var club_shopping_selector = [ | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1)", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2)", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3)", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4)", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5)", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6)", | |
]; | |
var offers = [ | |
{ | |
index: 1, | |
html: '<div id="offer-insurance-theclub-com-hk-zh-individual-gadget-easy-phone-tablet" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"><div class="OfferListImageContainer"><a to="https://insurance.theclub.com.hk/zh/individual/gadget/easy-phone-tablet?itm_campaign=211117_clubployalty_epnt_offer_wave4-shopping_homepage-earn&itm_medium=buwebsite&itm_source=clubployalty" target="_self" href="https://insurance.theclub.com.hk/zh/individual/gadget/easy-phone-tablet?itm_campaign=211117_clubployalty_epnt_offer_wave4-shopping_homepage-earn&itm_medium=buwebsite&itm_source=clubployalty" rel="noopener noreferrer" class="undefined open-external"><img class="" alt="Club Insurance 獨家優惠" srcset="/content/dam/theclub-spa-react/en/partners-offers/partners/kv/clubinsurance-our-partners_epnt_tc_v4.jpg" src="/content/dam/theclub-spa-react/en/partners-offers/partners/kv/clubinsurance-our-partners_epnt_tc_v4.jpg" title="" style=""><div class="OfferListTypeContainer"></div></a></div><div class="OfferListTitleContainer"><a to="https://insurance.theclub.com.hk/zh/individual/gadget/easy-phone-tablet?itm_campaign=211117_clubployalty_epnt_offer_wave4-shopping_homepage-earn&itm_medium=buwebsite&itm_source=clubployalty" target="_self" href="https://insurance.theclub.com.hk/zh/individual/gadget/easy-phone-tablet?itm_campaign=211117_clubployalty_epnt_offer_wave4-shopping_homepage-earn&itm_medium=buwebsite&itm_source=clubployalty" rel="noopener noreferrer" class="undefined open-external"><div><div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">Club Insurance 獨家優惠</div></div></a></div><div class="OfferListAuthorContainer"><div><div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent">把握機會立即投保「Easy Phone & Tablet維修計劃」即享Club Shopping HK$300折扣優惠!受條款及細則約束。</div></div></div></div>', | |
}, | |
{ | |
index: 2, | |
html: '<div id="offer-www-theclub-com-hk-zh-campaigns-cpearning-onlineshopping-202011-html" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"><div class="OfferListImageContainer"><a to="https://www.theclub.com.hk/zh/campaigns/cpearning-onlineshopping-202011.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211101_homepage_earn_banner_whatsnews" target="_self" href="https://www.theclub.com.hk/zh/campaigns/cpearning-onlineshopping-202011.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211101_homepage_earn_banner_whatsnews" rel="noopener noreferrer" class="undefined open-external"><img class="" alt="全新合作夥伴" srcset="/content/dam/theclub-spa-react/en/partners-offers/campaigns/campaign-shopping-banner-20201104-v01.png" src="/content/dam/theclub-spa-react/en/partners-offers/campaigns/campaign-shopping-banner-20201104-v01.png" title="" style=""><div class="OfferListTypeContainer"></div></a></div><div class="OfferListTitleContainer"><a to="https://www.theclub.com.hk/zh/campaigns/cpearning-onlineshopping-202011.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211101_homepage_earn_banner_whatsnews" target="_self" href="https://www.theclub.com.hk/zh/campaigns/cpearning-onlineshopping-202011.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211101_homepage_earn_banner_whatsnews" rel="noopener noreferrer" class="undefined open-external"><div><div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">全新合作夥伴</div></div></a></div><div class="OfferListAuthorContainer"><div><div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent">於The Club全新合作網店/前往指定店鋪購物,即可賺取Club積分。買得多,賺得多!</div></div></div></div>', | |
}, | |
{ | |
index: 3, | |
html: '<div id="offer-www-theclub-com-hk-zh-campaigns-earncp-hkt-202011-html" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"><div class="OfferListImageContainer"><a to="https://www.theclub.com.hk/zh/campaigns/earncp-hkt-202011.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211101_homepage_earn_banner_hkt-services" target="_self" href="https://www.theclub.com.hk/zh/campaigns/earncp-hkt-202011.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211101_homepage_earn_banner_hkt-services" rel="noopener noreferrer" class="undefined open-external"><img class="" alt="透過HKT服務賺取Club積分" srcset="/content/dam/theclub-spa-react/en/partners-offers/campaigns/campaign-lob-banner-20201104-v01.png" src="/content/dam/theclub-spa-react/en/partners-offers/campaigns/campaign-lob-banner-20201104-v01.png" title="" style=""><div class="OfferListTypeContainer"></div></a></div><div class="OfferListTitleContainer"><a to="https://www.theclub.com.hk/zh/campaigns/earncp-hkt-202011.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211101_homepage_earn_banner_hkt-services" target="_self" href="https://www.theclub.com.hk/zh/campaigns/earncp-hkt-202011.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211101_homepage_earn_banner_hkt-services" rel="noopener noreferrer" class="undefined open-external"><div><div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">透過HKT服務賺取Club積分</div></div></a></div><div class="OfferListAuthorContainer"><div><div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent">經HKT各項認可服務賺Club積分話咁易。賺夠指定積分升級會籍so easy!</div></div></div></div>', | |
}, | |
{ | |
index: 4, | |
html: '<div id="offer-www-theclub-com-hk-zh-campaigns-cpearning-localtravel-202011-html" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"><div class="OfferListImageContainer"><a to="https://www.theclub.com.hk/zh/campaigns/cpearning-localtravel-202011.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211101_homepage_earn_banner_localtravel" target="_self" href="https://www.theclub.com.hk/zh/campaigns/cpearning-localtravel-202011.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211101_homepage_earn_banner_localtravel" rel="noopener noreferrer" class="undefined open-external"><img class="" alt="探索本地悠閒旅程" srcset="/content/dam/theclub-spa-react/en/partners-offers/campaigns/campaign-localtravel-banner-20201104-v01.png" src="/content/dam/theclub-spa-react/en/partners-offers/campaigns/campaign-localtravel-banner-20201104-v01.png" title="探索本地悠閒旅程"><div class="OfferListTypeContainer"></div></a></div><div class="OfferListTitleContainer"><a to="https://www.theclub.com.hk/zh/campaigns/cpearning-localtravel-202011.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211101_homepage_earn_banner_localtravel" target="_self" href="https://www.theclub.com.hk/zh/campaigns/cpearning-localtravel-202011.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211101_homepage_earn_banner_localtravel" rel="noopener noreferrer" class="undefined open-external"><div><div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">探索本地悠閒旅程</div></div></a></div><div class="OfferListAuthorContainer"><div><div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent">於The Club預訂本地酒店住房或旅遊相關項目賺Club積分,渡過你的快閃假期。</div></div></div></div>', | |
}, | |
{ | |
index: 5, | |
html: '<div id="offer-www-theclub-com-hk-zh-campaigns-browser-extension-html" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"><div class="OfferListImageContainer"><a to="https://www.theclub.com.hk/zh/campaigns/browser-extension.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211207_homepage_earn_banner_browser-extension" target="_self" href="https://www.theclub.com.hk/zh/campaigns/browser-extension.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211207_homepage_earn_banner_browser-extension" rel="noopener noreferrer" class="undefined open-external"><img class="" alt="為你介紹 The Club全新瀏覽器擴充功能" srcset="/content/dam/theclub-spa-react/en/partners-offers/partners/kv/browser extension_v4_herobanner_tc.jpg" src="/content/dam/theclub-spa-react/en/partners-offers/partners/kv/browser extension_v4_herobanner_tc.jpg" title="" style=""><div class="OfferListTypeContainer"></div></a></div><div class="OfferListTitleContainer"><a to="https://www.theclub.com.hk/zh/campaigns/browser-extension.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211207_homepage_earn_banner_browser-extension" target="_self" href="https://www.theclub.com.hk/zh/campaigns/browser-extension.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=211207_homepage_earn_banner_browser-extension" rel="noopener noreferrer" class="undefined open-external"><div><div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">為你介紹 The Club全新瀏覽器擴充功能</div></div></a></div><div class="OfferListAuthorContainer"><div><div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent">讓你於超過130個合作夥伴網上平台購物時,不會錯過任何賺盡Club積分的機會。立即加到Chrome!</div></div></div></div>', | |
}, | |
{ | |
index: 6, | |
html: '<div id="offer-www-theclub-com-hk-zh-campaigns-easter_shopping_spree-html" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"><div class="OfferListImageContainer"><a to="https://www.theclub.com.hk/zh/campaigns/easter_shopping_spree.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220331_homepage_earn_banner_easter" target="_self" href="https://www.theclub.com.hk/zh/campaigns/easter_shopping_spree.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220331_homepage_earn_banner_easter" rel="noopener noreferrer" class="undefined open-external"><img class="" alt="復活節購物狂賞" srcset="https://www.theclub.com.hk/content/dam/theclub-spa-react/en/partners-offers/partners/kv/Easter_Promotion_1188x664_01tc.jpg" src="https://www.theclub.com.hk/content/dam/theclub-spa-react/en/partners-offers/partners/kv/Easter_Promotion_1188x664_01tc.jpg" title="" style=""><div class="OfferListTypeContainer"></div></a></div><div class="OfferListTitleContainer"><a to="https://www.theclub.com.hk/zh/campaigns/easter_shopping_spree.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220331_homepage_earn_banner_easter" target="_self" href="https://www.theclub.com.hk/zh/campaigns/easter_shopping_spree.html?itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220331_homepage_earn_banner_easter" rel="noopener noreferrer" class="undefined open-external"><div><div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">復活節購物狂賞</div></div></a></div><div class="OfferListAuthorContainer"><div><div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent">The Club 特別集合 20 個人氣美妝及時尚品牌網上平台,為會員帶來節日限定購物狂賞,以最抵優惠*入手大熱產品之餘,更可同時賺Club積分!</div></div></div></div>', | |
}, | |
]; | |
var club_shopping_offers = [ | |
{ | |
index: 1, | |
html: '<div id="offer-shop-theclub-com-hk-promotions-cvs22-samsung-html" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"><div class="OfferListImageContainer"><a to="https://shop.theclub.com.hk/promotions/cvs22-samsung.html?___store=zh_Hant_HK&itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220401_cvs22_samsung_indexpagebanner" target="_blank" href="https://shop.theclub.com.hk/promotions/cvs22-samsung.html?___store=zh_Hant_HK&itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220401_cvs22_samsung_indexpagebanner" rel="noopener noreferrer" class="undefined open-external"><img class="" alt="Samsung消費券優惠: 指定產品額外減HK$200" srcset="/content/dam/theclub-spa-react/en/partners-offers/partners/kv/CVS22 Banner (1188x664).png" src="/content/dam/theclub-spa-react/en/partners-offers/partners/kv/CVS22 Banner (1188x664).png" title="Samsung消費券優惠: 指定產品額外減HK$200"><div class="OfferListTypeContainer"></div></a></div><div class="OfferListTitleContainer"><a to="https://shop.theclub.com.hk/promotions/cvs22-samsung.html?___store=zh_Hant_HK&itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220401_cvs22_samsung_indexpagebanner" target="_blank" href="https://shop.theclub.com.hk/promotions/cvs22-samsung.html?___store=zh_Hant_HK&itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220401_cvs22_samsung_indexpagebanner" rel="noopener noreferrer" class="undefined open-external"><div><div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">Samsung消費券優惠: 指定產品額外減HK$200</div></div></a></div><div class="OfferListAuthorContainer"><div><div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent">上Club Shopping買指定Samsung產品,並輸入優惠碼【CVS22】 即減HK$200!Galaxy S22 5G系列折後低至HK$6,098,立即搶購!</div></div></div></div>', | |
}, | |
{ | |
index: 2, | |
html: '<div id="offer-shop-theclub-com-hk-samsung-galaxy-a53-5g-8-256gb-ss-galaxy-a53-html" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"><div class="OfferListImageContainer"><a to="https://shop.theclub.com.hk/samsung-galaxy-a53-5g-8-256gb-ss-galaxy-a53.html?___store=zh_Hant_HK&itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220401_a53_launch_samsung_indexpagebanner" target="_blank" href="https://shop.theclub.com.hk/samsung-galaxy-a53-5g-8-256gb-ss-galaxy-a53.html?___store=zh_Hant_HK&itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220401_a53_launch_samsung_indexpagebanner" rel="noopener noreferrer" class="undefined open-external"><img class="" alt="Samsung Galaxy A53 5G 現正發售" srcset="/content/dam/theclub-spa-react/en/partners-offers/partners/kv/A53 Lauch banner 1188x664 V2.png" src="/content/dam/theclub-spa-react/en/partners-offers/partners/kv/A53 Lauch banner 1188x664 V2.png" title="Samsung Galaxy A53 5G 現正發售"><div class="OfferListTypeContainer"></div></a></div><div class="OfferListTitleContainer"><a to="https://shop.theclub.com.hk/samsung-galaxy-a53-5g-8-256gb-ss-galaxy-a53.html?___store=zh_Hant_HK&itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220401_a53_launch_samsung_indexpagebanner" target="_blank" href="https://shop.theclub.com.hk/samsung-galaxy-a53-5g-8-256gb-ss-galaxy-a53.html?___store=zh_Hant_HK&itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220401_a53_launch_samsung_indexpagebanner" rel="noopener noreferrer" class="undefined open-external"><div><div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">Samsung Galaxy A53 5G 現正發售</div></div></a></div><div class="OfferListAuthorContainer"><div><div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent">購買Galaxy A53 5G即送Club Shopping獨家HK$300自選禮品及享半價優惠加購Galaxy Buds Live無線降噪耳機 ! 立即搶購!</div></div></div></div>', | |
}, | |
{ | |
index: 3, | |
html: '<div id="offer-shop-theclub-com-hk-promotions-monthly-wine-promotion-html" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"><div class="OfferListImageContainer"><a to="https://shop.theclub.com.hk/promotions/monthly-wine-promotion.html?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220401_apr_monthlywinepromotion_clubindexpage" target="_blank" href="https://shop.theclub.com.hk/promotions/monthly-wine-promotion.html?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220401_apr_monthlywinepromotion_clubindexpage" rel="noopener noreferrer" class="undefined open-external"><img class="" alt="每月美酒優惠" srcset="/content/dam/theclub-spa-react/club-shopping/WinePromo_1188x664_April_01tc.jpg" src="/content/dam/theclub-spa-react/club-shopping/WinePromo_1188x664_April_01tc.jpg" title="每月美酒優惠"><div class="OfferListTypeContainer"></div></a></div><div class="OfferListTitleContainer"><a to="https://shop.theclub.com.hk/promotions/monthly-wine-promotion.html?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220401_apr_monthlywinepromotion_clubindexpage" target="_blank" href="https://shop.theclub.com.hk/promotions/monthly-wine-promotion.html?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220401_apr_monthlywinepromotion_clubindexpage" rel="noopener noreferrer" class="undefined open-external"><div><div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">每月美酒優惠</div></div></a></div><div class="OfferListAuthorContainer"><div><div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent">精選烈酒買滿HK$1,000享9折!醉CHILL星期四限時優惠!</div></div></div></div>', | |
}, | |
{ | |
index: 4, | |
html: '<div id="offer-shop-theclub-com-hk-dondondonki-grandopen" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"><div class="OfferListImageContainer" style="max-width:100%"><a to="https://shop.theclub.com.hk/dondondonki-grandopen?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220401_apr-offer_donki_clubindexpage" target="_blank" href="https://shop.theclub.com.hk/dondondonki-grandopen?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220401_apr-offer_donki_clubindexpage" rel="noopener noreferrer" class="undefined open-external"><img class="" alt="DON DON DONKI 家居清潔好幫手" srcset="/content/dam/theclub-spa-react/club-shopping/HKT210601_22065_Donki_StaticBanner_1188x664px_r2_TC.jpg" src="/content/dam/theclub-spa-react/club-shopping/HKT210601_22065_Donki_StaticBanner_1188x664px_r2_TC.jpg" title="DON DON DONKI 家居清潔好幫手"><div class="OfferListTypeContainer"></div></a></div><div class="OfferListTitleContainer"><a to="https://shop.theclub.com.hk/dondondonki-grandopen?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220401_apr-offer_donki_clubindexpage" target="_blank" href="https://shop.theclub.com.hk/dondondonki-grandopen?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220401_apr-offer_donki_clubindexpage" rel="noopener noreferrer" class="undefined open-external"><div><div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">DON DON DONKI 家居清潔好幫手</div></div></a></div><div class="OfferListAuthorContainer"><div><div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent">精選家居清潔法寶及零食套裝低至65折發售!</div></div></div></div>', | |
}, | |
{ | |
index: 5, | |
html: '<div id="offer-shop-theclub-com-hk-promotions-apple-npi-spring2022-html" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"><div class="OfferListImageContainer"><a to="https://shop.theclub.com.hk/promotions/apple-npi-spring2022.html?___store=zh_Hant_HK&itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220318_spring2022_launch_apple_indexpagebanner" target="_blank" href="https://shop.theclub.com.hk/promotions/apple-npi-spring2022.html?___store=zh_Hant_HK&itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220318_spring2022_launch_apple_indexpagebanner" rel="noopener noreferrer" class="undefined open-external"><img class="" alt="Apple 春季發佈會2022產品現正發售!" srcset="/content/dam/theclub-spa-react/en/partners-offers/partners/kv/Apple new product - Spring 2022 - The Club index page banner.png" src="/content/dam/theclub-spa-react/en/partners-offers/partners/kv/Apple new product - Spring 2022 - The Club index page banner.png" title="Apple 春季發佈會2022產品現正發售!"><div class="OfferListTypeContainer"></div></a></div><div class="OfferListTitleContainer"><a to="https://shop.theclub.com.hk/promotions/apple-npi-spring2022.html?___store=zh_Hant_HK&itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220318_spring2022_launch_apple_indexpagebanner" target="_blank" href="https://shop.theclub.com.hk/promotions/apple-npi-spring2022.html?___store=zh_Hant_HK&itm_source=clubloyalty&itm_medium=buwebsite&itm_campaign=220318_spring2022_launch_apple_indexpagebanner" rel="noopener noreferrer" class="undefined open-external"><div><div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">Apple 春季發佈會2022產品現正發售!</div></div></a></div><div class="OfferListAuthorContainer"><div><div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent">全新 iPhone 13 Pro 松嶺綠色、 iPhone 13 綠色、 iPhone SE (第三代)及 iPad Air (第五代) 現已登陸Club Shopping! 立即搶購!</div></div></div></div>', | |
}, | |
{ | |
index: 6, | |
html: '<div id="offer-shop-theclub-com-hk-samsung-handsets-s22-series-html" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"><div class="OfferListImageContainer"><a to="https://shop.theclub.com.hk/samsung/handsets/s22-series.html?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220304_s22_launch_samsung_clubindexpage" target="_blank" href="https://shop.theclub.com.hk/samsung/handsets/s22-series.html?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220304_s22_launch_samsung_clubindexpage" rel="noopener noreferrer" class="undefined open-external"><img class="" alt="Samsung Galaxy S22 系列 現正發售!" srcset="/content/dam/theclub-spa-react/en/partners-offers/partners/kv/S22 launch banner TC.jpg" src="/content/dam/theclub-spa-react/en/partners-offers/partners/kv/S22 launch banner TC.jpg" title="Samsung Galaxy S22 系列 現正發售!"><div class="OfferListTypeContainer"></div></a></div><div class="OfferListTitleContainer"><a to="https://shop.theclub.com.hk/samsung/handsets/s22-series.html?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220304_s22_launch_samsung_clubindexpage" target="_blank" href="https://shop.theclub.com.hk/samsung/handsets/s22-series.html?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220304_s22_launch_samsung_clubindexpage" rel="noopener noreferrer" class="undefined open-external"><div><div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">Samsung Galaxy S22 系列 現正發售!</div></div></a></div><div class="OfferListAuthorContainer"><div><div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent">購買 Galaxy S22 系列 送總值高達HK$2,754禮品!</div></div></div></div>', | |
}, | |
{ | |
index: 7, | |
html: '<div id="offer-shop-theclub-com-hk-apple-watch-s7-html" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"><div class="OfferListImageContainer"><a to="https://shop.theclub.com.hk/apple/watch/s7.html?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220119_watchs7-200off_apple_clubindexpage" target="_blank" href="https://shop.theclub.com.hk/apple/watch/s7.html?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220119_watchs7-200off_apple_clubindexpage" rel="noopener noreferrer" class="undefined open-external"><img class="" alt="Apple Watch Series 7 即享HK$200折扣!" srcset="/content/dam/theclub-spa-react/club-shopping/Apple Watch S7 banner the club banner _1188x664_TC.png" src="/content/dam/theclub-spa-react/club-shopping/Apple Watch S7 banner the club banner _1188x664_TC.png" title="Apple Watch Series 7 即享HK$200折扣!"><div class="OfferListTypeContainer"></div></a></div><div class="OfferListTitleContainer"><a to="https://shop.theclub.com.hk/apple/watch/s7.html?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220119_watchs7-200off_apple_clubindexpage" target="_blank" href="https://shop.theclub.com.hk/apple/watch/s7.html?itm_source=clubshopping&itm_medium=buwebsite&itm_campaign=220119_watchs7-200off_apple_clubindexpage" rel="noopener noreferrer" class="undefined open-external"><div><div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">Apple Watch Series 7 即享HK$200折扣!</div></div></a></div><div class="OfferListAuthorContainer"><div><div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent">低至HK$3,799即可入手!</div></div></div></div>', | |
}, | |
]; | |
//var ran_list = [1,2,3,4,5,6,7,8,9,10,11,12] | |
function setRandom(number_list, button,ran_list,result_number,origin_css_selector,offers,category) { | |
debugger | |
var ran_list = ran_list || [1, 2, 3, 4, 5, 6]; | |
var res_number = result_number || 6 | |
var result_list = number_list || getRandom(ran_list, res_number); | |
for (var i = 0; i < 3; i++) { | |
let o = search(result_list[i], offers); | |
console.log( category +" : radom offer line 1"); | |
console.log(o); | |
applyHTML(origin_css_selector[i], o.html); | |
} | |
/*if(category === 'earn'){ | |
document.getElementById('at_earn_style').parentNode.removeChild(document.getElementById('at_earn_style')) | |
} | |
if(category === 'club shopping'){ | |
document.getElementById('at_club_shopping_style').parentNode.removeChild(document.getElementById('at_club_shopping_style')) | |
}*/ | |
let flag; | |
if(category === 'earn'){ | |
flag = window.at_earn_more_text_click | |
} | |
if(category === 'club shopping'){ | |
flag = window.at_club_shopping_show_more_text_click | |
} | |
//let earn_show_btn = button | |
if(!!button){ | |
button.addEventListener("click", function () { | |
setTimeout(function () { | |
//if (flag === "init") { | |
for (var i = 3; i < 6; i++) { | |
let o = search(result_list[i], offers); | |
console.log("radom offer line 2"); | |
console.log(o); | |
applyHTML(origin_css_selector[i], o.html); | |
} | |
if(category === 'earn'){ | |
window.at_earn_more_text_click = 'second' | |
} | |
if(category === 'club shopping'){ | |
window.at_club_shopping_show_more_text_click = 'second' | |
let temp_bt = document.querySelector('#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div.div-button-container.col-12 > div') | |
temp_bt.style = 'display:none' | |
}; | |
return | |
// } | |
// if (window.at_earn_more_text_click === "second") { | |
// for (var i = 6; i < 9; i++) { | |
// let o = search(result_list[i], offers); | |
// console.log("radom offer line 3"); | |
// console.log(o); | |
// applyHTML(earn_selector[i], o.html); | |
// } | |
//} | |
}, 1500); | |
}); | |
} | |
} | |
function createHTMLTemplate(offer,category) { | |
let target_method; | |
if(category === 'earn'){ | |
target_method = '_self' | |
} | |
if(category === 'club shopping'){ | |
target_method = "_blank" | |
} | |
var res_html = []; | |
for (var recs in offer) { | |
let temp = `<div id="${offer[recs].id}" class="OfferListItemContainer col-md-4 col-12" style="max-width:100%"> | |
<div class="OfferListImageContainer"><a to="${offer[recs].pageUrl}" target="${target_method}" href="${offer[recs].pageUrl}" | |
rel="noopener noreferrer" class="undefined open-external"><img class="" alt="recs.name" | |
srcset="${offer[recs].thumbnailUrl}" src="${offer[recs].thumbnailUrl}" title="" style=""> | |
<div class="OfferListTypeContainer"></div> | |
</a></div> | |
<div class="OfferListTitleContainer"><a to="${offer[recs].pageUrl}" target="${target_method}" href="${offer[recs].pageUrl}" | |
rel="noopener noreferrer" class="undefined open-external"> | |
<div> | |
<div class="sc-ftvSup eobHHr OfferListTitle" data-parallax="false">${offer[recs].name}</div> | |
</div> | |
</a></div> | |
<div class="OfferListAuthorContainer"> | |
<div> | |
<div data-parallax="false" data-rte-editelement="true" class="sc-ftvSup eobHHr OfferDescriptionContent"> | |
${offer[recs].message}</div> | |
</div> | |
</div> | |
</div>`; | |
res_html.push(temp); | |
} | |
return res_html; | |
} | |
function setRec(res,button,origin_css_selector,category) { | |
debugger | |
if (!!res.adobeRecommendations.recDetailedResults.recEntity1Details.id) { | |
var recs = createHTMLTemplate(res.adobeRecommendations.recDetailedResults,category); | |
let flag; | |
if(category === 'earn'){ | |
flag = window.at_earn_more_text_click | |
} | |
if(category === 'club shopping'){ | |
flag = window.at_club_shopping_show_more_text_click | |
} | |
for (var i = 0; i < 3; i++) { | |
console.log(category + " :Recs offer line 1"); | |
console.log(recs[i]); | |
applyHTML(origin_css_selector[i], recs[i]); | |
} | |
/*if(category === 'earn'){ | |
document.getElementById('at_earn_style').parentNode.removeChild(document.getElementById('at_earn_style')) | |
} | |
if(category === 'club shopping'){ | |
document.getElementById('at_club_shopping_style').parentNode.removeChild(document.getElementById('at_club_shopping_style')) | |
}*/ | |
debugger | |
//let earn_show_btn = button | |
if(!!button){ | |
button.addEventListener("click", function () { | |
setTimeout(function () { | |
//if (flag === "init") { | |
for (var i = 3; i < 6; i++) { | |
console.log(recs[i]); | |
applyHTML(origin_css_selector[i], recs[i]); | |
} | |
if(category === 'club shopping'){ | |
window.at_club_shopping_show_more_text_click = 'second' | |
let temp_bt = document.querySelector('#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div.div-button-container.col-12 > div') | |
temp_bt.style = 'display:none' | |
//}; | |
return | |
} | |
}, 1500); | |
}); | |
} | |
} else { | |
console.log("no recs resut yet, Set fixed order"); | |
var result_list = [3, 2, 1, 6, 5, 4]; | |
for (var i = 0; i < 3; i++) { | |
let o = search(result_list[i], offers); | |
console.log("Rec radom offer line 1"); | |
console.log(o); | |
applyHTML(origin_css_selector[i], o.html); | |
} | |
let earn_show_btn = button | |
if(!!earn_show_btn){ | |
earn_show_btn.addEventListener("click", function () { | |
setTimeout(function () { | |
if (window.at_earn_more_text_click === "init") { | |
for (var i = 3; i < 6; i++) { | |
let o = search(result_list[i], offers); | |
console.log(Category + " :Recs radom offer line 2"); | |
console.log(o); | |
applyHTML(origin_css_selector[i], o.html); | |
} | |
} | |
}, 1500); | |
}); | |
} | |
} | |
} | |
//window.targetGlobalSettings = { | |
//timeout: 200, // using custom timeout | |
//visitorApiTimeout: 500, // using custom API timeout | |
// clientCode:"clubhkt"// enabled ONLY on adobe.com | |
//}; | |
function antiFlick(win, doc, style, timeout,sc,id) { | |
var STYLE_ID =id || 'at-offer-style'; | |
function getParent() { | |
return doc.querySelector(sc); | |
} | |
function addStyle(parent, id, def) { | |
if (!parent) { | |
return; | |
} | |
var style = doc.createElement('style'); | |
style.id = id; | |
style.innerHTML = def; | |
parent.appendChild(style); | |
} | |
function removeStyle(parent, id) { | |
if (!parent) { | |
return; | |
} | |
var style = doc.getElementById(id); | |
if (!style) { | |
return; | |
} | |
parent.removeChild(style); | |
} | |
addStyle(getParent(), STYLE_ID, style); | |
//setTimeout(function() { | |
// removeStyle(getParent(), STYLE_ID); | |
// }, timeout); | |
} | |
//antiFlick(window, document, "#container-d502ef979f {opacity: 0 !important}", 3000, "#container-d502ef979f"); | |
//document.getElementById('at_earn_style').parentNode.removeChild(document.getElementById('at_earn_style')) | |
var earn_show_more_selector = [ | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div.div-button-container.col-12 > div > div > div.show-more-text", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div.div-button-container.col-12 > div > div > div.show-more-text" | |
] | |
var earn_show_more_bn_el = getShowMoreButton(earn_show_more_selector) | |
function getEarnAT(){ | |
if(document.location.pathname.indexOf('/zh')!= -1){ | |
//antiFlick(window, document, "#container-d502ef979f {opacity: 0 !important}", 3000, "#container-d502ef979f",'at_earn_style'); | |
} | |
if(document.location.pathname.indexOf('/zh')!=-1){ | |
adobe.target | |
.getOffers({ | |
request: { | |
prefetch: { | |
mboxes: [ | |
{ | |
index: 0, | |
name: "mbox", | |
}, | |
], | |
}, | |
}, | |
}) | |
.then((response) => { | |
// get all mboxes from response | |
const mboxes = response.prefetch.mboxes; | |
debugger; | |
if(!mboxes[0].hasOwnProperty("options")){ | |
console.log("No Recs Yet") | |
setRandom([3,2,1,5,4,6],earn_show_more_bn_el,[1,2,3,4,5,6],6,earn_selector,offers,'earn') | |
window.at_exp_version = { | |
exp: "res", | |
offers:"No Recs Yet", | |
}; | |
return | |
} | |
if (mboxes[0].options[0].type === "html" && mboxes[0].options[0].content.indexOf("textarea") != -1) { | |
applyHTML( | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container", | |
mboxes[0].options[0].content | |
); | |
return; | |
} | |
console.log(mboxes[0].options[0].content === "object"); | |
if (typeof mboxes[0].options[0].content === "object") { | |
res = mboxes[0].options[0].content; | |
} else { | |
res = JSON.parse(mboxes[0].options[0].content); | |
} | |
console.log(res); | |
if (!!res && res.hasOwnProperty("exp") && res.exp.indexOf("random") != -1) { | |
window.at_exp_version = { | |
exp: "random", | |
offer: res, | |
}; | |
console.log("activate Random Expreince"); | |
setRandom(undefined, earn_show_more_bn_el,[1,2,3,4,5,6],6,earn_selector,offers,'earn'); | |
return; | |
} else if (!!res && res.hasOwnProperty("adobeRecommendations")) { | |
console.log("activate Recs Expreince"); | |
window.at_exp_version = { | |
exp: "res", | |
offers: res, | |
}; | |
setRec(res,earn_show_more_bn_el,earn_selector,'earn'); | |
return; | |
} else { | |
window.at_exp_version = { | |
exp: "control", | |
offers: res, | |
}; | |
console.log("Do nothing Default Exprience"); | |
if(category === 'earn'){ | |
document.getElementById('at_earn_style').parentNode.removeChild(document.getElementById('at_earn_style')) | |
} | |
if(category === 'club shopping'){ | |
document.getElementById('at_club_shopping_style').parentNode.removeChild(document.getElementById('at_club_shopping_style')) | |
} | |
return; | |
} | |
}); | |
} | |
} | |
var club_shopping_show_more = [ | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div.div-button-container.col-12 > div > div > div.show-more-text", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div.div-button-container.col-12 > div > div > div.show-more-text" | |
] | |
var club_show_more_bn_el = getShowMoreButton(club_shopping_show_more) | |
function getClubShopAT(){ | |
if(document.location.pathname.indexOf('/zh')!= -1){ | |
//antiFlick(window, document, "#container-79caac9575 {opacity: 0 !important}", 3000, "#container-79caac9575",'at_club_shopping_style'); | |
} | |
if(document.location.pathname.indexOf('/zh')!=-1){ | |
adobe.target.getOffers({ | |
request: { | |
prefetch: { | |
mboxes: [ | |
{ | |
index: 0, | |
name: "mbox2", | |
}, | |
], | |
}, | |
}, | |
}) | |
.then((response) => { | |
// get all mboxes from response | |
const mboxes = response.prefetch.mboxes; | |
debugger; | |
if(!mboxes[0].hasOwnProperty("options")){ | |
console.log("No Recs Yet") | |
setRandom([3,2,1,5,4,6],club_show_more_bn_el,[1,2,3,4,5,6,7],6,club_shopping_selector,club_shopping_offers,'club shopping') | |
//function setRandom(number_list, button,ran_list,result_number,origin_css_selector,offers,category) | |
window.at_exp_club_shopping_version = { | |
exp: "res", | |
offers:"No Recs Yet", | |
}; | |
return | |
} | |
if (mboxes[0].options[0].type === "html" && mboxes[0].options[0].content.indexOf("textarea") != -1) { | |
applyHTML( | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container", | |
mboxes[0].options[0].content | |
); | |
return; | |
} | |
console.log(mboxes[0].options[0].content === "object"); | |
if (typeof mboxes[0].options[0].content === "object") { | |
res = mboxes[0].options[0].content; | |
} else { | |
res = JSON.parse(mboxes[0].options[0].content); | |
} | |
console.log(res); | |
if (!!res && res.hasOwnProperty("exp") && res.exp.indexOf("random") != -1) { | |
window.at_exp_club_shopping_version = { | |
exp: "random", | |
offer: res, | |
}; | |
console.log("activate Random Expreince"); | |
setRandom(undefined, club_show_more_bn_el,[1,2,3,4,5,6,7],6,club_shopping_selector,club_shopping_offers,'club shopping'); | |
return; | |
} else if (!!res && res.hasOwnProperty("adobeRecommendations")) { | |
console.log("activate Recs Expreince"); | |
window.at_exp_club_shopping_version = { | |
exp: "res", | |
offers: res, | |
}; | |
setRec(res,club_show_more_bn_el,club_shopping_selector,'club shopping'); | |
return; | |
} else { | |
window.at_exp_club_shopping_version = { | |
exp: "control", | |
offers: res, | |
}; | |
console.log("Do nothing Default Exprience"); | |
return; | |
} | |
}); | |
} | |
} | |
//getClubShopAT() | |
//getClubShopAT() | |
//getEarnAT() | |
if(document.URL.match('adobeQA=true')){ | |
getEarnAT() | |
getClubShopAT() | |
} | |
///// AA implementation | |
window.aa_earn_more_text_click = "init"; | |
function getElements(selector_list) { | |
if (selector_list.length > 0) { | |
for (var i = 0; i < selector_list.length; i++) { | |
var els = document.querySelector(selector_list[i]); | |
console.log(els); | |
console.log(selector_list[i]); | |
if (!!els && els.className.indexOf("OfferListItemContainer") != -1) { | |
return els; | |
} | |
} | |
} | |
} | |
function getIndex(elements) { | |
debugger | |
let el; | |
if(elements.parentElement.id.indexOf('theclub')!=-1){ | |
el = elements.parentElement | |
}else{ | |
el = elements | |
} | |
var child = el; | |
var parent = child.parentNode; | |
// The equivalent of parent.children.indexOf(child) | |
var index = Array.prototype.indexOf.call(parent.children, child); | |
return index + 1; | |
} | |
function getShowMoreButton(button_selector){ | |
for(let i = 0; i < button_selector.length; i++){ | |
if(!!document.querySelector(button_selector[i])){ | |
return document.querySelector(button_selector[i]) | |
} | |
} | |
} | |
var offers_elements = [ | |
{ | |
category: "earn", | |
position: 1, | |
css_select: [ | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1) > div", | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1)", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1) > div", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1)", | |
], | |
}, | |
{ | |
category: "earn", | |
position: 2, | |
css_select: [ | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2) > div", | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2)", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2) > div", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2)", | |
], | |
}, | |
{ | |
category: "earn", | |
position: 3, | |
css_select: [ | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3) > div", | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3)", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3) > div", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3)", | |
], | |
}, | |
{ | |
category: "earn", | |
position: 4, | |
css_select: [ | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4) > div", | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4)", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4) > div", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4)", | |
], | |
}, | |
{ | |
category: "earn", | |
position: 5, | |
css_select: [ | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5) > div", | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5)", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5) > div", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5)", | |
], | |
}, | |
{ | |
category: "earn", | |
position: 6, | |
css_select: [ | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6) > div", | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6)", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6) > div", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6)", | |
], | |
}, | |
]; | |
function getOfferId(element){ | |
//debugger | |
let s = element.children | |
if(!!element.children[0]){ | |
if(!!element.children[0].id){ | |
if(element.children[0].id.indexOf('offer') != -1){ | |
return element.children[0].id | |
} | |
} | |
} | |
return element.id | |
} | |
function callback(offer, category) { | |
let mboxName | |
if(category === 'earn'){ | |
mboxName = 'mbox' | |
} | |
if(category === 'club shopping'){ | |
mboxName = 'mbox2' | |
} | |
if(document.URL.match('adobeQA=true')){ | |
if (!!window.hasOwnProperty('at_exp_version')) { | |
if (window.at_exp_version.exp === "random") { | |
adobe.target.getOffers({ | |
request: { | |
execute: { | |
mboxes: [ | |
{ | |
index: 0, | |
name: mboxName, | |
parameters: { | |
"entity.id": getOfferId(offer), | |
}, | |
}, | |
], | |
}, | |
}, | |
}); | |
adobe.target.trackEvent({ | |
mbox: mboxName, | |
params: { | |
"entity.id": getOfferId(offer), | |
}, | |
}); | |
} | |
} | |
adobe.target.trackEvent({ | |
mbox: "offer_click", | |
type:"click" | |
}); | |
} | |
// adobe.target.trackEvent({ | |
// mbox: "click_offer", | |
// params: { | |
// orderId: new Date().getTime(), | |
// orderTotal: "1", | |
// productPurchasedId:offer.id, | |
// }, | |
// timeout:1000 | |
//}); | |
debugger | |
_satellite.track("offerClick", { | |
category: category, | |
offerPosition: getIndex(offer), | |
offerId: getOfferId(offer), | |
}); | |
console.log({ | |
category: category, | |
offerPosition: getIndex(offer), | |
offerId: getOfferId(offer), | |
}); | |
} | |
for (var i = 0; i < 3; i++) { | |
console.log(offers_elements[i]); | |
let temp = offers_elements[i]; | |
let el = getElements(offers_elements[i].css_select); | |
//console.log(el); | |
console.log("listen to " + el.id); | |
el.addEventListener("click", function () { | |
console.log(el); | |
callback(el, "earn"); | |
}); | |
} | |
var earn_show_more_selector = [ | |
"#container-d502ef979f > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div.div-button-container.col-12 > div > div > div.show-more-text", | |
"#container-e2e5a06157 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div.div-button-container.col-12 > div > div > div.show-more-text" | |
] | |
var earn_show_more_bn = getShowMoreButton(earn_show_more_selector) | |
earn_show_more_bn.addEventListener("click", function () { | |
_satellite.track("showMoreClick", { | |
category: "earn", | |
}); | |
console.log("Earn Show More Click"); | |
setTimeout(function () { | |
//if (window.aa_earn_more_text_click === "init") { | |
for (var i = 3; i < 6; i++) { | |
console.log(offers_elements[i]); | |
let temp = offers_elements[i]; | |
let el = getElements(offers_elements[i].css_select); | |
//console.log(el); | |
console.log("listen to " + el.id); | |
el.addEventListener("click", function () { | |
console.log(el); | |
callback(el, "earn"); | |
}); | |
} | |
window.aa_earn_more_text_click = "second"; | |
//} | |
// if (window.aa_earn_more_text_click === "second") { | |
// for (var i = 6; i < 9; i++) { | |
// console.log(offers_elements[i]); | |
// let temp = offers_elements[i]; | |
// let el = document.querySelector(offers_elements[i].css_select); | |
//console.log(el); | |
// console.log("listen to " + el.id); | |
// el.addEventListener("click", function () { | |
// console.log(el); | |
// callback(el); | |
// }); | |
// } | |
// } | |
}, 2000); | |
}); | |
window.aa_club_shopping_more_text_click = "init"; | |
var club_shopping_offers_elements = [ | |
{ | |
category: "club shopping", | |
position: 1, | |
css_select: [ | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1) > div", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1)", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1) > div", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1)" | |
], | |
}, | |
{ | |
category: "club shopping", | |
position: 2, | |
css_select: [ | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2) > div", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2)", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2) > div", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2)" | |
], | |
}, | |
{ | |
category: "club shopping", | |
position: 3, | |
css_select: [ | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3) > div", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3)", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3) > div", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3)" | |
], | |
}, | |
{ | |
category: "club shopping", | |
position: 4, | |
css_select: [ | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4) > div", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4)", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4) > div", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4)" | |
], | |
}, | |
{ | |
category: "club shopping", | |
position: 5, | |
css_select: [ | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5) > div", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5)", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5) > div", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5)" | |
], | |
}, | |
{ | |
category: "club shopping", | |
position: 6, | |
css_select: [ | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6) > div", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6)", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6) > div", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6)" | |
], | |
}, | |
{ | |
category: "club shopping", | |
position: 7, | |
css_select: [ | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(7) > div", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(7)", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(7) > div", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(7)" | |
], | |
}, | |
{ | |
category: "club shopping", | |
position: 8, | |
css_select: [ | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(8) > div", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(8)", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(8) > div", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(8)" | |
], | |
}, | |
{ | |
category: "club shopping", | |
position: 9, | |
css_select: [ | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(9) > div", | |
"#container-79caac9575 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(9)", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(9) > div", | |
"#container-d67f6e1937 > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(9)" | |
], | |
}, | |
]; | |
for (var i = 0; i < 3; i++) { | |
console.log(club_shopping_offers_elements[i]); | |
let temp = club_shopping_offers_elements[i]; | |
let el = getElements(club_shopping_offers_elements[i].css_select); | |
//console.log(el); | |
console.log( | |
"listen to " + ":" + club_shopping_offers_elements[i].category + ":" + el.id | |
); | |
el.addEventListener("click", function () { | |
console.log(el); | |
callback(el, "club shopping"); | |
}); | |
} | |
var club_shopping_show_more_bn = getShowMoreButton(club_shopping_show_more) | |
club_shopping_show_more_bn.addEventListener("click", function () { | |
_satellite.track("showMoreClick", { | |
category: "club shopping", | |
}); | |
console.log("club shopping More Click"); | |
setTimeout(function () { | |
//if (window.aa_club_shopping_more_text_click === "init") { | |
for (var i = 3; i < 6; i++) { | |
console.log(club_shopping_offers_elements[i]); | |
let temp = club_shopping_offers_elements[i]; | |
let el = getElements( | |
club_shopping_offers_elements[i].css_select | |
); | |
//console.log(el); | |
console.log("listen to " + el.id); | |
el.addEventListener("click", function () { | |
console.log(el); | |
callback(el, "club shopping"); | |
}); | |
} | |
window.aa_club_shopping_more_text_click = "second"; | |
return; | |
//} | |
/*if (window.aa_club_shopping_more_text_click === "second") { | |
for (var i = 6; i < 9; i++) { | |
console.log(club_shopping_offers_elements[i]); | |
let temp = club_shopping_offers_elements[i]; | |
let el = getElements( | |
club_shopping_offers_elements[i].css_select | |
); | |
//console.log(el); | |
console.log("listen to " + el.id); | |
el.addEventListener("click", function () { | |
console.log(el); | |
callback(el, "club shopping"); | |
}); | |
} | |
window.aa_club_shopping_more_text_click = "third"; | |
return; | |
}*/ | |
}, 2000); | |
}); | |
window.aa_redeem_show_more_text_click = "init"; | |
var redeem_offers_elements = [ | |
{ | |
category: "redeem", | |
position: 1, | |
css_select: [ | |
"#container-e6a202a61d > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1) > div", | |
"#container-e6a202a61d > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1)", | |
"#container-542d8470ab > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1) > div", | |
"#container-542d8470ab > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(1)" | |
], | |
}, | |
{ | |
category: "redeem", | |
position: 2, | |
css_select: [ | |
"#container-e6a202a61d > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2) > div", | |
"#container-e6a202a61d > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2)", | |
"#container-542d8470ab > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2) > div", | |
"#container-542d8470ab > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(2)" | |
], | |
}, | |
{ | |
category: "redeem", | |
position: 3, | |
css_select: [ | |
"#container-e6a202a61d > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3) > div", | |
"#container-e6a202a61d > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3)", | |
"#container-542d8470ab > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3) > div", | |
"#container-542d8470ab > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(3)" | |
], | |
}, | |
{ | |
category: "redeem", | |
position: 4, | |
css_select: [ | |
"#container-e6a202a61d > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4) > div", | |
"#container-e6a202a61d > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4)", | |
"#container-542d8470ab > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4) > div", | |
"#container-542d8470ab > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(4)" | |
], | |
}, | |
{ | |
category: "redeem", | |
position: 5, | |
css_select: [ | |
"#container-e6a202a61d > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5) > div", | |
"#container-e6a202a61d > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5)", | |
"#container-542d8470ab > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5) > div", | |
"#container-542d8470ab > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(5)" | |
], | |
}, | |
{ | |
category: "redeem", | |
position: 6, | |
css_select: [ | |
"#container-e6a202a61d > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6) > div", | |
"#container-e6a202a61d > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6)", | |
"#container-542d8470ab > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6) > div", | |
"#container-542d8470ab > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div:nth-child(6)" | |
], | |
}, | |
]; | |
for (var i = 0; i < 3; i++) { | |
console.log(redeem_offers_elements[i]); | |
let temp = redeem_offers_elements[i]; | |
let el = getElements(redeem_offers_elements[i].css_select); | |
//console.log(el); | |
console.log( | |
"listen to " + ":" + redeem_offers_elements[i].category + ":" + el.id | |
); | |
el.addEventListener("click", function () { | |
console.log(el); | |
callback(el, "redeem"); | |
}); | |
} | |
var redeem_show_more = [ | |
"#container-e6a202a61d > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div.div-button-container.col-12 > div > div > div.show-more-text", | |
"#container-542d8470ab > div > div > div:nth-child(2) > div.selected-offers-container > div > div > div > div.div-button-container.col-12 > div > div > div.show-more-text" | |
] | |
var redeem_show_more_bn = getShowMoreButton(redeem_show_more) | |
redeem_show_more_bn.addEventListener("click", function () { | |
_satellite.track("showMoreClick", { | |
category: "redeem", | |
}); | |
console.log("redeem More Click"); | |
setTimeout(function () { | |
//if (window.aa_redeem_show_more_text_click === "init") { | |
for (var i = 3; i < 6; i++) { | |
console.log(redeem_offers_elements[i]); | |
let temp = redeem_offers_elements[i]; | |
let el = getElements( | |
redeem_offers_elements[i].css_select | |
); | |
//console.log(el); | |
console.log( | |
"listen to " + ":" + redeem_offers_elements[i].category + ":" + el.id | |
); | |
console.log( | |
el | |
); | |
el.addEventListener("click", function () { | |
console.log(el); | |
callback(el, "redeem"); | |
}); | |
} | |
window.aa_redeem_show_more_text_click = "second"; | |
return; | |
//} | |
}, 2000); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment