본문 바로가기
기타

네이버 블로그 요약해서 보기

by 앗사비 2025. 11. 10.
728x90

ai가 알려준 방법

1. 크롬에 템퍼몽키 설치 후 스크립트 추가 (맨 아래 코드)
https://chromewebstore.google.com/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo?hl=ko

 

2. 확장 프로그램에서 개발자 모드 켜기

3. 네이버 블로그 접속 > 복사하기 클릭

 

4. 퍼플렉시티에 붙여넣기 후 엔터

 

---

 

// ==UserScript==
// @name         Naver Blog 본문 복사 (iframe 내부 직접 실행, 복사방지 우회, 요청문 포함, 토스트 클릭 시 퍼플렉시티 열기, 닫기 버튼 추가)
// @namespace    http://tampermonkey.net/
// @version      3.3
// @description  네이버 블로그 본문을 복사방지 우회 후 요청문과 함께 클립보드에 복사. iframe 내부 직접 실행으로 랜덤 누락 방지. 토스트 팝업 클릭 시 퍼플렉시티 새탭 오픈 및 복사 수행. 닫기 버튼으로 수동 종료 가능.
// @author       GPT
// @match        https://blog.naver.com/*
// @match        https://blog.naver.com/PostView.naver*
// @match        https://blog.naver.com/PostView.nhn*
// @match        https://m.blog.naver.com/*
// @match        https://m.blog.naver.com/PostView.naver*
// @grant        GM_setClipboard
// ==/UserScript==

(function() {
    'use strict';

    const prefixText = `[요청]
다음 콘텐츠를 읽고 다음 항목에 대해 답변해주세요:

## 역할 (Role)
- 당신은 뛰어난 요약 전문가입니다.
- 어떤 주제든 신속하게 핵심만 남기고 명확하게 요약합니다.

## 작업 (Task)
- 사용자로부터 입력받은 텍스트를 가장 중요한 정보 위주로 간결하고 명확하게 요약하세요.

## 출력 포맷 (Format)
- 3~5문장 이내로 한눈에 들어오는 요약문을 제공합니다.
- 불필요한 내용이나 반복은 생략하세요.
- 모든 내용을 한국어로 제공해주세요.

## 지시사항 (Instructions)
- 핵심 내용에만 집중해, 빠르게 전체 맥락을 파악할 수 있도록 작성하세요.
- 요약에 숫자, 인명, 중요한 용어가 나오면 반드시 포함하세요.
- 입력된 내용에 없는 것은 추가하지 마세요.

## 기대 결과 (Expected Output)
- 짧고 명확한 요약문 제공
- 정보 누락 없이 핵심만 포함
`;

    // 본문 추출 (복사방지 해제 포함)
    function getMainContent(doc) {
        try {
            // 복사방지 스타일 해제
            doc.querySelectorAll('*').forEach(el => {
                el.style.userSelect = 'text';
                el.style.webkitUserSelect = 'text';
            });
            // 복사방지 이벤트 차단
            doc.addEventListener('copy', e => e.stopPropagation(), true);
            doc.addEventListener('selectstart', e => e.stopPropagation(), true);

            let content = doc.querySelector('.se-main-container');
            if (!content) content = doc.body;
            return content ? content.textContent.trim() : '';
        } catch (e) {
            console.error('본문 추출 실패:', e);
            return '';
        }
    }

    // 클립보드 복사 (복사 성공 시 알림 제거)
    function copyContentToClipboard(text) {
        if (typeof GM_setClipboard === 'function') {
            GM_setClipboard(text);
            // 복사 성공 시 알림 제거
        } else if (navigator.clipboard) {
            navigator.clipboard.writeText(text).then(() => {
                // 복사 성공 시 알림 제거
            }).catch(() => {
                alert('복사 실패');
            });
        } else {
            alert('복사 기능을 지원하지 않습니다.');
        }
    }

    // 토스트 팝업 (닫기 버튼 포함)
    function showToast(copyText) {
        const toast = document.createElement('div');
        toast.style.position = 'fixed';
        toast.style.top = '20px';
        toast.style.left = '50%';
        toast.style.transform = 'translateX(-50%)';
        toast.style.padding = '10px 20px';
        toast.style.backgroundColor = 'rgba(0,0,0,0.8)';
        toast.style.color = 'white';
        toast.style.fontSize = '14px';
        toast.style.borderRadius = '4px';
        toast.style.zIndex = '9999';
        toast.style.display = 'flex';
        toast.style.alignItems = 'center';
        toast.style.gap = '10px';
        toast.style.cursor = 'pointer';
        toast.style.opacity = '0';
        toast.style.transition = 'opacity 0.3s ease';

        // 텍스트
        const textSpan = document.createElement('span');
        textSpan.textContent = '복사하기';
        textSpan.style.flex = '1';
        textSpan.style.userSelect = 'none';

        // 닫기 버튼
        const closeBtn = document.createElement('button');
        closeBtn.textContent = '×';
        closeBtn.style.background = 'transparent';
        closeBtn.style.color = 'white';
        closeBtn.style.border = 'none';
        closeBtn.style.fontSize = '16px';
        closeBtn.style.cursor = 'pointer';
        closeBtn.style.userSelect = 'none';

        closeBtn.addEventListener('click', (e) => {
            e.stopPropagation();
            toast.remove();
        });

        toast.appendChild(textSpan);
        toast.appendChild(closeBtn);

        // 클릭 시 복사 실행 + 퍼플렉시티 새탭 열기
        toast.addEventListener('click', () => {
            copyContentToClipboard(copyText);
            window.open('https://www.perplexity.ai', '_blank');
            toast.remove();
        });

        document.body.appendChild(toast);

        requestAnimationFrame(() => {
            toast.style.opacity = '1';
        });
    }

    // 실행 구분
    if (location.pathname.includes('PostView')) {
        // iframe 내부 또는 모바일 포스트 페이지 → 여기서 본문 직접 추출
        const mainText = getMainContent(document);
        if (mainText) {
            const fullText = prefixText + '\n' + mainText;
            showToast(fullText);
        }
    } else {
        console.log('네이버 블로그 부모 페이지 감지됨. 본문 처리는 iframe 내부에서 실행.');
    }

})();

 

728x90