SHARE
TWEET

Untitled

a guest May 23rd, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript:if(!('remove'in Element.prototype)){Element.prototype.remove=function(){if(this.parentNode){this.parentNode.removeChild(this)}}};function showDiscounts(){var minDiscount=100;function getProducts(){return[].slice.call(document.getElementsByTagName('*')).filter(function(e){if(e.getAttribute("data-asin")!==null&&e.className!=="asinImage"){return true}return false})}function productHasDiscount(product){if(product.getAttribute("data-a-strike")!==null){return true}else if(product.children&&product.children.length){var prodHasDisc=false;[].slice.call(product.children).forEach(function(c){var discExists=productHasDiscount(c);if(discExists){prodHasDisc=true}});return prodHasDisc}return false}function showDiscount(){var discElements=[].slice.call(document.getElementsByTagName('*')).map(function(e){if(e.getAttribute("data-a-strike")!==null){return e.parentElement}return null}).filter(function(d){return d!==null});discElements.forEach(function(e){calcDiscount(e)});reorderItems(getProducts());function calcDiscount(parEl){var currencySymbol=parEl.children[0].children[0].innerText[0];var discPrice=parEl.children[0].children[0].innerText.replace(/[£$€]/,"").replace(/\,/,"")*1;var origPrice=parEl.children[parEl.children.length-1].children[0].innerText.replace(/[£$€]/,"").replace(/\,/,"")*1;var discount=origPrice-discPrice;if(discount<minDiscount){getProductParent(parEl).remove();return}else{parEl.children[0].children[1].innerText="("+currencySymbol+discount.toFixed(2)+") "+currencySymbol+discPrice;getProductParent(parEl).setAttribute("data-discount",discount)}function getProductParent(e){if(e.getAttribute("data-asin")!==null){return e}else{return getProductParent(e.parentElement)}}}}function reorderItems(items){var parent=items[0].parentElement;var elements=document.createDocumentFragment();items.sort(function(a,b){return(b.getAttribute("data-discount"))-(a.getAttribute("data-discount")*1)}).forEach(function(item){elements.appendChild(item.cloneNode(true))});parent.innerHTML=null;parent.appendChild(elements)}var prods=getProducts();prods.forEach(function(p){if(!productHasDiscount(p)){p.remove()}});showDiscount()}showDiscounts();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top