Elsa SpeechAnalyzer batch recording DELETE

 avatar
Andy
javascript
a month ago
2.1 kB
2
Indexable
Never
(async () => {
    // Selector for the delete icon using the class 'elsa-icon-delete recording-item__action-icon'
    const DELETE_ICON_SELECTOR = '.elsa-icon-delete.recording-item__action-icon';
    // Selector for the confirmation button ('Yes') in the pop-up
    const CONFIRM_BUTTON_SELECTOR = '.btn.recording-popup-confirm__ok';
    const TIME_BETWEEN_DELETIONS_MS = 1000; // Adjust this delay as needed between each deletion
    const TIME_FOR_POPUP_APPEAR_MS = 500;   // Time to wait for the pop-up to appear after clicking delete

    // Helper function to wait for a given time (used for delays)
    const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));

    // Step 1: Loop until no delete icons are left
    while (true) {
        // Step 2: Refetch the list of delete icons after every deletion
        const deleteIcons = document.querySelectorAll(DELETE_ICON_SELECTOR);

        // If no more delete icons are found, stop the loop
        if (deleteIcons.length === 0) {
            console.log("No more recordings to delete. Deletion process completed.");
            break;
        }

        console.log(`Found ${deleteIcons.length} delete icons. Proceeding with the next deletion...`);

        // Step 3: Click the first available delete icon
        const deleteIcon = deleteIcons[0];
        deleteIcon.click();
        console.log('Delete icon clicked.');

        // Step 4: Wait for the confirmation pop-up to appear
        await sleep(TIME_FOR_POPUP_APPEAR_MS);

        // Step 5: Click the confirmation button ('Yes') in the pop-up
        const confirmButton = document.querySelector(CONFIRM_BUTTON_SELECTOR);
        if (confirmButton) {
            confirmButton.click();
            console.log('Confirmation button clicked.');
        } else {
            console.log('No confirmation button found.');
            break; // If the confirmation button isn't found, stop the process
        }

        // Step 6: Wait before proceeding to the next deletion to allow time for the DOM to update
        await sleep(TIME_BETWEEN_DELETIONS_MS);
    }
})();
Leave a Comment