Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- divsToUpdate = document.getElementsByClassName("olpOffer");
- var i = 0;
- while (i < divsToUpdate.length){
- var d = divsToUpdate[i];
- var o = d.getElementsByClassName("olpOfferPrice")[0];
- var p = o.innerText;
- //var amountRegex = new RegExp(/[0-9\.]+/ig);
- //console.log("Parent: ",d);
- //console.log("Span : ",p);
- //console.log("Regex : ",amountRegex.exec(p));
- var amountRegex = new RegExp(/[0-9\.]+/ig);
- var cost = amountRegex.exec(p);
- //console.log("Cost : ",cost);
- // not all have a shipping price
- var shipping = 0.0;
- var s = d.getElementsByClassName("olpShippingPrice")[0];
- if (s !== undefined) {
- var amountRegex = new RegExp(/[0-9\.]+/ig);
- shipping = amountRegex.exec(s.innerText);
- }
- //console.log(d);
- var c = parseFloat(cost) + parseFloat(shipping);
- //console.log("Actual Price: " + c);
- // now replace the big red price with the ACTUAL price
- o.removeAttribute("class", "a-size-large");
- actualPrice = document.createElement("span");
- actualPrice.className = "a-size-large a-color-price olpOfferPrice a-text-bold";
- actualPrice.innerText = c;
- o.parentElement.insertBefore(actualPrice, o.parentElement.firstChild);
- i++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement