I've read a lot of posts about the 5mb limit and and stiff confused. On this page
https://groups.google.com/a/chromium.org/g/chromium-extensions/c/6_SoqKPkZpI/m/RyUCiZCyAwAJ There was this text "HTML5 localStorage is always limited to 5MB (computed as a combined string length which actually means 10MB physical bytes on disk because strings are 2-byte unicode in JS)."
I have a storage viewer built into my extensions (hidden by default) It reports;
Total Storage: 5.79MB f 5MB (5928.11 KB) - 115.78% used
So, can I go more, or am I already in trouble? It looks like unlimited storage in manifest will not help. Any help or clarification is appreciated.
// Populate dropdown with storage keys and their sizes
chrome.storage.local.get(null, function(items) {
let totalSize = 0;
// Add total size as first option
const totalOption = document.createElement('option');
totalOption.value = '';
Object.keys(items).forEach(key => {
const option = document.createElement('option');
// Calculate size of this item
const size = new TextEncoder().encode(JSON.stringify(items[key])).length;
totalSize += size;
const sizeInKB = (size / 1024).toFixed(2);
option.value = key;
option.text = `${key} (${sizeInKB} KB)`;
select.appendChild(option);
});
// Update total size option
const totalInMB = (totalSize / (1024 * 1024)).toFixed(2);
const totalInKB = (totalSize / 1024).toFixed(2);
const percentUsed = ((totalSize / (5 * 1024 * 1024)) * 100).toFixed(2);
totalOption.text = `Total Storage: ${totalInMB}MB / 5MB (${totalInKB}KB) - ${percentUsed}% used`;
select.insertBefore(totalOption, select.firstChild);