Force Text Copying Enhanced

Force-enable text copying across more browsers

  1. // ==UserScript==
  2. // @name Force Text Copying Enhanced
  3. // @namespace https://viayoo.com/
  4. // @version 0.2
  5. // @description Force-enable text copying across more browsers
  6. // @author You
  7. // @run-at document-end
  8. // @match https://*/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Apply user-select: text to all elements with different prefixes and standard property
  16. document.querySelectorAll("*").forEach(function(el) {
  17. el.style.webkitUserSelect = 'text'; // For WebKit browsers (Chrome, Safari) [cite: 2]
  18. el.style.mozUserSelect = 'text'; // For Firefox
  19. el.style.msUserSelect = 'text'; // For Internet Explorer/Edge (older versions)
  20. el.style.userSelect = 'text'; // Standard property
  21. });
  22.  
  23. // --- Optional: Attempt to re-enable copy/cut events ---
  24. // This part is more complex and might not work on all sites or could cause unintended side effects.
  25. // Use with caution and test thoroughly.
  26.  
  27. /*
  28. document.addEventListener('copy', enableCopy);
  29. document.addEventListener('cut', enableCopy);
  30. document.addEventListener('selectstart', enableCopy);
  31.  
  32. function enableCopy(e) {
  33. e.stopPropagation(); // Stop the event from propagating up the DOM tree
  34. // In some cases, you might need to explicitly set the clipboard data,
  35. // but stopping propagation is often enough to prevent sites from blocking the default action.
  36. }
  37. */
  38.  
  39. })();