2017-06-18 13 views
1

私はぼかしでsave_notes関数を実行するようにコード化されたテキストエリアを持っています。 save_notesが起動すると、私はコンソールでこれを取得する:chrome.storage.sync呼び出しの結果:TypeError:未定義のプロパティ 'sync'を読み取ることができません

TypeError: Cannot read property 'sync' of undefined 
    at HTMLTextAreaElement.save_notes 

Javascriptコード:

var note_area = document.getElementById('notetext') 

//// todo Create a function to save the textarea to local storage 
// todo First check & load any previously saved notes 

;(function load_notes() { 
    if (note_area === "") { 
    chrome.storage.sync.get("stored_obj", function(resultObj) { 
     note_area.value = resultObj.stored_obj 
    }) 
    } 
})() 

function save_notes() { 
    chrome.storage.sync.set({ 
    stored_obj: note_area.value 
    }, function() { 
    // console.log("Saved into Chrome Storage") 
    }) 
} 

note_area.addEventListener('blur', save_notes) 

this topic manifest.jsonをする記憶許可を追加する必要がポスターによります。

私のmanifest.jsonにはすでにその行が含まれています。他に必要な権限がないか、コード自体に無関係な問題があるかどうかは不思議です。あなたはmanifest.jsonをファイルを変更

manifest.jsonを

{ 
    "manifest_version": 2, 

    "name": "Mindless Blocker", 
    "description": "Block mindless distractions and have a place to take notes for followup during free time", 
    "version": "0.1", 
    "browser_action": { 
    "default_icon": "cloud-icon.png", 
    "default_popup": "index.html" 
    }, 
    "permissions": [ 
    "storage" 
    ] 
} 

答えて

0

、あなたはあなたの拡張機能のリストをリロードする必要があります。

chrome://extensions/に移動し、Ctrl + Rキーを押します。

関連する問題