Google Books Allow copy

-

  1. // ==UserScript==
  2. // @name:ko 구글북스 복사 활성화
  3. // @name Google Books Allow copy
  4. // @namespace https://ndaesik.tistory.com/
  5. // @version 1
  6. // @description:ko -
  7. // @description -
  8. // @match *://play.google.com/books/*
  9. // @match *://books.googleusercontent.com/books/reader/frame*
  10. // @icon https://www.gstatic.com/images/branding/product/2x/play_books_96dp.png
  11. // @grant GM_setClipboard
  12. // @run-at document-idle
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. const isIframe = window.location.href.includes('books.googleusercontent.com/books/reader/frame');
  17.  
  18. if (isIframe) {
  19. const style = document.createElement('style');
  20. style.textContent = `* {user-select: text !important} .overlay, .selection-overlay, .page-overlay {display: none !important}`;
  21. document.head.appendChild(style);
  22.  
  23. document.addEventListener('copy', e => e.stopPropagation(), true);
  24. document.addEventListener('keydown', e => {
  25. if ((e.ctrlKey || e.metaKey) && e.key === 'c') {
  26. e.preventDefault();
  27. const text = window.getSelection().toString().trim();
  28. if (text) window.parent.postMessage({ type: 'COPY_TEXT', text }, '*');
  29. }
  30. }, true);
  31. } else {
  32. window.addEventListener('message', e => {
  33. if (e.data?.type === 'COPY_TEXT' && e.data.text) {
  34. GM_setClipboard(e.data.text);
  35. }
  36. });
  37. }
  38. })();