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

  1. // ==UserScript==
  2. // @name Copy All Text and Redirect to ChatGPT (iOS)
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5
  5. // @description Adds a button to copy all text (with "Summarize:" prefix) and redirects to ChatGPT
  6. // @author YourName
  7. // @match *://*/*
  8. // @homepage https://gf.qytechs.cn/en/scripts/526062
  9. // @grant GM_setValue
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. // Create a button
  15. const button = document.createElement('button');
  16. button.textContent = '💎'; // Use an emoji or custom text
  17. button.style.position = 'fixed';
  18. button.style.bottom = '10px';
  19. button.style.left = '50%'; // Position in the middle horizontally
  20. button.style.transform = 'translateX(-50%)'; // Center the button
  21. button.style.zIndex = 10000;
  22. button.style.padding = '10px 20px';
  23. button.style.backgroundColor = 'rgba(255, 255, 255, 0)'; // Fully transparent background
  24. button.style.color = 'rgba(255, 255, 255, 0.3)'; // Semi-transparent white color
  25. button.style.border = 'none'; // No border
  26. button.style.borderRadius = '5px'; // Rounded corners
  27. button.style.cursor = 'pointer'; // Pointer cursor on hover
  28. button.style.fontSize = '18px'; // Font size
  29. button.style.opacity = '0.1'; // Added overall opacity
  30.  
  31. // Add hover effect to make it more visible when needed
  32. button.addEventListener('mouseenter', () => {
  33. button.style.opacity = '0.8';
  34. });
  35. button.addEventListener('mouseleave', () => {
  36. button.style.opacity = '0.1';
  37. });
  38.  
  39. // Add button to the page
  40. document.body.appendChild(button);
  41.  
  42. // Button click handler
  43. button.addEventListener('click', () => {
  44. // Select all text
  45. const range = document.createRange();
  46. range.selectNodeContents(document.body);
  47. const selection = window.getSelection();
  48. selection.removeAllRanges();
  49. selection.addRange(range);
  50.  
  51. // Add "Summarize:" prefix to the selected text
  52. const selectedText = selection.toString();
  53. const textWithPrefix = `Summarize: ${selectedText}`;
  54.  
  55. // Store text in GM storage
  56. GM_setValue('chatgpt_summary_text', textWithPrefix);
  57.  
  58. // Copy text with prefix to clipboard
  59. navigator.clipboard.writeText(textWithPrefix)
  60. .then(() => {
  61. // Redirect to ChatGPT
  62. window.location.href = 'https://chat.openai.com';
  63. })
  64. .catch(err => {
  65. console.error('Failed to copy text:', err);
  66. // Redirect even if clipboard copy fails
  67. window.location.href = 'https://chat.openai.com';
  68. });
  69. });
  70. })();

QingJ © 2025

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