OpenAI Chat Copy Code Hotkey

Binds the "Alt+C" hotkey to find and click the HTML element with the text "Copy code" on chat.openai.com.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name             OpenAI Chat Copy Code Hotkey
// @namespace        https://userscript.snomiao.com/
// @version          0.0.1
// @description      Binds the "Alt+C" hotkey to find and click the HTML element with the text "Copy code" on chat.openai.com.
// @author           [email protected]
// @match            https://chat.openai.com/*
// @grant            none
// @license          GPL-3.0+
// @contributionURL  https://snomiao.com/donate
// @supportURL       https://github.com/snomiao/userscript.js/issues
// @copyright        2017 - 2023, @snomiao <snomiao.com>
// ==/UserScript==

(function () {
  "use strict";

  document.addEventListener("keydown", function (event) {
    // Check if the pressed key is 'C' and the 'Alt' key is held down
    if (event.key === "c" && event.altKey) {
      // Prevent default action (if any)
      event.preventDefault();

      // Find the HTML element with the text "Copy code"
      const elements = [...document.getElementsByTagName("*")].reverse();
      for (let i = 0; i < elements.length; i++) {
        const element = elements[i];
        if (element.textContent === "Copy code") {
          // Simulate a click event on the element
          element.click();
          break;
        }
      }
    }
  });
})();