您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a button to copy the last code block on chat.openai.com without copying the header
当前为
- // ==UserScript==
- // @name Copy Last Code Block on ChatGPT Without Header
- // @namespace http://tampermonkey.net/
- // @version 1.2
- // @description Adds a button to copy the last code block on chat.openai.com without copying the header
- // @author max5555
- // @license MIT
- // @match https://chat.openai.com/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // Create the copy button
- const copyButton = document.createElement('button');
- copyButton.textContent = 'Copy Last Code';
- copyButton.style.position = 'fixed';
- copyButton.style.bottom = '20px';
- copyButton.style.right = '20px';
- copyButton.style.zIndex = '1000';
- // Add the button to the body
- document.body.appendChild(copyButton);
- // Function to copy the last code block
- copyButton.addEventListener('click', () => {
- const codeContainers = document.querySelectorAll('pre code');
- if (codeContainers.length > 0) {
- const lastCodeContainer = codeContainers[codeContainers.length - 1];
- navigator.clipboard.writeText(lastCodeContainer.textContent).then(() => {
- alert('Code copied to clipboard!');
- }).catch(err => {
- console.error('Failed to copy text: ', err);
- });
- } else {
- alert('No code blocks found!');
- }
- });
- })();