Skip to content

Instantly share code, notes, and snippets.

@koduki
Created January 23, 2011 07:30
Show Gist options
  • Save koduki/791901 to your computer and use it in GitHub Desktop.
Save koduki/791901 to your computer and use it in GitHub Desktop.
/*
https://books.step.rakuten.co.jp/rms/mall/book/bs/Cart
https://books.step.rakuten.co.jp/rms/mall/book/bs/Cart?shop_bid=213310
*/
var trs = jQuery("html body div form table tbody tr td table tbody tr:has(img[alt='削除'])")
var items = trs.toArray().map(function(tr){
var item = jQuery(tr)
var name = item.find("td a").eq(1)
var isbn = item.find("td b").eq(0).text()
var price = jQuery(item.find("td").get().reverse()[7]).text()
return {
title: name.text(),
link: name.attr("href"),
isbn: isbn.replace(/.*ISBN:(.*?)\)/g, function(){return RegExp.$1}).trim(),
price:parseInt(price.replace(/\D/g, ""))
}})
window.localStorage.setItem('order_items', JSON.stringify(items));
JSON.parse(window.localStorage.getItem('order_items'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment