Bind Delete Key to Delete Button in Rabbit Hole

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

Stan na 05-10-2024. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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