Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions markasread/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ <h3>Clear</h3>
<p>WARNING! This will delete all stored data regarding sites you've visited!</p>
<button id="clear">Clear All Stored Data</button>
</section>
<section>
<h3>Number of URLs Read</h3>
<div id="visited-count"></div>
</section>
</body>
</html>
12 changes: 11 additions & 1 deletion markasread/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ function upload() {
upload.value = '';
}

async function getVisitedCount() {
const obj = await chrome.storage.local.get("visited")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error on calling this line

Uncaught (in promise) TypeError: Error in invocation of storage.get(optional [string|array|object] keys, function callback): No matching signature.
    at getVisitedCount (options.js:24:44)
    at HTMLDocument.<anonymous> (options.js:46:64)

I believe you need to use chrome.storage.local.get("visited", function(obj) instead, as done elsewhere in the project.

const visited = obj["visited"]
return Object.keys(visited)
.filter(key => key != "version")
.flatMap(key => visited[key])
.length
}

function openDialog() {
document.getElementById('upload').click();
}
Expand All @@ -28,9 +37,10 @@ function clearData() {
chrome.storage.local.clear();
}

document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', async function() {
document.getElementById("download").addEventListener("click", download);
document.getElementById('upload').addEventListener("change", upload, false);
document.getElementById("import").addEventListener('click', openDialog);
document.getElementById("clear").addEventListener('click', clearData)
document.getElementById("visited-count").innerText = await getVisitedCount()
}, false);