Skip to content

Instantly share code, notes, and snippets.

@mateusmaaia
Last active November 17, 2019 15:15
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mateusmaaia/4c756abaf41e582ea4ea720ecb1a022c to your computer and use it in GitHub Desktop.
Save mateusmaaia/4c756abaf41e582ea4ea720ecb1a022c to your computer and use it in GitHub Desktop.
Discover what products are sold and distributed by Dafiti's
javascript:(
function(){
$(".banner-text-box").css("display", "none");
$(".col-md-3").css("width","15%");
$(".col-md-9").css("width","85%");
$(".product-list-col-3 .product-box").css({"width": "30%", "margin-right": "3%"});
$(".product-box").each((i, item) => {
url = $(item).find(".quickview-link.product-box-preview").attr("data-remote");
$.get(url, function(data) {
var elements = $(data);
var soldByDafiti = $('.product-seller-name', elements).find("strong").text();
var soldByKanui = $('.product-seller-name', elements).text();
$(item).css({"border-radius":"2%","border-width":"3px"});
if (soldByDafiti === "Dafiti" || soldByKanui.indexOf("Kanui") > 0) {
$(item).css({
"border-style":"solid",
"border-color":"green"
});
var price = ($(item).find(".product-box-price .product-box-price-to").text() !="" && $(item).find(".product-box-price .product-box-price-to") != undefined)
? $(item).find(".product-box-price .product-box-price-to").text() : $(item).find(".product-box-price .product-box-price-from").text();
var v = parseInt(price.replace(/\D/g,""));
var d = (v * 0.7).toFixed(0) + "";
var discount = (!isNaN(v)) ? d.substring(0, d.length-2) + ',' + d.substring(d.length-2) : "";
$(item).find(".product-box-price").append("<br /><span style='color:green;'>-30%: R$ " + discount +"</span>");
} else {
$(item).css({
"border-style":"dotted",
"border-color":"red"
});
}
});
});
}
) (document);
@mateusmaaia
Copy link
Author

@julio-maia Added Kanui store support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment