您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a copy button to query bubbles for easy text copying
当前为
// ==UserScript== // @name Add Copy Button to Query Bubbles For Google Gemini Chat // @namespace http://tampermonkey.net/ // @version 0.1 // @description Adds a copy button to query bubbles for easy text copying // @author aspen138 // @match *://gemini.google.com/app/* // @grant none // @icon https://www.gstatic.com/lamda/images/gemini_home_icon_8d62f72e7aae54b6859f1.png // @license MIT // ==/UserScript== (function() { 'use strict'; // Function to create a copy button function createCopyButton(textElement) { const button = document.createElement('button'); button.textContent = 'Copy'; button.style.marginLeft = '10px'; button.style.padding = '2px 8px'; button.style.fontSize = '12px'; button.style.cursor = 'pointer'; // Add click event to copy text button.addEventListener('click', function() { const textToCopy = textElement.textContent.trim(); navigator.clipboard.writeText(textToCopy) .then(() => { // Visual feedback button.textContent = 'Copied!'; setTimeout(() => { button.textContent = 'Copy'; }, 2000); }) .catch(err => { console.error('Failed to copy text: ', err); button.textContent = 'Error'; }); }); return button; } // Function to add copy buttons to all query bubbles function addCopyButtons() { const queryBubbles = document.querySelectorAll('.user-query-bubble-with-background'); queryBubbles.forEach(bubble => { // Check if button already exists to avoid duplicates if (!bubble.querySelector('.copy-button')) { const textElement = bubble.querySelector('.query-text'); if (textElement) { const copyButton = createCopyButton(textElement); copyButton.classList.add('copy-button'); // Add class for tracking const container = bubble.querySelector('.horizontal-container'); if (container) { container.appendChild(copyButton); } } } }); } // Initial run addCopyButtons(); // Observe for dynamic content changes const observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.addedNodes.length) { addCopyButtons(); } }); }); // Start observing the document body for changes observer.observe(document.body, { childList: true, subtree: true }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址