Copy All Text and Redirect to ChatGPT (iOS)

Adds a button to copy all text (with "Summarize:" prefix) and redirects to ChatGPT

目前為 2025-02-06 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Copy All Text and Redirect to ChatGPT (iOS)
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Adds a button to copy all text (with "Summarize:" prefix) and redirects to ChatGPT
// @author       YourName
// @match        *://*/*
// @grant        none
// ==/UserScript==
(function() {
    'use strict';
    // Create a button
    const button = document.createElement('button');
    button.textContent = '💎'; // Use an emoji or custom text
    button.style.position = 'fixed';
    button.style.bottom = '30px';
    button.style.left = '50%'; // Position in the middle horizontally
    button.style.transform = 'translateX(-50%)'; // Center the button
    button.style.zIndex = 10000;
    button.style.padding = '10px 20px';
    button.style.backgroundColor = 'rgba(255, 255, 255, 0)'; // Fully transparent background
    button.style.color = 'rgba(255, 255, 255, 0.3)'; // Semi-transparent white color
    button.style.border = 'none'; // No border
    button.style.borderRadius = '5px'; // Rounded corners
    button.style.cursor = 'pointer'; // Pointer cursor on hover
    button.style.fontSize = '18px'; // Font size
    button.style.opacity = '0.3'; // Added overall opacity

    // Add hover effect to make it more visible when needed
    button.addEventListener('mouseenter', () => {
        button.style.opacity = '0.8';
    });
    button.addEventListener('mouseleave', () => {
        button.style.opacity = '0.3';
    });

    // Add button to the page
    document.body.appendChild(button);

    // Button click handler
    button.addEventListener('click', () => {
        // Select all text
        const range = document.createRange();
        range.selectNodeContents(document.body);
        const selection = window.getSelection();
        selection.removeAllRanges();
        selection.addRange(range);

        // Add "Summarize:" prefix to the selected text
        const selectedText = selection.toString();
        const textWithPrefix = `Summarize: ${selectedText}`;

        // Copy text with prefix to clipboard
        navigator.clipboard.writeText(textWithPrefix)
            .then(() => {
                // Redirect to ChatGPT
                window.location.href = 'https://chat.openai.com';
            })
            .catch(err => {
                console.error('Failed to copy text:', err);
            });
    });
})();

QingJ © 2025

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