Bind Delete Key to Delete Button in Rabbit Hole

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

Tính đến 05-10-2024. Xem phiên bản mới nhất.

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

Bạn sẽ cần cài đặt một tiện ích mở rộng như Tampermonkey hoặc Violentmonkey để cài đặt kịch bản này.

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