Удаление комментариев на YouTube (расширенный)

Удобное удаление своих комментариев на YouTube, на странице истории https://www.youtube.com/feed/history/comment_history

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

// ==UserScript==
// @name            YouTube Comments Delete Advanced
// @name:ru         Удаление комментариев на YouTube (расширенный)
// @name:de         Erweitertes Löschen von YouTube-Kommentaren
// @name:uk         Розширене видалення коментарів на YouTube
// @name:zh         YouTube评论删除高级
// @name:ja         YouTubeコメント削除の高度な機能
// @name:nl         Geavanceerd verwijderen van YouTube-reacties
// @name:pt         Exclusão Avançada de Comentários do YouTube
// @name:es         Eliminación Avanzada de Comentarios de YouTube
// @name:it         Eliminazione Avanzata dei Commenti su YouTube
// @name:ar         حذف تعليقات YouTube المتقدمة
// @name:fr         Suppression avancée des commentaires YouTube
// @name:pl         Zaawansowane usuwanie komentarzy na YouTube
// @name:az         YouTube Şərhlərinin Ətraflı Silinməsi
// @name:kz         YouTube Пікірлерінің Кеңейтілген Жою
// @name:hy         YouTube-ի Դիտորդների Գրանցված Պատկերասրահները
// @name:af         YouTube Kommentaarverwydering Gevorderd
// @name:ab         YouTube-ре Комментариев Ирытхьит Къаьнапре
// @name:bn         ইউটিউব মন্তব্য মুছে দেওয়ার উন্নত বিষয়বস্তু
// @name:bs         Napredno brisanje komentara na YouTube-u
// @name:ka         YouTube-ის კომენტარების გაუქმების გაფართოება
// @name:da         Avanceret sletning af kommentarer på YouTube
// @name:he         מחיקת תגובות מתקדמת ביוטיוב
// @name:yi         אויפפירן קאָמענטאַרן אויף יוטוב אַדוואַנסירט
// @name:id         Penghapusan Komentar YouTube yang Lanjutan
// @name:is         Áframhaldandi Eyðing á Athugasemdum á YouTube
// @name:kk         YouTube Пікірлерінің Қиындылығы
// @name:ky         YouTube Комментарийлерди Өчүрүүнүн кеңири
// @name:km         ការលុបមតិយោបល់នៅលើ YouTube ដោយកម្រិតខ្ពស់
// @name:et         Edasijõudnud YouTube'i kommentaaride kustutamine
// @name:lv         YouTube Komentāru Papildināts Dzēšana
// @name:lt         Pažangus „YouTube“ komentarų trynimas
// @name:ce         YouTube-до Шхаштунаьхнах комментариев яцагийн
// @name:hi         YouTube पर टिप्पणियों का उन्नत रूप से हटाना
// @name:tk         YouTube-da maglumatlaryň gowjaňlaýyn
// @name:tr         YouTube Yorumlarınızın Gelişmiş Silinmesi
// @name:uz         YouTube Sharhlaringizni Gelişgan o'chirish
// @name:fa         حذف پیشرفته نظرات یوتیوب
// @name:el         Προηγμένη διαγραφή σχολίων στο YouTube
// @name:be         Расшыранае выдаленне каментароў на YouTube
// @description     Convenient deletion of your comments on YouTube, on the comment history page https://www.youtube.com/feed/history/comment_history
// @description:ru  Удобное удаление своих комментариев на YouTube, на странице истории https://www.youtube.com/feed/history/comment_history
// @description:de  Bequemes Löschen Ihrer Kommentare auf YouTube auf der Kommentarverlauf-Seite https://www.youtube.com/feed/history/comment_history
// @description:uk  Зручне видалення ваших коментарів на YouTube, на сторінці історії коментарів https://www.youtube.com/feed/history/comment_history
// @description:zh  在YouTube上方便删除您的评论,位于评论历史页面 https://www.youtube.com/feed/history/comment_history
// @description:ja  YouTubeのコメント履歴ページhttps://www.youtube.com/feed/history/comment_historyで自分のコメントを便利に削除する
// @description:nl  Handig verwijderen van uw opmerkingen op YouTube, op de pagina met commentaargeschiedenis https://www.youtube.com/feed/history/comment_history
// @description:pt  Exclusão conveniente dos seus comentários no YouTube, na página de histórico de comentários https://www.youtube.com/feed/history/comment_history
// @description:es  Eliminación conveniente de sus comentarios en YouTube, en la página de historial de comentarios https://www.youtube.com/feed/history/comment_history
// @description:it  Comoda eliminazione dei tuoi commenti su YouTube, nella pagina della cronologia dei commenti https://www.youtube.com/feed/history/comment_history
// @description:ar  حذف مريح لتعليقاتك على YouTube، على صفحة تاريخ التعليقات https://www.youtube.com/feed/history/comment_history
// @description:fr  Suppression pratique de vos commentaires sur YouTube, sur la page d'historique des commentaires https://www.youtube.com/feed/history/comment_history
// @description:pl  Wygodne usuwanie swoich komentarzy na YouTube, na stronie historii komentarzy https://www.youtube.com/feed/history/comment_history
// @description:az  YouTube-da öz şərhlərinizin rahat silinməsi, şərhlərin tarix səhifəsində https://www.youtube.com/feed/history/comment_history
// @description:kz  YouTube-дағы комментарилеріңіздің оңтай өшіруі, комментарий тарихы бетінде https://www.youtube.com/feed/history/comment_history
// @description:hy  Ձեր մերժումների հեշտ ջնջումը YouTube- ում, մեկնաբանության պատմության էջում https://www.youtube.com/feed/history/comment_history
// @description:af  Gerieflike verwydering van jou kommentaar op YouTube, op die kommentaar geskiedenis bladsy https://www.youtube.com/feed/history/comment_history
// @description:ab  ГӀавзендагаш вашхӀа комментариеваш на YouTube, на страницан лхарьваруш https://www.youtube.com/feed/history/comment_history
// @description:bn  ইউটিউবে আপনার মন্তব্যগুলি সুবিধাজনকভাবে মুছে ফেলা, মন্তব্যের ইতিহাস পৃষ্ঠায় https://www.youtube.com/feed/history/comment_history
// @description:bs  Prikladno brisanje vaših komentara na YouTubeu, na stranici povijesti komentara https://www.youtube.com/feed/history/comment_history
// @description:ka  თქვენი კომენტარების წაშლა YouTube- ზე, კომენტარების ისტორიის გვერდზე https://www.youtube.com/feed/history/comment_history
// @description:da  Bequemes Löschen Ihrer Kommentare auf YouTube auf der Kommentarverlauf-Seite https://www.youtube.com/feed/history/comment_history
// @description:he  מחיקה נוחה של ההערות שלך ב- YouTube, בדף ההיסטוריית ההערות https://www.youtube.com/feed/history/comment_history
// @description:yi  געמיטלעך פון דיין קאָמענטאַרן אויפן יוטוב, אויף די קאָמענט ארכיו זײַט https://www.youtube.com/feed/history/comment_history
// @description:id  Penghapusan komentar YouTube Anda yang nyaman, di halaman riwayat komentar https://www.youtube.com/feed/history/comment_history
// @description:is  Þægilegt eyða athugasemdum þínum á YouTube, á athugasemdarsögu síðunni https://www.youtube.com/feed/history/comment_history
// @description:kk  YouTube-дегі пікірлеріңіздің ыңғай жоюы, пікірлер тарихы бетінде https://www.youtube.com/feed/history/comment_history
// @description:ky  YouTube-дагы комментарийлериңизди колдонмонун тарыхы бетиндеги ыңғайтуу өчүргүлөрү https://www.youtube.com/feed/history/comment_history
// @description:km  ការលុបស្ថានភាពរបស់លោកអ្នកនៅលើយូធូប YouTube, នៅលើទំព័រប្រវត្តិសាស្ត្រនៃយូធូប https://www.youtube.com/feed/history/comment_history
// @description:et  Teie kommentaaride mugav kustutamine YouTube'is, kommentaaride ajaloo lehel https://www.youtube.com/feed/history/comment_history
// @description:lv  Jūsu komentāru ērta dzēšana YouTube, komentāru vēstures lapā https://www.youtube.com/feed/history/comment_history
// @description:lt  Patogus jūsų komentarų šalinimas „YouTube“, komentarų istorijos puslapyje https://www.youtube.com/feed/history/comment_history
// @description:ce  YouTube-са бакъыт вац сацарыгӀ комментариев хьа егатарш, комментариев тариххаш https://www.youtube.com/feed/history/comment_history
// @description:hi  यूट्यूब पर अपने टिप्पणियों को सुविधाजनक रूप से हटाना, टिप्पणी इतिहास पृष्ठ पर https://www.youtube.com/feed/history/comment_history
// @description:tk  YouTube-da öz diňe kommentlerinizi gowjaňlaýyn, kommentler tarapyndan geçirýän sahypa https://www.youtube.com/feed/history/comment_history
// @description:tr  YouTube'daki yorumlarınızı rahatça silme, yorum geçmişi sayfasında https://www.youtube.com/feed/history/comment_history
// @description:uz  Sizning fikrlaringizni YouTube-da qulay o'chirish, fikrlar tarixi sahifasida https://www.youtube.com/feed/history/comment_history
// @description:fa  حذف راحت نظرات شما در YouTube، در صفحه تاریخچه نظرات https://www.youtube.com/feed/history/comment_history
// @description:el  Εύκολη διαγραφή των σχολίων σας στο YouTube, στη σελίδα ιστορικού σχολίων https://www.youtube.com/feed/history/comment_history
// @description:be  Зручнае выдаленне вашых каментараў на YouTube, на старонцы гісторыі каментароў https://www.youtube.com/feed/history/comment_history
// @namespace       https://greatest.deepsurf.us/users/1221433
// @icon            https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @version         1.20
// @author          Sitego
// @match           *://myactivity.google.com/*
// @include         *://www.youtube.com/feed/history/*
// @grant           GM_getResourceText
// @license         MIT
// @category YouTube
// ==/UserScript==

(function () {
    'use strict';
    function addButtons() {
        var deleteButtons = document.querySelectorAll('div[class^="VfPpkd-Bz112c-"]');
        deleteButtons.forEach(function (button) {
            if (!button.closest('[aria-haspopup="menu"]')) {
                if (!button.parentNode.querySelector('.comment-checkbox')) {
                    var checkbox = document.createElement('input');
                    checkbox.type = 'checkbox';
                    checkbox.className = 'comment-checkbox';
                    button.parentNode.insertBefore(checkbox, button);
                    checkbox.addEventListener('change', function () {
                        updateDeleteButtonState();
                    });
                    checkbox.addEventListener('mouseover', function (event) {
                        handleCheckboxMouseover(event, checkbox);
                    });
                }
            }
        });
        if (!document.querySelector('.delete-all-button')) {
            var deleteAllButton = document.createElement('button');
            deleteAllButton.textContent = 'Delete Selected Comments';
            deleteAllButton.className = 'delete-all-button';
            deleteAllButton.disabled = true;
            deleteAllButton.addEventListener('click', function () {
                deleteSelectedComments();
            });
            if (deleteButtons.length > 0) {
                deleteButtons[0].parentNode.parentNode.insertBefore(deleteAllButton, deleteButtons[0].parentNode);
            }
        }
        if (!document.querySelector('.select-all-button')) {
            var selectAllButton = document.createElement('button');
            selectAllButton.textContent = 'Select All';
            selectAllButton.className = 'select-all-button';
            selectAllButton.addEventListener('click', function () {
                selectAllCheckboxes();
            });
            if (deleteButtons.length > 0) {
                deleteButtons[0].parentNode.parentNode.insertBefore(selectAllButton, deleteButtons[0].parentNode);
            }
        }
        if (!document.querySelector('.clear-all-button')) {
            var clearAllButton = document.createElement('button');
            clearAllButton.textContent = 'Clear All';
            clearAllButton.className = 'clear-all-button';
            clearAllButton.addEventListener('click', function () {
                clearAllCheckboxes();
            });
            if (deleteButtons.length > 0) {
                deleteButtons[0].parentNode.parentNode.insertBefore(clearAllButton, deleteButtons[0].parentNode);
            }
        }
    }
    function updateDeleteButtonState() {
        var deleteAllButton = document.querySelector('.delete-all-button');
        var checkboxes = document.querySelectorAll('.comment-checkbox');
        var anyChecked = Array.from(checkboxes).some(function (checkbox) {
            return checkbox.checked;
        });
        if (deleteAllButton) {
            if (anyChecked) {
                deleteAllButton.removeAttribute('disabled');
            } else {
                deleteAllButton.setAttribute('disabled', 'disabled');
            }
        }
    }
    function deleteSelectedComments() {
        var checkboxes = document.querySelectorAll('.comment-checkbox');
        checkboxes.forEach(function (checkbox) {
            if (checkbox.checked) {
                var deleteButton = checkbox.nextElementSibling;
                deleteButton.click();
            }
        });
    }
    function selectAllCheckboxes() {
        var checkboxes = document.querySelectorAll('.comment-checkbox');
        checkboxes.forEach(function (checkbox) {
            checkbox.checked = true;
        });
        updateDeleteButtonState();
    }
    function clearAllCheckboxes() {
        var checkboxes = document.querySelectorAll('.comment-checkbox');
        checkboxes.forEach(function (checkbox) {
            checkbox.checked = false;
        });
        updateDeleteButtonState();
    }
    function handleCheckboxMouseover(event, currentCheckbox) {
        if (currentCheckbox.checked) {
            currentCheckbox.checked = false;
        } else {
            currentCheckbox.checked = true;
        }
    }
    window.addEventListener('load', function () {
        addButtons();
    });
    document.addEventListener('DOMSubtreeModified', function () {
        updateDeleteButtonState();
        addButtons();
    });
    var buttonStyles = document.createElement('style');
    buttonStyles.textContent = `
        .delete-all-button, .select-all-button, .clear-all-button {
            position: fixed;
            top: 50%;
            right: 20px;
            transform: translateY(-50%);
            background-color: red;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            z-index: 9999;
            margin-bottom: 10px;
   font-weight: bold;
        }
  .delete-all-button:hover, .select-all-button:hover, .clear-all-button:hover {
   background-color: #777;
  }
        .select-all-button {
            top: 40%;
            background-color: #1988FF;
   font-weight: bold;
        }
        .clear-all-button {
            top: 60%;
            background-color: #1DA044;
   font-weight: bold;
        }
    `;
    document.head.appendChild(buttonStyles);
    var checkboxStyles = document.createElement('style');
    checkboxStyles.textContent = `
    .comment-checkbox {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        width: 24px;
        height: 24px;
        border: 3px solid #ccc;
        border-radius: 5px;
        cursor: pointer;
        float: right;
        margin-right: -4em;
    }

    .comment-checkbox:checked {
        background-color: #007bff;
        border-color: #007bff;
    }

    .comment-checkbox:checked::after {
        content: '\\2713';
        font-size: 18px;
        color: white;
        margin-left: 4px;
    }
    .comment-checkbox:hover {
        background-color: #007bff;
    }
`;
    document.head.appendChild(checkboxStyles);
})();