Adds a button to copy all text (with "Summarize:" prefix) and redirects to ChatGPT
// ==UserScript==
// @name Copy All Text and Redirect to ChatGPT (iOS)
// @namespace http://tampermonkey.net/
// @version 2.0
// @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.top = '20px';
button.style.left = '70px';
button.style.transform = 'translateX(-50%)'; // Center the button
button.style.zIndex = 10000;
button.style.padding = '0px 0px';
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.8'; // 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);
});
});
})();