Last active
August 29, 2015 14:08
-
-
Save user19/0fcc60d7817f563814ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var select = function(){ | |
for(var i=1;i<=100;i++) | |
if(!(location.pathname+i in window.localStorage)) | |
return location.pathname+i; | |
} | |
var category = "[" + document.getElementsByClassName("path btmPath")[0].getElementsByTagName("a")[2].getElementsByTagName("span")[0].innerHTML + "]"; | |
var title = document.getElementById("titleBox").getElementsByTagName("h2")[0].innerHTML; | |
var price = document.getElementById("minPrice").getElementsByTagName("span")[0].innerHTML; | |
var obj = {category:category,title:title,price:price}; | |
window.localStorage.setItem(select(),JSON.stringify(obj)); | |
var str = ""; | |
var sum = 0; | |
for(key in window.localStorage){ | |
if(key.search(/item/) >= 0){ | |
var obj2 = JSON.parse(window.localStorage.getItem(key)); | |
for(key2 in obj2){ | |
str += obj2[key2]; | |
str += " "; | |
if(key2 == "price") | |
sum += Number(obj2[key2].slice(1).replace(",","")); | |
} | |
str += "\n"; | |
} | |
} | |
str += "合計" + " " + "\\" + String(sum).replace(/(\d)(?=(\d\d\d)+(?!\d))/g,'$1,'); | |
alert(str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment