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.4
  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 none
  10. // ==/UserScript==
  11. (function() {
  12. 'use strict';
  13. // Create a button
  14. const button = document.createElement('button');
  15. button.textContent = '💎'; // Use an emoji or custom text
  16. button.style.position = 'fixed';
  17. button.style.bottom = '10px';
  18. button.style.left = '50%'; // Position in the middle horizontally
  19. button.style.transform = 'translateX(-50%)'; // Center the button
  20. button.style.zIndex = 10000;
  21. button.style.padding = '10px 20px';
  22. button.style.backgroundColor = 'rgba(255, 255, 255, 0)'; // Fully transparent background
  23. button.style.color = 'rgba(255, 255, 255, 0.3)'; // Semi-transparent white color
  24. button.style.border = 'none'; // No border
  25. button.style.borderRadius = '5px'; // Rounded corners
  26. button.style.cursor = 'pointer'; // Pointer cursor on hover
  27. button.style.fontSize = '18px'; // Font size
  28. button.style.opacity = '0.1'; // Added overall opacity
  29.  
  30. // Add hover effect to make it more visible when needed
  31. button.addEventListener('mouseenter', () => {
  32. button.style.opacity = '0.8';
  33. });
  34. button.addEventListener('mouseleave', () => {
  35. button.style.opacity = '0.1';
  36. });
  37.  
  38. // Add button to the page
  39. document.body.appendChild(button);
  40.  
  41. // Button click handler
  42. button.addEventListener('click', () => {
  43. // Select all text
  44. const range = document.createRange();
  45. range.selectNodeContents(document.body);
  46. const selection = window.getSelection();
  47. selection.removeAllRanges();
  48. selection.addRange(range);
  49.  
  50. // Add "Summarize:" prefix to the selected text
  51. const selectedText = selection.toString();
  52. const textWithPrefix = `Summarize: ${selectedText}`;
  53.  
  54. // Copy text with prefix to clipboard
  55. navigator.clipboard.writeText(textWithPrefix)
  56. .then(() => {
  57. // Redirect to ChatGPT
  58. window.location.href = 'https://chat.openai.com';
  59. })
  60. .catch(err => {
  61. console.error('Failed to copy text:', err);
  62. });
  63. });
  64. })();

QingJ © 2025

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