Gemini Eraser

Tự động xóa tất cả các cuộc trò chuyện trong Gemini

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name                Gemini Eraser
// @name:pt-BR          Gemini Eraser
// @name:zh-CN          Gemini Eraser
// @name:zh-TW          Gemini Eraser
// @name:fr-CA          Gemini Eraser
// @name:ckb            Gemini Eraser
// @name:ar             Gemini Eraser
// @name:be             Gemini Eraser
// @name:bg             Gemini Eraser
// @name:cs             Gemini Eraser
// @name:da             Gemini Eraser
// @name:de             Gemini Eraser
// @name:el             Gemini Eraser
// @name:en             Gemini Eraser
// @name:eo             Gemini Eraser
// @name:es             Gemini Eraser
// @name:fi             Gemini Eraser
// @name:fr             Gemini Eraser
// @name:he             Gemini Eraser
// @name:hr             Gemini Eraser
// @name:hu             Gemini Eraser
// @name:id             Gemini Eraser
// @name:it             Gemini Eraser
// @name:ja             Gemini Eraser
// @name:ka             Gemini Eraser
// @name:ko             Gemini Eraser
// @name:mr             Gemini Eraser
// @name:nb             Gemini Eraser
// @name:nl             Gemini Eraser
// @name:pl             Gemini Eraser
// @name:ro             Gemini Eraser
// @name:ru             Gemini Eraser
// @name:sk             Gemini Eraser
// @name:sr             Gemini Eraser
// @name:sv             Gemini Eraser
// @name:th             Gemini Eraser
// @name:tr             Gemini Eraser
// @name:uk             Gemini Eraser
// @name:ug             Gemini Eraser
// @name:vi             Gemini Eraser
// @namespace           http://github.com/0H4S
// @version             1.0
// @description         Automatically deletes all conversations in Gemini
// @description:pt-BR   Exclui automaticamente todas as conversas no Gemini
// @description:zh-CN   自动删除 Gemini 中的所有 o 对话
// @description:zh-TW   自動刪除 Gemini 中的所有對話
// @description:fr-CA   Supprime automatiquement toutes les conversations dans Gemini
// @description:ckb     بە شێوەیەکی ئۆتۆماتیکی هەموو گفتوگۆکان لە Gemini دەسڕێتەوە
// @description:ar      يحذف جميع المحادثات في Gemini تلقائيًا
// @description:be      Аўтаматычна выдаляе ўсе размовы ў Gemini
// @description:bg      Автоматично изтрива всички разговори в Gemini
// @description:cs      Automaticky smaže všechny konverzace v Gemini
// @description:da      Sletter automatisk alle samtaler i Gemini
// @description:de      Löscht automatisch alle Gespräche in Gemini
// @description:el      Διαγράφει αυτόματα όλες τις συνομιλίες στο Gemini
// @description:en      Automatically deletes all conversations in Gemini
// @description:eo      Aŭtomate viŝas ĉiujn konversaciojn en Gemini
// @description:es      Elimina automáticamente todas las conversaciones en Gemini
// @description:fi      Poistaa automaattisesti kaikki keskustelut Geminissä
// @description:fr      Supprime automatiquement toutes les conversations dans Gemini
// @description:he      מחק אוטומטית את כל השיחות ב-Gemini
// @description:hr      Automatski briše sve razgovore u Gemini
// @description:hu      Automatikusan törli az összes beszélgetést a Gemini alkalmazásban
// @description:id      Menghapus semua percakapan di Gemini secara otomatis
// @description:it      Elimina automaticamente tutte le conversazioni in Gemini
// @description:ja      Gemini のすべての会話を自動的に削除します
// @description:ka      ავტომატურად შლის ყველა საუბარს Gemini-ში
// @description:ko      Gemini의 모든 대화를 자동으로 삭제합니다
// @description:mr      Gemini मधील सर्व संभाषणे स्वयंचलितपणे हटवते
// @description:nb      Sletter automatisk alle samtaler i Gemini
// @description:nl      Verwijdert automatisch alle gesprekken in Gemini
// @description:pl      Automatycznie usuwa wszystkie rozmowy w Gemini
// @description:ro      Șterge automat toate conversațiile din Gemini
// @description:ru      Автоматически удаляет все диалоги в Gemini
// @description:sk      Automaticky vymaže všetky konverzácie v Gemini
// @description:sr      Аутоматски брише све разговоре у Gemini
// @description:sv      Raderar automatiskt alla konversationer i Gemini
// @description:th      ลบการสนทนาทั้งหมดใน Gemini โดยอัตโนมัติ
// @description:tr      Gemini'deki tüm konuşmaları otomatik olarak siler
// @description:uk      Автоматично видаляє всі розмови в Gemini
// @description:ug      Gemini دىكى بارلىق پاراڭلارنى ئاپتوماتىك ئۆچۈرىدۇ
// @description:vi      Tự động xóa tất cả các cuộc trò chuyện trong Gemini
// @author              OHAS
// @license             CC-BY-NC-ND-4.0
// @copyright           2025 OHAS. All Rights Reserved.
// @icon                https://cdn-icons-png.flaticon.com/512/8623/8623746.png
// @match               https://gemini.google.com/*
// @grant               GM_registerMenuCommand
// @noframes
// @compatible          chrome
// @compatible          firefox
// @compatible          edge
// @compatible          opera
// @bgf-compatible      brave
// @bgf-colorLT         #4799ff
// @bgf-colorDT         #4799ff
// @bgf-copyright       [2025 OHAS. All Rights Reserved.](https://gist.github.com/0H4S/ae2fa82957a089576367e364cbf02438)
// @bgf-social          https://github.com/0H4S
// @contributionURL     https://linktr.ee/0H4S
// ==/UserScript==

(function() {
    'use strict';

    // --- TRADUÇÃO ---
    const translations = {
        'pt': { menu: "🗑️ Excluir Tudo", confirm: "Tem certeza que deseja apagar todas as conversas?" },
        'en': { menu: "🗑️ Delete All", confirm: "Are you sure you want to delete all conversations?" },
        'es': { menu: "🗑️ Borrar todo", confirm: "¿Estás seguro de que quieres borrar todas las conversaciones?" },
        'fr': { menu: "🗑️ Tout supprimer", confirm: "Êtes-vous sûr de vouloir supprimer toutes les conversations ?" },
        'zh': { menu: "🗑️ 全部删除", confirm: "您确定要删除所有对话吗?" },
        'ja': { menu: "🗑️ すべて削除", confirm: "すべての会話を削除してもよろしいですか?" },
        'ko': { menu: "🗑️ 모두 삭제", confirm: "모든 대화를 삭제하시겠습니까?" },
        'ru': { menu: "🗑️ Удалить все", confirm: "Вы уверены, что хотите удалить все беседы?" },
        'ar': { menu: "🗑️ حذف الكل", confirm: "هل أنت متأكد que ترغب في حذف جميع المحادثات؟" },
        'be': { menu: "🗑️ Выдаліць усё", confirm: "Вы ўпэўнены, што хочаце выдаліць усе размовы?" },
        'bg': { menu: "🗑️ Изтрий всичко", confirm: "Сигурни ли сте, че искате да изтриете всички разговори?" },
        'cs': { menu: "🗑️ Smazat vše", confirm: "Opravdu chcete smazat všechny konverzace?" },
        'da': { menu: "🗑️ Slet alt", confirm: "Er du sikker på, at du vil slette alle samtaler?" },
        'de': { menu: "🗑️ Alles löschen", confirm: "Sind Sie sicher, dass Sie alle Gespräche löschen möchten?" },
        'el': { menu: "🗑️ Διαγραφή όλων", confirm: "Είστε σίγουροι ότι θέλετε να διαγράψετε όλες τις συνομιλίες;" },
        'eo': { menu: "🗑️ Viŝi ĉion", confirm: "Ĉu vi certas, ke vi volas viŝi ĉiujn konversaciojn?" },
        'fi': { menu: "🗑️ Poista kaikki", confirm: "Oletko varma, että haluat poistaa kaikki keskustelut?" },
        'he': { menu: "🗑️ מחק הכל", confirm: "האם אתה בטוח שברצונך למחוק את כל השיחות?" },
        'hr': { menu: "🗑️ Obriši sve", confirm: "Jeste li sigurni da želite obrisati sve razgovore?" },
        'hu': { menu: "🗑️ Összes törlése", confirm: "Biztosan törölni szeretné az összes beszélgetést?" },
        'id': { menu: "🗑️ Hapus Semua", confirm: "Apakah Anda yakin ingin menghapus semua percakapan?" },
        'it': { menu: "🗑️ Elimina tutto", confirm: "Sei sicuro di voler eliminare tutte le conversazioni?" },
        'ka': { menu: "🗑️ ყველას წაშლა", confirm: "დარწმუნებული ხართ, რომ გსურთ ყველა საუბრის წაშლა?" },
        'mr': { menu: "🗑️ सर्व हटवा", confirm: "तुम्हाला खात्री आहे की तुम्ही सर्व संभाषणे हटवू इच्छिता?" },
        'nb': { menu: "🗑️ Slett alt", confirm: "Er du sikker på at du vil slette alle samtaler?" },
        'nl': { menu: "🗑️ Alles verwijderen", confirm: "Weet u zeker dat u alle gesprekken wilt verwijderen?" },
        'pl': { menu: "🗑️ Usuń wszystko", confirm: "Czy na pewno chcesz usunąć wszystkie rozmowy?" },
        'ro': { menu: "🗑️ Șterge tot", confirm: "Ești sigur că vrei să ștergi toate conversațiile?" },
        'sk': { menu: "🗑️ Vymazať vše", confirm: "Naozaj chcete vymazať všetky konverzácie?" },
        'sr': { menu: "🗑️ Обриши све", confirm: "Да ли сте сигурни да желите да обришете све разговоре?" },
        'sv': { menu: "🗑️ Radera allt", confirm: "Är du säker på att du vill radera alla konversationer?" },
        'th': { menu: "🗑️ ลบทั้งหมด", confirm: "คุณแน่ใจหรือไม่ว่าต้องการลบการสนทนาทั้งหมด?" },
        'tr': { menu: "🗑️ Hepsini Sil", confirm: "Tüm konuşmaları silmek istediğinizden emin misiniz?" },
        'ug': { menu: "🗑️ ھەممىنى ئۆچۈرۈش", confirm: "ھەقىقەتەن بارلىق پاراڭلارنى ئۆچۈرەمسىز؟" },
        'uk': { menu: "🗑️ Видалити все", confirm: "Ви впевнені, що хочете видалити всі розмови?" },
        'vi': { menu: "🗑️ Xóa tất cả", confirm: "Bạn có chắc chắn muốn xóa tất cả các cuộc hội thoại không?" },
        'ckb': { menu: "🗑️ سڕینەوەی هەموو", confirm: "دڵنیای لە سڕینەوەی هەموو گفتوگۆکان؟" }
    };

    function getText(key) {
        const userLang = navigator.language || navigator.userLanguage || 'en';
        if (translations[userLang] && translations[userLang][key]) {return translations[userLang][key];}
        const langPrefix = userLang.split('-')[0];
        if (translations[langPrefix] && translations[langPrefix][key]) {return translations[langPrefix][key];}
        return translations['en'][key];
    }

    // --- ESPEAR ELEMENTO ---
    const waitForEl = (selector, timeout = 2000) => {
        return new Promise(resolve => {
            const start = Date.now();
            const interval = setInterval(() => {
                const el = document.querySelector(selector);
                if (el || (Date.now() - start) > timeout) {
                    clearInterval(interval);
                    resolve(el);
                }
            }, 100);
        });
    };

    // --- DELETAR TODAS AS CONVERSAS ---
    async function deletarTodasConversas() {
        while (true) {
            const listContainer = document.querySelector('conversations-list[data-test-id="all-conversations"]'); if (!listContainer) break;
            const menuBtn       = listContainer.querySelector('button[data-test-id="actions-menu-button"]');      if (!menuBtn) break; menuBtn.click();
            const deleteBtn     = await waitForEl('button[data-test-id="delete-button"]');
            if (deleteBtn) {
                deleteBtn.click();
                const confirmBtn = await waitForEl('mat-dialog-actions button.mat-mdc-unelevated-button, button[data-test-id="confirm-button"]');
                if (confirmBtn) {
                    confirmBtn.click();
                    await new Promise(r => setTimeout(r, 500));
                } else { break; }
            } else { break; }
        }
    }

    // --- FUNÇÃO DE EXECUÇÃO CENTRALIZADA ---
    function runDeleteScript() {
        if (confirm(getText('confirm'))) {
            deletarTodasConversas();
        }
    }

    // --- ATALHOS DE TECLADO (ALT + DEL / ALT + BACKSPACE) ---
    document.addEventListener('keydown', function(e) {
        if (e.altKey && (e.key === 'Delete' || e.key === 'Backspace')) {
            const activeTag  = document.activeElement.tagName.toLowerCase();
            const isEditable = document.activeElement.isContentEditable;
            if (activeTag === 'input' || activeTag === 'textarea' || isEditable) {return;}
            e.preventDefault();
            runDeleteScript();
        }
    });

    // --- REGISTRAR COMANDO NO MENU ---
    GM_registerMenuCommand(getText('menu'), runDeleteScript);

})();