// ye get_max() use hota hai hide wale fxn me, and add_delivery k get_a2c me function get_max(arr){ return Math.max.apply(Math, arr); } function onlyUnique(value, index, self) { return self.indexOf(value) === index; } // hmare internal fxns function final_polish( master_array ){ let final_array = []; let n = master_array.length; for( i=0; i 0){ let carr = [].slice.call(cccc.children); master_array = master_array.concat(carr); } } master_array = master_array.filter(onlyUnique); return master_array; } // utility fxns function get_forms(){ let forms = document.querySelectorAll('form[action*="cart/Add" i]'); return forms; } function get_childs(form){ let c = [].slice.call(form.children); for(let i=0; i<25; i++){ c = polish(c); } return c; } function get_childless_childs(form){ let c = get_childs(form); return final_polish(c); } function get_form_variant_id(form){ let p = {}; // potential_ids // case 1 - input hai and usme id hai let c = get_childs(form); for(let i=0;i"; form.appendChild(div2); } } } function remove_order_type_input(form) { if( form.querySelectorAll(".pp_a").length > 0 ){ form.querySelectorAll(".pp_a")[0].remove(); } if( form.querySelectorAll(".pp_aSP").length > 0 ){ form.querySelectorAll(".pp_aSP")[0].remove(); } } a2c_txts = [ "indenwarenkorblegen", "addtocart", "addtobag", "addtobasket", "ajouteraupanier", "indenwarenkorb", "indeneinkaufswagen", "agregaralcarrito", "añadiralcarrito", "añadiralacesta", "加入購物車", "加入購物清單", "加入购物车", "aggiungialcarrello", "Додадивокошничка", "カートに追加する", "j'ajouteàmonpanier", "sepeteekle", "abinskörbchen", "aanwinkelwagentoevoegen", "alcarrito", "leggihandlekurv", "adaugaincos", "カートに追加", "přidat", "přidatdokošíku", "přidatdobatohu", "přidatdotašky", "adicionaraocarrinho", "أضفإلىالسلة", "dodajdokoszyka", "lägivarukorb", "läglvarukorb", "läggivarukorb", "lägglvarukorb", "indenwinkaufswagenlegen", "läggivarukorg", "添加到购物车", "dodajvvoziček", "dodajvtorbo", "dodajvkošarico", "j'ajouteàmonpanier🛒", "lisääostoskoriin", "この商品をカートへ入れる", "toevoegenaanwinkelwagen", "adăugațiîncoș", "indeneinkaufswagenlegen", "放入購物車", "addtoshoppingcart", "lægikurven", "הוספהלסל", "tilføjtilkurv", "inwarenkorb", "voegtoeaanwinkelwagen", "hozzáadásakosárhoz", "tambahkankekeranjang", "カートに入れる", "aggiungialcalderone", "masukkankekeranjang", "카트에추가", "thêmvàogiỏhàng", "ajouter", "tilføjkurv", "lægiindkøbskurv", "adaugîncoș", "läggivarukorgen", "カートに追加するにゃ!", "läggtillikundvagnen ", "dodajukorpu", "장바구니에추가", "προσθήκηστοκαλάθι", "føjtilindkøbskurv", ]; buy_now_txts = [ "jetztkaufenmitgooglepaymit", "weiterebezahlmöglichkeiten", "buyitnow", "buynowwithgooglepaybuywith", "buynow", "achetezmaintenant", "achetermaintenant", "kaufen", "jetztkaufen", "comprarahora", "立刻購買", "立即购买", "acquistaora", "今すぐ購入", "hemensatınalın", "nukopen", "kjøpnå", "koupitteď", "kupnyní", "kupteraz", "köpnu", "comprar", "kupitezdaj", "belisekarang", "buynowwithshoppay", "αγοράμεαντικαταβολή", ]; console.log("Helper js - script loaded!"); function save_variant_yes_no(){ //window.location.pathname ana chaiye, and cart bi ache se he /cart etc jese if(window.location.href.includes('cart')){ return; } url = "https://pre.bossapps.co/api/js/boucebackboom.myshopify.com/variants"; fetch(url).then(r => r.json()).then(data => { local_set('vdata',data); //console.log(data); });} function get_variant_yes_no(v){ let r = local_get('vdata'); if(!r){return 'no';}// mtlb data hale server to aaya ni, r null aa, local_clear() naal eda hunda, until we fetch the request with save_variant_yes_no // mtlb agar value hai if(r[v]){ return r[v]; }else{ return 'no';//mtlb bhai ne v select he ni kra } } function get_selling_plan(v){ let r = local_get('vdata'); if(!r){return flase;} // mtlb agar value hai if(r[v+'SP']){ return r[v+'SP']; } return false; } function replace_controller(form) { //for ( let i=0; i < a2c_txts.length; i++ ){ // replace_btn( a2c_txts[i], "Pre Order",form ); //} replace_btn( "Pre Order",form ); } function hide_btn_controller(form) { //for ( let i=0; i < buy_now_txts.length; i++ ){ // hide_btn( buy_now_txts[i],form); //} hide_btn(form); } // add delivery ka helper hai ye. //btn_txt is small case, without spaces //ye jaan buj k global rakha hai a2c_pre = a2c_txts.concat("Pre Order".toLowerCase().split(' ').join('')); function get_a2c(form) { for(let yo = 0;yo 0){ return; } let a2c = get_a2c(form); if (a2c == 'nahi mila a2c'){return;} let p = document.createElement('p'); let t = document.createTextNode(delivery_info_text); p.appendChild(t); p.classList.add("pnda-delivery-info"); a2c.parentElement.prepend(p); } function remove_delivery(form){ try{ form.getElementsByClassName('pnda-delivery-info')[0].remove(); } catch (err){ // console.log('err while removing delivery info',form); } } // eh warning suppress karda, on click te chalda, // par ui hale v slow krrea azat da /// logic //local_clear(); save_variant_yes_no(); async function run(form){ let v = await get_form_variant_id(form); if(!v['select_se']){ v = v['input_se']; } else { v = v['select_se']; } let yn = await get_variant_yes_no(v); if(yn == 'yes'){ await replace_controller(form); await hide_btn_controller(form); await append_order_type_input(form); await append_selling_plan(form, v); } else { await remove_order_type_input(form); } } async function runner(){ let f = get_forms(); for (let i=0;i