Bind Delete Key to Delete Button in Rabbit Hole

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

Verze ze dne 05. 10. 2024. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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
        }
    });
})();