Pure Text Copy

This script disables the automatic source insertion function when copying text.

  1. // ==UserScript==
  2. // @name Pure Text Copy
  3. // @namespace Pure Text Copy
  4. // @version 1.0.0
  5. // @description This script disables the automatic source insertion function when copying text.
  6. // @author DumbGPT
  7. // @match *://*/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. document.addEventListener('copy', function(event) {
  14. const selection = window.getSelection();
  15. if (selection && selection.toString().length > 0) {
  16. event.preventDefault();
  17. const pureText = selection.toString();
  18. event.clipboardData.setData('text/plain', pureText);
  19. }
  20. }, true);
  21. function showCopyNotification() {
  22. const notification = document.createElement('div');
  23. const container = document.createElement('div');
  24. container.style.cssText = 'display: flex; align-items: center;';
  25. const icon = document.createElement('span');
  26. icon.innerHTML = '✓';
  27. icon.style.cssText = 'display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; background-color: #4CAF50; border-radius: 50%; margin-right: 10px; font-size: 12px; color: white;';
  28. const text = document.createElement('span');
  29. text.textContent = 'Text Copied';
  30. text.style.cssText = 'font-family: "Segoe UI", Arial, sans-serif; font-weight: 500;';
  31. container.appendChild(icon);
  32. container.appendChild(text);
  33. notification.appendChild(container);
  34. notification.style.cssText = `
  35. position: fixed;
  36. bottom: 20px;
  37. right: 20px;
  38. background-color: rgba(255, 255, 255, 0.95);
  39. color: #333;
  40. padding: 12px 16px;
  41. border-radius: 8px;
  42. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  43. z-index: 9999;
  44. opacity: 0;
  45. transform: translateY(10px);
  46. transition: opacity 0.3s, transform 0.3s;
  47. `;
  48. document.body.appendChild(notification);
  49. setTimeout(() => {
  50. notification.style.opacity = '1';
  51. notification.style.transform = 'translateY(0)';
  52. }, 10);
  53. setTimeout(() => {
  54. notification.style.opacity = '0';
  55. notification.style.transform = 'translateY(10px)';
  56. setTimeout(() => {
  57. document.body.removeChild(notification);
  58. }, 300);
  59. }, 2000);
  60. }
  61. document.addEventListener('copy', () => showCopyNotification(), false);
  62. })();

QingJ © 2025

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