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 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Copy All Text and Redirect to ChatGPT (iOS)
// @namespace    http://tampermonkey.net/
// @version      1.6
// @description  Adds a button to copy all text (with "Summarize:" prefix) and redirects to ChatGPT
// @author       YourName
// @match        *://*/*
// @homepage     https://greasyfork.org/en/scripts/526062
// @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 = '10px';
    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.2'; // 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.2';
    });
 
    // 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);
            });
    });
})();