为 Google Gemini 聊天中的查询气泡添加复制按钮

为查询气泡添加复制按钮,以便轻松复制文本

目前为 2025-03-29 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Add Copy Button to Query Bubbles For Google Gemini Chat
  3. // @description Adds a copy button to query bubbles for easy text copying
  4. // @name:ar إضافة زر نسخ إلى فقاعات الاستعلام في دردشة Google Gemini
  5. // @description:ar يضيف زر نسخ إلى فقاعات الاستعلام لتسهيل نسخ النص
  6. // @name:bg Добавяне на бутон за копиране към балончетата с запитвания в Google Gemini Chat
  7. // @description:bg Добавя бутон за копиране към балончетата с запитвания за лесно копиране на текст
  8. // @name:cs Přidání tlačítka kopírování do bublin dotazů pro Google Gemini Chat
  9. // @description:cs Přidává tlačítko kopírování do bublin dotazů pro snadné kopírování textu
  10. // @name:da Tilføj en kopiknap til forespørgselsbobler i Google Gemini Chat
  11. // @description:da Tilføjer en kopiknap til forespørgselsbobler for nem tekstkopiering
  12. // @name:de Kopierknopf zu Abfrageblasen für Google Gemini Chat hinzufügen
  13. // @description:de Fügt einen Kopierknopf zu Abfrageblasen hinzu, um Text einfach zu kopieren
  14. // @name:el Προσθήκη κουμπιού αντιγραφής σε φυσαλίδες ερωτημάτων για το Google Gemini Chat
  15. // @description:el Προσθέτει ένα κουμπί αντιγραφής στις φυσαλίδες ερωτημάτων για εύκολη αντιγραφή κειμένου
  16. // @name:en Add Copy Button to Query Bubbles For Google Gemini Chat
  17. // @description:en Adds a copy button to query bubbles for easy text copying
  18. // @name:eo Aldoni Kopian Butonon al Demandaj Vezikoj por Google Gemini Chat
  19. // @description:eo Aldonas kopian butonon al demandaj vezikoj por facila tekstokopiado
  20. // @name:es Añadir botón de copiar a burbujas de consulta en Google Gemini Chat
  21. // @description:es Añade un botón de copiar a las burbujas de consulta para facilitar la copia de texto
  22. // @name:fi Lisää kopiointipainike kyselykupliin Google Gemini Chatissa
  23. // @description:fi Lisää kopiointipainikkeen kyselykupliin tekstin helppoa kopiointia varten
  24. // @name:fr Ajouter un bouton de copie aux bulles de requête dans Google Gemini Chat
  25. // @description:fr Ajoute un bouton de copie aux bulles de requête pour une copie facile du texte
  26. // @name:fr-CA Ajouter un bouton de copie aux bulles de requête dans Google Gemini Chat
  27. // @description:fr-CA Ajoute un bouton de copie aux bulles de requête pour une copie facile du texte
  28. // @name:he הוסף כפתור העתקה לבועות שאילתה עבור Google Gemini Chat
  29. // @description:he מוסיף כפתור העתקה לבועות שאילתה להעתקת טקסט בקלות
  30. // @name:hr Dodaj gumb za kopiranje u mjehuriće upita za Google Gemini Chat
  31. // @description:hr Dodaje gumb za kopiranje u mjehuriće upita za jednostavno kopiranje teksta
  32. // @name:hu Másolás gomb hozzáadása a lekérdezési buborékokhoz a Google Gemini Chatban
  33. // @description:hu Másolás gombot ad a lekérdezési buborékokhoz a szöveg egyszerű másolásához
  34. // @name:id Tambah Tombol Salin ke Gelembung Kueri untuk Google Gemini Chat
  35. // @description:id Menambahkan tombol salin ke gelembung kueri untuk penyalinan teks yang mudah
  36. // @name:it Aggiungi un pulsante di copia alle bolle di query per Google Gemini Chat
  37. // @description:it Aggiunge un pulsante di copia alle bolle di query per una facile copia del testo
  38. // @name:ja Google Geminiチャットのクエリバブルにコピーボタンを追加
  39. // @description:ja クエリバブルにコピーボタンを追加して、テキストを簡単にコピーできるようにします
  40. // @name:ka დაამატეთ კოპირების ღილაკი შეკითხვის ბუშტუკებს Google Gemini Chat-ში
  41. // @description:ka ამატებს კოპირების ღილაკს შეკითხვის ბუშტუკებს ტექსტის მარტივი კოპირებისთვის
  42. // @name:ko Google Gemini 채팅의 쿼리 버블에 복사 버튼 추가
  43. // @description:ko 쿼리 버블에 복사 버튼을 추가하여 텍스트를 쉽게 복사할 수 있게 합니다
  44. // @name:nb Legg til en kopieringsknapp i spørrebobler for Google Gemini Chat
  45. // @description:nb Legger til en kopieringsknapp i spørrebobler for enkel tekstkopiering
  46. // @name:nl Voeg een kopieerknop toe aan vraagbubbels voor Google Gemini Chat
  47. // @description:nl Voegt een kopieerknop toe aan vraagbubbels voor eenvoudige tekstkopie
  48. // @name:pl Dodaj przycisk kopiowania do bąbelków zapytań w Google Gemini Chat
  49. // @description:pl Dodaje przycisk kopiowania do bąbelków zapytań dla łatwego kopiowania tekstu
  50. // @name:pt-BR Adicionar botão de cópia às bolhas de consulta no Google Gemini Chat
  51. // @description:pt-BR Adiciona um botão de cópia às bolhas de consulta para facilitar a cópia de texto
  52. // @name:ro Adaugă un buton de copiere la bulele de interogare pentru Google Gemini Chat
  53. // @description:ro Adaugă un buton de copiere la bulele de interogare pentru copierea ușoară a textului
  54. // @name:ru Добавить кнопку копирования в пузырьки запросов для Google Gemini Chat
  55. // @description:ru Добавляет кнопку копирования в пузырьки запросов для удобного копирования текста
  56. // @name:sk Pridať tlačidlo kopírovania do bublín dotazov pre Google Gemini Chat
  57. // @description:sk Pridáva tlačidlo kopírovania do bublín dotazov pre jednoduché kopírovanie textu
  58. // @name:sr Додај дугме за копирање у мехуриће упита за Google Gemini Chat
  59. // @description:sr Додаје дугме за копирање у мехуриће упита за лако копирање текста
  60. // @name:sv Lägg till en kopieringsknapp till frågebubblor i Google Gemini Chat
  61. // @description:sv Lägger till en kopieringsknapp till frågebubblor för enkel textkopiering
  62. // @name:th เพิ่มปุ่มคัดลอกไปยังฟองคำถามสำหรับ Google Gemini Chat
  63. // @description:th เพิ่มปุ่มคัดลอกไปยังฟองคำถามเพื่อการคัดลอกข้อความที่ง่ายดาย
  64. // @name:tr Google Gemini Sohbeti için Sorgu Baloncuklarına Kopyala Düğmesi Ekle
  65. // @description:tr Sorgu baloncuklarına kopyala düğmesi ekleyerek metni kolayca kopyalamayı sağlar
  66. // @name:ug Google Gemini سۆھبىتى ئۈچۈن سۈرۈشتۈرۈش پۇقراقلىرىغا كۆچۈرۈش كۇنۇپكىسى قوشۇش
  67. // @description:ug سۈرۈشتۈرۈش پۇقراقلىرىغا كۆچۈرۈش كۇنۇپكىسى قوشۇپ، تېكىستنى ئاسان كۆچۈرۈشنى ئىشقا ئاشۇرىدۇ
  68. // @name:uk Додати кнопку копіювання до бульбашок запитів у Google Gemini Chat
  69. // @description:uk Додає кнопку копіювання до бульбашок запитів для легкого копіювання тексту
  70. // @name:vi Thêm nút sao chép vào bong bóng truy vấn cho Google Gemini Chat
  71. // @description:vi Thêm nút sao chép vào bong bóng truy vấn để sao chép văn bản dễ dàng
  72. // @name:zh 为 Google Gemini 聊天中的查询气泡添加复制按钮
  73. // @description:zh 为查询气泡添加复制按钮,以便轻松复制文本
  74. // @name:zh-CN 为 Google Gemini 聊天中的查询气泡添加复制按钮
  75. // @description:zh-CN 为查询气泡添加复制按钮,以便轻松复制文本
  76. // @name:zh-HK 喺 Google Gemini 聊天嘅查詢氣泡加入複製按鈕
  77. // @description:zh-HK 為查詢氣泡加入複製按鈕,方便輕鬆複製文本
  78. // @name:zh-SG 为 Google Gemini 聊天中的查询气泡添加复制按钮
  79. // @description:zh-SG 为查询气泡添加复制按钮,以便轻松复制文本
  80. // @name:zh-TW 為 Google Gemini 聊天中的查詢氣泡新增複製按鈕
  81. // @description:zh-TW 為查詢氣泡新增複製按鈕,以便輕鬆複製文字
  82. // @namespace http://tampermonkey.net/
  83. // @version 0.1.1
  84. // @author aspen138
  85. // @match *://gemini.google.com/app/*
  86. // @grant none
  87. // @icon https://www.gstatic.com/lamda/images/gemini_home_icon_8d62f72e7aae54b6859f1.png
  88. // @license MIT
  89. // ==/UserScript==
  90.  
  91. (function() {
  92. 'use strict';
  93.  
  94. // Function to create a copy button
  95. function createCopyButton(textElement) {
  96. const button = document.createElement('button');
  97. button.textContent = 'Copy';
  98. button.style.marginLeft = '10px';
  99. button.style.padding = '2px 8px';
  100. button.style.fontSize = '12px';
  101. button.style.cursor = 'pointer';
  102.  
  103. // Add click event to copy text
  104. button.addEventListener('click', function() {
  105. const textToCopy = textElement.textContent.trim();
  106. navigator.clipboard.writeText(textToCopy)
  107. .then(() => {
  108. // Visual feedback
  109. button.textContent = 'Copied!';
  110. setTimeout(() => {
  111. button.textContent = 'Copy';
  112. }, 2000);
  113. })
  114. .catch(err => {
  115. console.error('Failed to copy text: ', err);
  116. button.textContent = 'Error';
  117. });
  118. });
  119.  
  120. return button;
  121. }
  122.  
  123. // Function to add copy buttons to all query bubbles
  124. function addCopyButtons() {
  125. const queryBubbles = document.querySelectorAll('.user-query-bubble-with-background');
  126.  
  127. queryBubbles.forEach(bubble => {
  128. // Check if button already exists to avoid duplicates
  129. if (!bubble.querySelector('.copy-button')) {
  130. const textElement = bubble.querySelector('.query-text');
  131. if (textElement) {
  132. const copyButton = createCopyButton(textElement);
  133. copyButton.classList.add('copy-button'); // Add class for tracking
  134. const container = bubble.querySelector('.horizontal-container');
  135. if (container) {
  136. container.appendChild(copyButton);
  137. }
  138. }
  139. }
  140. });
  141. }
  142.  
  143. // Initial run
  144. addCopyButtons();
  145.  
  146. // Observe for dynamic content changes
  147. const observer = new MutationObserver(function(mutations) {
  148. mutations.forEach(function(mutation) {
  149. if (mutation.addedNodes.length) {
  150. addCopyButtons();
  151. }
  152. });
  153. });
  154.  
  155. // Start observing the document body for changes
  156. observer.observe(document.body, {
  157. childList: true,
  158. subtree: true
  159. });
  160.  
  161. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址