Untitled
unknown
plain_text
2 years ago
2.9 kB
5
Indexable
(function () {
try {
/* main variables */
var debug = 0;
var variation_name = "";
var $;
/* all Pure helper functions */
function waitForElement(selector, trigger, delayInterval, delayTimeout) {
var interval = setInterval(function () {
if (
document &&
document.querySelector(selector) &&
document.querySelectorAll(selector).length > 0
) {
clearInterval(interval);
trigger();
}
}, delayInterval);
setTimeout(function () {
clearInterval(interval);
}, delayTimeout);
}
var bulletPoints = `
<ul class="eg-product-bullets">
<li>Ikonisches Design mit hochwertigen Materialien <span class="eg-bold">Made in Germany</span></li>
<li>Designqualität wurde ausgezeichnet mit dem <span class="eg-bold">German Design Award</span></li>
<li>Bestes Preis-Leistungs-Verhältnis - <span class="eg-bold">Kostenloser Versand!</span></li>
</ul>`;
var inkl = `<p class="eg-inkl">inkl. MwSt.</p>`;
/* Variation Init */
function init() {
var price = document.querySelector('html body .product__info .price');
var price2 = document.querySelector('html body .product-meta__price-list-container .price');
var lastSelector = document.querySelector('html body .product-form__variants .product-form__option-selector:nth-child(3)');
var shipping = document.querySelector('html body .product-form .shipping_indicator');
var form = document.querySelector('html body .product-form .product-form__variants');
var productQuantity = document.querySelector('html body .product-form .product-form__quantity');
var paymentContainer = document.querySelector('html body .product-form #MainPaymentContainer');
var formFirst = document.querySelector('html body .product-form > div:first-child');
if (shipping && form) {
form.insertAdjacentElement("beforeend", shipping);
}
if (price && lastSelector) {
lastSelector.insertAdjacentElement("afterend", price);
}
if (price2 && shipping) {
shipping.insertAdjacentElement("beforebegin", price2);
}
if (formFirst && !document.querySelector('.eg-product-bullets')) {
formFirst.insertAdjacentHTML("afterend", bulletPoints);
}
if (paymentContainer && productQuantity) {
paymentContainer.insertAdjacentElement("afterbegin", productQuantity);
}
if (shipping && !document.querySelector('.eg-inkl')) {
shipping.insertAdjacentHTML("beforeend", inkl);
}
}
/* Initialize variation */
waitForElement('html body .product-form', init, 50, 15000);
} catch (e) {
if (debug) console.log(e, "error in Test" + variation_name);
}
})();
Editor is loading...
Leave a Comment