chromeæ¡å¼µã®éçºã§è¨å®ãã¼ã¿ãä¿åãã
chromeæ¡å¼µã§ãã¼ã¿ãä¿åããæ¹æ³ã¨ãã¦ã¯2ã¤ãã
html5ã®locatStorageã使ãæ¹æ³ã¨chrome extentionã®APIã§ããchrome.storageã使ãæ¹æ³ãããã
html5ã®locatStorageã使ãæ¹æ³ã¯ãæ®éã«localStorageã使ãã ããªã®ã§ç°¡åã ãããµã¤ãã§ä½¿ç¨ãã¦ããå ´åã«ãã¼ã¿ã被ãã¨å«ãªã®ã§ãchrome.storageã®æ¹ã使ã£ã¦ã¿ãã
注æç¹ã¨ãã¦ã¯ã³ã¼ã«ããã¯ã¨ãã¦é¢æ°ãæä¾ããã¦ãããã¨
chrome.storage.sync.getã®ã³ã¼ã«ããã¯ä¸ã«
chrome.storage.sync.setãæ¸ãããã«ããªãã¨ãªããªãã®ã§ã
ãã¹ãã1段深ããªãã
åç´ã«chrome.storage.sync.getãsetã並ã¹ã¦æ¸ãã¨getããã®ã«æéãæããçºãå ã«setãå®è¡ããã
chrome.storage.sync.get(['dateStrings'],function(items){ var dateStrings; dateStrings = items.dateStrings; // ã¹ã¯ãªããå®è¡æéãåå¾ãã date = new Date(); var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); var hours = date.getHours(); var minutes = date.getMinutes(); var seconds = date.getSeconds(); dateStrings = year + "/" + ("0"+month ).slice(-2) + "/" + ("0"+day ).slice(-2) + " " + ("0"+hours ).slice(-2) + ":" + ("0"+minutes).slice(-2) + ":" + ("0"+seconds).slice(-2); items = { dateStrings : dateStrings } chrome.storage.sync.set(items, function(){}); });
追è¨
chrome.storageã¯ãã¤ããªã¯ä¿åã§ããªãã
objectåãä¿åã§ããã®ã§ãã§ããããªã¨æã£ããã©ã§ããªãã£ãã
setæã¨ã©ã¼ã¯ç¹ã«çºçããªãããä¸èº«ã空ã®Object{}åã«å¤æããã¦ãã¼ã¿ãå£ããã
ãã®å ´åã¯chrome.filesystemã«ä¿åããæ¹ãããï¼ï¼