Bind Delete Key to Delete Button in Rabbit Hole

Binds the Delete key to trigger SVG trash button click in rabbit hole

Από την 05/10/2024. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Bind Delete Key to Delete Button in Rabbit Hole
// @namespace    http://tampermonkey.net/
// @license      GNU GPLv3
// @version      1.0
// @description  Binds the Delete key to trigger SVG trash button click in rabbit hole
// @author       You
// @match        *://hole.rabbit.tech/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to trigger a click on the second SVG button
    function triggerDeleteAction() {
        try {
            // Select the div containing the buttons
            const container = document.querySelector('div.ml\\:flex.hidden.items-center.space-x-2');
            if (container) {
                // Select all SVG buttons within the container
                const svgButtons = container.querySelectorAll('svg');
                if (svgButtons.length > 1) {
                    // Click the second button
                    svgButtons[1].dispatchEvent(new MouseEvent('click', { bubbles: true }));
                } else {
                    console.error('Second SVG button not found');
                }
            } else {
                console.error('Container not found');
            }
        } catch (error) {
            console.error('Error triggering delete action:', error);
        }
    }

    // Add event listener for keydown events
    document.addEventListener('keydown', function(event) {
        if (event.key === 'Delete') {
            triggerDeleteAction();
            event.preventDefault(); // Prevent default behavior if necessary
        }
    });
})();