clear

Clears local storage and indexedDB data

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         clear
// @version      1.1
// @description  Clears local storage and indexedDB data
// @match        https://www.genschat.com/*
// @match       https://www.characterwaifu.com/*
// @grant        none
// @license MIT
// @namespace Violentmonkey Scripts
// ==/UserScript==

(function() {
    'use strict';

    // Specify the name of the IndexedDB database you want to clear
    const databaseName = 'localforage';


 // Specify the time interval between clearing each object store, in milliseconds
       const loopDelay = 20;

    // Open the IndexedDB database
    const request = indexedDB.open(databaseName);

    // Event handler for successful database opening
    request.onsuccess = function(event) {
        const db = event.target.result;

        // Get a list of object store names in the database
        const objectStoreNames = Array.from(db.objectStoreNames);

        // Define a function to clear the next object store
        const clearNextObjectStore = function() {
            if (objectStoreNames.length > 0) {
                const objectStoreName = objectStoreNames.shift();
                const transaction = db.transaction(objectStoreName, 'readwrite');
                const objectStore = transaction.objectStore(objectStoreName);
                const clearRequest = objectStore.clear();

                clearRequest.onsuccess = function() {
                    console.log(`Cleared all data in object store: ${objectStoreName}`);
                    // Call the function again after a delay
                    setTimeout(clearNextObjectStore, loopDelay);
                };

                clearRequest.onerror = function(event) {
                    console.error(`An error occurred while clearing data in object store: ${objectStoreName}`, event.target.error);
                };
            } else {
                console.log('All data in the IndexedDB database has been cleared.');
            }
        };

        // Start the loop
        clearNextObjectStore();
    };

    // Event handler for database errors
    request.onerror = function(event) {
        console.error('An error occurred while opening the IndexedDB database:', event.target.error);
    };
    localStorage.clear();
})();