구글북스 복사 활성화

-

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name:ko         구글북스 복사 활성화
// @name            Google Books Allow copy
// @namespace       https://ndaesik.tistory.com/
// @version         1
// @description:ko  -
// @description     -
// @match           *://play.google.com/books/*
// @match           *://books.googleusercontent.com/books/reader/frame*
// @icon            https://www.gstatic.com/images/branding/product/2x/play_books_96dp.png
// @grant           GM_setClipboard
// @run-at          document-idle
// ==/UserScript==

(function() {
    const isIframe = window.location.href.includes('books.googleusercontent.com/books/reader/frame');

    if (isIframe) {
        const style = document.createElement('style');
        style.textContent = `* {user-select: text !important} .overlay, .selection-overlay, .page-overlay {display: none !important}`;
        document.head.appendChild(style);

        document.addEventListener('copy', e => e.stopPropagation(), true);
        document.addEventListener('keydown', e => {
            if ((e.ctrlKey || e.metaKey) && e.key === 'c') {
                e.preventDefault();
                const text = window.getSelection().toString().trim();
                if (text) window.parent.postMessage({ type: 'COPY_TEXT', text }, '*');
            }
        }, true);
    } else {
        window.addEventListener('message', e => {
            if (e.data?.type === 'COPY_TEXT' && e.data.text) {
                GM_setClipboard(e.data.text);
            }
        });
    }
})();