const data={'videos':{'https://www.wctc.co.jp/wp-content/uploads/2024/03/mv_movie-1.mp4':{'previewUrl':'https://customer-6lwuyo5n6cfk40c4.cloudflarestream.com/d29164bb0fafd5933cc97dacfbd60ddc/watch','dashUrl':'https://customer-6lwuyo5n6cfk40c4.cloudflarestream.com/d29164bb0fafd5933cc97dacfbd60ddc/manifest/video.mpd'}},'css':{'https://www.wctc.co.jp/wp-content/themes/wctc/css/stylesheet.css':{'.banner-block-hp .owl-theme .owl-nav .owl-prev':'background: url(https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/themes/wctc/images/slider_up_arrow.png/rcpg) no-repeat top center','.banner-block-hp .owl-theme .owl-nav .owl-next':'background: url(https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/themes/wctc/images/slider_down_arrow.png/rcpg) no-repeat bottom center','.form-field-input-cop select':'background: url(https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/themes/wctc/images/dropdown_arrow.png/rcpg) no-repeat right 26px center'}},'src':{'https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01121-scaled.jpg':'https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01121-scaled.jpg/rcpg','https://www.wctc.co.jp/wp-content/themes/wctc/images/right_arrow.png':'https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/themes/wctc/images/right_arrow.png/rcpg','https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01509-scaled.jpg':'https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01509-scaled.jpg/rcpg','https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01501-scaled.jpg':'https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01501-scaled.jpg/rcpg','https://www.wctc.co.jp/wp-content/themes/wctc/images/contact_banner.jpg':'https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/themes/wctc/images/contact_banner.jpg/rcpg','https://www.wctc.co.jp/wp-content/themes/wctc/images/logo.png':'https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/themes/wctc/images/logo.png/rcpg','https://www.wctc.co.jp/wp-content/themes/wctc/images/recruit_banner.jpg':'https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/themes/wctc/images/recruit_banner.jpg/rcpg','https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01411-scaled.jpg':'https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01411-scaled.jpg/rcpg','https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01365-scaled.jpg':'https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01365-scaled.jpg/rcpg','https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01160-scaled.jpg':'https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01160-scaled.jpg/rcpg'},'srcset':{'https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01160-scaled.jpg 2560w, https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01160-300x200.jpg 300w, https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01160-1024x683.jpg 1024w, https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01160-768x512.jpg 768w, https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01160-1536x1024.jpg 1536w':'https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01160-scaled.jpg/rcpg 2560w, https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01160-300x200.jpg/rcpg 300w, https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01160-1024x683.jpg/rcpg 1024w, https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01160-768x512.jpg/rcpg 768w, https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01160-1536x1024.jpg/rcpg 1536w','https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01365-scaled.jpg 2560w, https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01365-300x200.jpg 300w, https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01365-1024x683.jpg 1024w, https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01365-768x512.jpg 768w, https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01365-1536x1024.jpg 1536w':'https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01365-scaled.jpg/rcpg 2560w, https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01365-300x200.jpg/rcpg 300w, https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01365-1024x683.jpg/rcpg 1024w, https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01365-768x512.jpg/rcpg 768w, https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01365-1536x1024.jpg/rcpg 1536w','https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01411-scaled.jpg 2560w, https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01411-300x200.jpg 300w, https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01411-1024x683.jpg 1024w, https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01411-768x512.jpg 768w, https://www.wctc.co.jp/wp-content/uploads/2021/08/wctc-01411-1536x1024.jpg 1536w':'https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01411-scaled.jpg/rcpg 2560w, https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01411-300x200.jpg/rcpg 300w, https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01411-1024x683.jpg/rcpg 1024w, https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01411-768x512.jpg/rcpg 768w, https://imagedelivery.net/ceVF3uTUr6EqdmxeEW35QQ/wctc.co.jp/wp-content/uploads/2021/08/wctc-01411-1536x1024.jpg/rcpg 1536w'},'src_with_style':{}} const replaceImageAttributes=(element,imageURLReplace,attribute)=>{let value=element.getAttribute(attribute);if(value){element.setAttribute("loading","lazy");element.setAttribute(attribute,"");element.setAttribute(attribute,imageURLReplace);}};const processReplaceTagImg=(imageKey,imageURLReplace,attribute)=>{const imageElements=document.querySelectorAll(`img[${attribute}="${imageKey}"]`);if(imageElements.length>0){imageElements.forEach((imageElement,index)=>{replaceImageAttributes(imageElement,imageURLReplace,attribute);});}};const processReplaceTagImgBase64=(imageKey,imageURLReplace,attribute)=>{document.querySelectorAll(`[${attribute}^="data:image"]`).forEach((element)=>{const src=element.getAttribute("src");const base64Portion=src.split(",")[1];const firstFiveChars=base64Portion.substring(0,5);const lastTenChars=base64Portion.slice(-10);const imageKeyBase64=imageKey.split("/");const firstFveScharsRes=imageKeyBase64[0];const lastTenCharsRes=imageKeyBase64[1];if(firstFveScharsRes===firstFiveChars&&lastTenCharsRes===lastTenChars){replaceImageAttributes(element,imageURLReplace,attribute);}});};const overWriteStyleCss=(href,selectorObj)=>{let styleSheets=document.styleSheets;let styleSheet;for(i=0;i{var imageUrl="";var property="";if(backgroundObj.startsWith("background-image")){property="backgroundImage";imageUrl=backgroundObj.replace("background-image:","");}else if(backgroundObj.startsWith("background")){property="background";imageUrl=backgroundObj.replace("background:","");} var cssRules=styleSheet.cssRules||styleSheet.rules;try{if(imageUrl&&property){let selectorStr=selector;const pseudoSingle=selectorStr.split(":");if(pseudoSingle[1]==="before"||pseudoSingle[1]==="after"){selectorStr=`${pseudoSingle[0]}::${pseudoSingle[1]}`;} for(var i=0;i{const imageElements=document.querySelectorAll(`[style*="${imageKey}"]`);if(imageElements.length>0){imageElements.forEach((el,index)=>{const currentBackground=el.style.background;const currentBackgroundImage=el.style.backgroundImage;if(currentBackground){const newBackground=currentBackground.replace(imageKey,urlBackgroundReplace);el.style.background=newBackground;} if(currentBackgroundImage){const newBackground=currentBackgroundImage.replace(imageKey,urlBackgroundReplace);el.style.backgroundImage=newBackground;}});}};const processReplacePictureTag=(imageKey,urlImageReplace)=>{const sourceElements=document.querySelectorAll(`source[srcset="${imageKey}"]`);sourceElements.forEach((source)=>{replaceImageAttributes(source,urlImageReplace,"srcset");});};const processReplaceVideo=(videoKey,videoReplace)=>{const videos=document.querySelectorAll(`[src="${videoKey}"]`);videos.forEach((source)=>{replaceVideoSrcSource(source,videoReplace);});};const replaceVideoSrcSource=(source,videoReplace)=>{switch(source.tagName){case"VIDEO":source.setAttribute("src",videoReplace.dashUrl);source.setAttribute("data-dashjs-player",true);break;case"SOURCE":const parentVideo=source.parentNode;let src=source.getAttribute("src");if(src){source.setAttribute("src",videoReplace.dashUrl);source.setAttribute("type","application/dash+xml");parentVideo.load();} break;case"IFRAME":case"EMBED":source.setAttribute("src",videoReplace.previewUrl);source.setAttribute("loading","lazy");break;default:}};const addLazyLoadingToIframes=()=>{document.querySelectorAll("iframe").forEach((iframe)=>{const lazyIframe=document.createElement("iframe");Array.from(iframe.attributes).forEach((attr)=>{lazyIframe.setAttribute(attr.name,attr.value);});lazyIframe.setAttribute("loading","lazy");iframe.parentNode.replaceChild(lazyIframe,iframe);});};const proccessReplace=()=>{const head=document.querySelector("head");if(head)head.setAttribute("rel","preload");const{src,srcset,css,src_with_style,videos}=data;const srcsetPromises=srcset?Object.keys(srcset).map((key)=>{const imageURLReplace=srcset[key];return Promise.all([processReplacePictureTag(key,imageURLReplace),processReplaceTagImg(key,imageURLReplace,"srcset"),]);}):[];const srcPromises=src?Object.keys(src).map((key)=>{const imageURLReplace=src[key];return processReplaceTagImg(key,imageURLReplace,"src");}):[];const cssPromises=css?Object.keys(css).map((key)=>{const index=key;const selectorObj=css[key];return overWriteStyleCss(index,selectorObj);}):[];const srcWithStylePromises=src_with_style?Object.keys(src_with_style).map((key)=>{const urlBackgroundReplace=src_with_style[key];return processReplaceCssWithStyle(key,urlBackgroundReplace);}):[];const videoPromises=videos?Object.keys(videos).map((key)=>{const videoReplace=videos[key];return processReplaceVideo(key,videoReplace);}):[];return Promise.all([...cssPromises,...srcsetPromises,...srcPromises,...srcWithStylePromises,...videoPromises,addLazyLoadingToIframes(),]);};proccessReplace().then(()=>{console.log("All replacements processed successfully.");}).catch((error)=>{console.error("An error occurred while processing replacements:",error);});