Galaxy S25 | S25+
6 meses de Gemini Advanced gratuitos e 2 TB de armazenamento Online!
Click to Expand
// `;
// parent.innerHTML += template;
const pricemonthly = (sku.price / monthlypayment) - discount;
const oldpricemontly = window.currencyComma(pricemonthly,window.currency);
const promopricemonthly = (sku.promotionPrice / monthlypayment) - discount;
const newpricemonthly = window.currencyComma(promopricemonthly,window.currency);
const oldpriceone = sku.price - discount;
const oldpricetwo = window.currencyComma(oldpriceone,window.currency);
//let oldpriceonerounded = Number(oldpriceone.toFixed(0));
//const oldpricetwo = localecurrency.format((sku.price - discount));
const newpriceone = sku.promotionPrice - discount;
//let newpriceonerounded = newpriceone.toFixed(0);
const newpricetwo = window.currencyComma(newpriceone ,window.currency);
//change the 'mo. or' to match correct region information
const template = `
${oldpricetwo}
${newpricetwo} ou ${newpricemonthly}/mês*
`;
parent.innerHTML += template;
}
}
}
// function addMerchText() {
// const selectedModel = document
// .querySelector(
// `div.s-option-box.hubble-pd-radio.js-radio-wrap.is-checked input[data-typecode=OPT-015]`
// )
// .getAttribute("data-displayname");
// let text = "";
// console.log("merchtextmodel", selectedModel);
// if (selectedModel === "Galaxy Book3 360") {
// text = "512 GB za ceno 256 GB";
// }
// const inputEl = document.querySelector("#" + targetOption);
// const container = inputEl.parentNode;
// const template = `
//
// `;
// const merchText = document.querySelectorAll(".pd-merch-text-container");
// if (merchText && merchText.length > 0) {
// merchText.forEach((el) => {
// el.remove();
// });
// }
// if (container) {
// container.innerHTML += template;
// } else {
// console.log("no container");
// }
// }
function callback(mutationsList) {
console.log("callback");
for (let mutation of mutationsList) {
// console.log(mutation);
if (
mutation.type === "childList" ||
mutation.attributeName === "data-modelcode"
) {
console.log("mutation");
addPrice();
console.log("model", model);
const selectedModel = document
.querySelector(
`div.s-option-box.hubble-pd-radio.js-radio-wrap.is-checked input[data-typecode=OPT-015]`
)
.getAttribute("data-displayname");
if (selectedModel === "Galaxy S25") {
// addMerchText();
} else if (selectedModel === "Galaxy S25+") {
// addMerchText();
}
}
}
}
addCSS(targetOption);
//
const observer = new MutationObserver(callback);
const config = {
childList: true,
subtree: true,
characterData: true,
attributes: true,
};
console.log(observerTarget);
observer.observe(observerTarget, config);
addPrice(targetOption);
window.setTimeout(() => {
//for some reason adding it on the first run breaks the mutation observer
const selectedModel = document
.querySelector(
`div.s-option-box.hubble-pd-radio.js-radio-wrap.is-checked input[data-typecode=OPT-015]`
)
.getAttribute("data-displayname");
if (selectedModel === "Galaxy S25") {
// addMerchText();
}
}, 500);
return () => {
console.log("disconnecting", targetOption);
observer.disconnect();
const styleTag = document.querySelector(
"#hubble-pd-price-strikethrough_" + targetOption
);
if (styleTag) {
styleTag.remove();
}
const newPriceTag = document.querySelectorAll(`.s-rdo-price-new`);
if (newPriceTag && newPriceTag.length > 0) {
newPriceTag.forEach((el) => {
console.log("priceTag teardown", el);
el.remove();
});
}
const merchText = document.querySelectorAll(".pd-merch-text-container");
if (merchText && merchText.length > 0) {
merchText.forEach((el) => {
el.remove();
});
}
};
}
function strikeThroughConfiguratorHandler(targetOption, model) {
return createStrikeThroughPrice(
targetOption,
model,
document.querySelector("#" + targetOption)
);
}
function strikeThroughPriceBarHandler(targetOption, model) {
return createStrikeThroughPrice(
targetOption,
model,
document.querySelector(`div.hubble-price-bar__price-total`)
);
}
function initStrikeThrough() {
//get current device
const initialDeviceSelector = document.querySelector(
`div.s-option-box.hubble-pd-radio.js-radio-wrap.is-checked input[data-typecode=OPT-015]`
);
const initialDevice = initialDeviceSelector.getAttribute("data-displayname");
console.log("init");
if (initialDevice === "Galaxy S25") {
const init = () => {
const tearDown1 = strikeThroughConfiguratorHandler(
"OPT-007_2",
initialDevice
);
const tearDown2 = strikeThroughConfiguratorHandler(
"OPT-007_3",
initialDevice
);
const tearDown3 = strikeThroughPriceBarHandler(
"OPT-007_2",
initialDevice
);
const tearDown4 = strikeThroughPriceBarHandler(
"OPT-007_3",
initialDevice
);
return () => {
tearDown1();
tearDown2();
tearDown3();
tearDown4();
};
};
window.removeInitialStrikeThroughPrice = init();
} else if (initialDevice === "Galaxy S25+") {
console.log("init ultra inital");
const init = () => {
const tearDown1 = strikeThroughConfiguratorHandler(
"OPT-007_2",
initialDevice
);
const tearDown2 = strikeThroughConfiguratorHandler(
"OPT-007_3",
initialDevice
);
const tearDown3 = strikeThroughPriceBarHandler(
"OPT-007_2",
initialDevice
);
const tearDown4 = strikeThroughPriceBarHandler(
"OPT-007_3",
initialDevice
);
return () => {
tearDown1();
tearDown2();
tearDown3();
tearDown4();
};
};
window.removeInitialStrikeThroughPrice = init();
}
//detect change in current device
const deviceSelectors = document.querySelectorAll(
`div.s-option-box.hubble-pd-radio.js-radio-wrap input[data-typecode=OPT-015]`
);
const deviceClickHandler = (e) => {
const targetDevice = e.target.getAttribute("data-displayname");
if (window.removeInitialStrikeThroughPrice) {
console.log("cleaning up");
window.removeInitialStrikeThroughPrice();
}
if (targetDevice === "Galaxy S25") {
const init = () => {
const tearDown1 = strikeThroughConfiguratorHandler(
"OPT-007_2",
initialDevice
);
const tearDown2 = strikeThroughConfiguratorHandler(
"OPT-007_3",
initialDevice
);
const tearDown3 = strikeThroughPriceBarHandler(
"OPT-007_2",
initialDevice
);
const tearDown4 = strikeThroughPriceBarHandler(
"OPT-007_3",
initialDevice
);
return () => {
tearDown1();
tearDown2();
tearDown3();
tearDown4();
};
};
window.removeInitialStrikeThroughPrice = init();
} else if (targetDevice === "Galaxy S25+") {
console.log("init ultra");
const init = () => {
const tearDown1 = strikeThroughConfiguratorHandler(
"OPT-007_2",
initialDevice
);
const tearDown2 = strikeThroughConfiguratorHandler(
"OPT-007_3",
initialDevice
);
const tearDown3 = strikeThroughPriceBarHandler(
"OPT-007_2",
initialDevice
);
const tearDown4 = strikeThroughPriceBarHandler(
"OPT-007_3",
initialDevice
);
return () => {
tearDown1();
tearDown2();
tearDown3();
tearDown4();
};
};
window.removeInitialStrikeThroughPrice = init();
}
};
deviceSelectors.forEach((deviceSelector) => {
deviceSelector.addEventListener("click", (e) => {
const targetDevice = e.target.getAttribute("data-displayname");
if (
window.BC_CARTDATA &&
window.BC_CARTDATA.tradeinData &&
window.BC_CARTDATA.tradeinData.price
) {
const waitForTradeIn = () => {
console.log("waiting for trade in");
if (
targetDevice !==
document
.querySelector(
`div.s-option-box.hubble-pd-radio.js-radio-wrap.is-checked input[data-typecode=OPT-015]`
)
.getAttribute("data-displayname")
) {
setTimeout(() => {
waitForTradeIn();
}, 200);
} else {
deviceClickHandler(e);
}
};
waitForTradeIn();
} else {
deviceClickHandler(e);
}
});
});
}
function waitForBC(time) {
console.log("waiting for bc");
if (
//window.NEWSYDICATEPRODUCTDATALIST &&
//window.NEWSYDICATEPRODUCTDATALIST.length > 0 &&
document.querySelector(
`div.s-option-box.hubble-pd-radio.js-radio-wrap.is-checked input[data-typecode=OPT-015]`
)
) {
initStrikeThrough();
return;
} else {
setTimeout(function () {
waitForBC(time);
}, time);
}
}
waitForBC(500);