The error message DOMException: The operation is insecure typically occurs when a web page script tries to access a browser API or perform an action that is disallowed for security reasons, such as accessing a database that is not on the same domain as the web page.

It is possible that the indexedDB.databases() call is being prevented by the browser’s same-origin policy, which restricts scripts from accessing resources not on the same domain as the page. To avoid this error, you should either ensure that the script is running on the same domain as the database or you could use a server-side language to access the database and call that via AJAX request.

If you need to delete all indexedDB databases, another approach you could try is iterating through the array returned by indexedDB.getDatabaseNames()(for Firefox), and delete each database individually. now try normally do this: if (typeof browser !== "undefined" && browser.history) { // Firefox
    const millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7;
    browser.browsingData.remove({
        "since": new Date().getTime() - millisecondsPerWeek
    }, {
        "history": true
    });
}
else if (typeof indexedDB !== "undefined" && indexedDB.databases) { // Chrome
    indexedDB.databases().then(function(dbs) {
        for (var i = 0; i < dbs.length; i++) {
            var req = indexedDB.deleteDatabase(dbs[i].name);
            req.onsuccess = function(event) {
                console.log("Database deleted successfully.");
            };
            req.onerror = function(event) {
                console.log("Error deleting database.");
            };
            req.onblocked = function(event) {
                console.log("Database deletion blocked.");
            };
        }
    });
}

// Clear cookies
document.cookie.split(";").forEach(function(c) {
    document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/");
});

// Clear cache
if ('caches' in window) {
    caches.keys().then(function(cacheNames) {
        cacheNames.forEach(function(cacheName) {
            caches.delete(cacheName);
        });
    });
}

// Clear local storage
localStorage.clear();

// Clear session storage
sessionStorage.clear();