PageSourceSearch

https://img.creative.com/landingpages/sale/switchpdtimg.js?v=0.1

js creative.com collected 2026-10-02 09:50:31 UTC 1,667 bytes, 38 lines download raw bytes

1//collect all pdt from promo list
2const arrAllPdt = promoList.flatMap(element => element.Products);
3
4//find pdt using pdt id from all pdt
5const getPdtObjfromPromo = function(pdtID){  
6  return arrAllPdt.find(e=>e.ID == pdtID);
7};
8
9//switch pdt image function, using observe to watch dom and replace the img to target color
10//this function will query all the pdt exist the same id and replace their img
11const switchPdtImg = function(pdtID,storeIDs,color){
12  const pdtObj = getPdtObjfromPromo(pdtID);
13
14  if(storeIDs.includes(global.store.id) && pdtObj){
15    const observer = new MutationObserver(() => {
16        const nodes = document.querySelectorAll(`div[data-productid='${pdtID}']`);
17        if (nodes.length > 0) {
18            Array.from(nodes).forEach(function(e){
19              // change img
20              e.innerHTML=e.innerHTML.replace("cat-"+pdtObj.UrlSlug,"cat-"+pdtObj.UrlSlug+"-"+color);
21            })
22            observer.disconnect(); // stop observe
23        }
24    });
25
26    // start observe
27    observer.observe(document.body, { childList: true, subtree: true });    
28  }
29};
30
31//this replace product image using {Product master ID}, {store ID array}, and {color attribute name (english)}
32//*Make sure the target color you wish to join with other country is same, otherwise use a different function to call
33//*Make sure color attribute img exist! - You can test the actual img path using the combination
34//https://img.creative.com/images/products/categories/cat-{pdtUrlSlug}-{color}.png
35
36
37switchPdtImg(24204,[3,4],"black"); //Creative Zen Air Pro - Black
38switchPdtImg(23891,[37],"black"); //Creative Hybrid sXFI - Black

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.