Skip to content

Instantly share code, notes, and snippets.

@skttl
Created July 11, 2019 09:45
Show Gist options
  • Save skttl/f755d7d5e4111b7ebaa7cb7b960818a2 to your computer and use it in GitHub Desktop.
Save skttl/f755d7d5e4111b7ebaa7cb7b960818a2 to your computer and use it in GitHub Desktop.
IKEA huskeliste til js object
console.table([...products].map(p => {
var o = {};
o.name = p.querySelector(".product__name").innerText;
o.description = [...p.querySelectorAll(".product__description-list > :not(:last-child)")].map(d => d.innerText).join(" ");
o.articlenumber = p.querySelector(".product_description-article-number").innerText;
o.price = (p.querySelector(".product__price-regular") || p.querySelector(".product__total")).innerText;
o.quantity = p.querySelector(".product-controls__quantity select").value;
o.total = p.querySelector(".product__total").innerText;
return o;
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment