Skip to content

Shortcut addition #1

@science64

Description

@science64

Hello,

Thanks a lot for the great useful chrome app. I would like to have short cut option in the code if it is possible. So far I am using tampermonkey to do it addition to your code maybe you can update your code and would be great it can work with google gemini (aistudio), perpexlity and chatgpt maybe.

Thanks.

Here is the code I am using:

// @name         Claude.ai Microphone Toggle
// @namespace    http://tampermonkey.net/
// @version      0.7
// @description  Toggle Claude.ai microphone with a keyboard shortcut (Ctrl + Alt + S)
// @author       science64
// @match        https://claude.ai/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function triggerMicrophoneButton() {
        const micButton = document.querySelector('.claudet-mic-button[id="mic-button"]');

        if (micButton) {
            micButton.click();

            // Check for activation (modify the attribute/class/style check as needed)
            if (!micButton.hasAttribute('activated')) {
                const events = ['mousedown', 'mouseup', 'click'];
                events.forEach(eventType => {
                    const event = new MouseEvent(eventType, {
                        view: window,
                        bubbles: true,
                        cancelable: true
                    });
                    micButton.dispatchEvent(event);
                });
            }
        }
    }

    function waitForElement(selector, callback) {
        const element = document.querySelector(selector);

        if (element) {
            callback(element);
        } else {
            setTimeout(() => {
                waitForElement(selector, callback);
            }, 500);
        }
    }

    window.addEventListener('keydown', function(event) {
        if (event.ctrlKey && event.altKey && event.key === 's') {
            event.preventDefault();
            waitForElement('.claudet-mic-button[id="mic-button"]', (btn) => {
                triggerMicrophoneButton();
            });
        }
    });
})();```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions