// ==UserScript== // @name 종합 웹 크롤러 7.8 Enhanced // @namespace http://tampermonkey.net/…
- User
// ==UserScript== // @name 종합 웹 크롤러 7.8 Enhanced // @namespace http://tampermonkey.net/ // @version 7.8 // @description 고급 기능을 갖춘 웹 크롤러로 검색 결과를 실시간으로 수집하고 표시 (무제한 페이지 지원 및 기능 개선) // @author YourName // @match ://www.google.com/search // @match ://www.bing.com/search // @match ://search.daum.net/search // @match ://search.naver.com/search // @match ://search.yahoo.com/search // @match ://duckduckgo.com/ // @match ://www.ecosia.org/search // @match ://www.startpage.com/do/search // @grant GM_xmlhttpRequest // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @grant GM_notification // @connect * // @require https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js // @require https://cdn.jsdelivr.net/npm/chart.js // @require https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.14.0/Sortable.min.js // ==/UserScript==
(function() { 'use strict';
// CSS 스타일 추가 (크롤러 창 대폭 개선 및 축소) GM_addStyle(` /* 기본 컨테이너 스타일 */ #crawler-container { position: fixed; top: 50px; right: 50px; background-color: #1e1e1e; border: 2px solid #4CAF50; padding: 15px; z-index: 10000; width: 500px; max-height: 80vh; overflow: hidden; box-shadow: 0 8px 30px rgba(0,0,0,0.5); border-radius: 10px; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: 14px; display: flex; flex-direction: column; transition: all 0.3s ease; color: #fff; } /* 헤더 스타일 */ #crawler-container header { display: flex; justify-content: space-between; align-items: center; background-color: #2d2d30; color: #fff; padding: 10px 15px; border-radius: 8px 8px 0 0; cursor: move; } #crawler-container header .title { font-size: 18px; font-weight: bold; } #crawler-container header .close-btn { font-size: 20px; cursor: pointer; transition: color 0.3s; } #crawler-container header .close-btn:hover { color: #ff4d4d; } /* 탭 스타일 */ #crawler-container .tabs { display: flex; border-bottom: 2px solid #4CAF50; margin-top: 10px; } #crawler-container .tab { flex: 1; padding: 8px; text-align: center; cursor: pointer; background-color: #2d2d30; transition: background-color 0.3s, color 0.3s; border-right: 1px solid #4CAF50; font-size: 13px; } #crawler-container .tab:last-child { border-right: none; } #crawler-container .tab.active { background-color: #4CAF50; color: #fff; font-weight: bold; border-bottom: 2px solid #fff; } /* 탭 콘텐츠 스타일 */ #crawler-container .tab-content { display: none; padding: 10px; flex-grow: 1; overflow-y: auto; background-color: #1e1e1e; } #crawler-container .tab-content.active { display: block; } /* 버튼 스타일 */ #crawler-container button { padding: 6px 10px; margin: 4px 2px; border: none; border-radius: 5px; background-color: #4CAF50; color: #fff; cursor: pointer; transition: background-color 0.3s; font-size: 13px; display: flex; align-items: center; } #crawler-container button:hover { background-color: #45a049; } #crawler-container button i { margin-right: 4px; font-size: 16px; } /* Toggle 스위치 스타일 */ .switch { position: relative; display: inline-block; width: 50px; height: 24px; margin-left: 10px; vertical-align: middle; } .switch input { opacity: 0; width: 0; height: 0; } .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 24px; } .slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; } input:checked + .slider { background-color: #4CAF50; } input:focus + .slider { box-shadow: 0 0 1px #4CAF50; } input:checked + .slider:before { transform: translateX(26px); } /* 기타 섹션 스타일 */ #crawler-container .options, #crawler-container .filters, #crawler-container .exclude-domains, #crawler-container .advanced-options, #crawler-container .site-filters, #crawler-container .controls, #crawler-container .site-filter-settings { margin-bottom: 15px; } /* 입력 필드 스타일 */ #crawler-container input[type="text"], #crawler-container textarea, #crawler-container input[type="number"], #crawler-container select { width: 100%; padding: 6px; margin-top: 4px; border: 1px solid #ccc; border-radius: 5px; font-size: 13px; background-color: #2d2d30; color: #fff; } #crawler-container input[type="text"]::placeholder, #crawler-container textarea::placeholder { color: #aaa; } /* 테이블 스타일 */ #crawler-container table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12px; background-color: #1e1e1e; } #crawler-container th, #crawler-container td { border: 1px solid #4CAF50; padding: 6px; text-align: left; vertical-align: middle; } #crawler-container th { background-color: #4CAF50; color: #fff; position: sticky; top: 0; z-index: 2; } /* 로그 섹션 스타일 */ #crawler-container .log { max-height: 120px; overflow-y: auto; background-color: #2d2d30; padding: 8px; border: 1px solid #4CAF50; border-radius: 5px; font-size: 12px; white-space: pre-wrap; } /* 진행률 표시줄과 상태 텍스트 */ #crawler-container .progress-section { display: flex; align-items: center; margin-top: 8px; } #crawler-container progress { flex: 1; height: 16px; margin-right: 8px; } #crawler-container .status { font-size: 13px; font-weight: bold; margin-top: 8px; } /* 차트 컨테이너 */ #crawler-container .chart-container { position: relative; height: 200px; margin-top: 15px; background-color: #2d2d30; padding: 8px; border-radius: 5px; } /* 미리보기 팝업 스타일 */ .preview-popup { position: absolute; top: 0; left: 0; width: 300px; height: 200px; background-color: #1e1e1e; border: 2px solid #4CAF50; box-shadow: 0 8px 30px rgba(0,0,0,0.5); z-index: 10001; display: none; border-radius: 8px; overflow: hidden; } /* iframe 스타일 */ .html-display { width: 100%; height: 300px; border: 2px solid #4CAF50; border-radius: 8px; margin-top: 15px; background-color: #fff; display: none; } /* 검색 엔진 팝업 스타일 */ .search-engine-popup { position: absolute; top: 60px; right: 20px; width: 220px; background-color: #2d2d30; border: 2px solid #4CAF50; box-shadow: 0 8px 30px rgba(0,0,0,0.5); z-index: 10002; display: none; border-radius: 8px; padding: 10px; } .search-engine-popup button { width: 100%; margin-bottom: 8px; background-color: #4CAF50; font-size: 13px; display: flex; align-items: center; justify-content: center; padding: 6px; } .search-engine-popup button:last-child { margin-bottom: 0; } /* 반응형 디자인 */ @media (max-width: 600px) { #crawler-container { width: 95%; right: 2.5%; } .preview-popup { width: 90%; height: 150px; } .html-display { height: 250px; } } `); // UI 생성 (대폭 개선된 디자인 및 창 크기 축소) const container = document.createElement('div'); container.id = 'crawler-container'; container.innerHTML = ` <header> <span class="title">🔥 웹 크롤러 7.8</span> <span class="close-btn" title="닫기">×</span> </header> <div class="tabs"> <div class="tab active" data-tab="settings">설정</div> <div class="tab" data-tab="results">결과</div> <div class="tab" data-tab="logs">로그</div> <div class="tab" data-tab="site-filters">사이트 필터</div> </div> <div class="tab-content active" id="settings"> <!-- 제어 버튼 --> <div class="controls"> <button id="startBtn" title="크롤링 시작"><i>▶️</i> 시작</button> <button id="pauseBtn" class="pause-btn" title="크롤링 일시정지/재개"><i>⏸️</i> 일시정지</button> <button id="stopBtn" title="크롤링 중지"><i>⏹️</i> 중지</button> <button id="resetBtn" title="크롤링 초기화"><i>🔄</i> 초기화</button> <button id="exportBtn" class="export-btn" title="결과 내보내기"><i>💾</i> 내보내기</button> <button id="searchEnginesBtn" class="search-engines-btn" title="검색 엔진 바로가기"><i>🔍</i> 검색 엔진</button> </div> <!-- 옵션 섹션 --> <div class="options"> <label><input type="checkbox" id="toggleHTML" checked> HTML 가져오기</label> <label><input type="checkbox" id="toggleImages" checked> 이미지 가져오기</label> <label><input type="checkbox" id="toggleAds" checked> 광고 제외</label> </div> <!-- 사이트 필터링 섹션 --> <div class="site-filter-settings"> <label>사이트 필터링 기능 <label class="switch"> <input type="checkbox" id="enableSiteFiltering" checked> <span class="slider"></span> </label> </label> </div> <!-- 필터 섹션 --> <div class="filters"> <label for="filterInput">필터 단어 (정규식, 쉼표로 구분):</label> <input type="text" id="filterInput" placeholder="예: 기부, 광고, /promo/i"> </div> <!-- 도메인 제외 섹션 --> <div class="exclude-domains"> <label for="excludeDomainsInput">제외할 도메인 (쉼표로 구분):</label> <input type="text" id="excludeDomainsInput" placeholder="예: facebook.com, youtube.com"> </div> <!-- 고급 옵션 섹션 --> <div class="advanced-options"> <label for="duplicateThreshold">중복 허용 횟수:</label> <input type="number" id="duplicateThreshold" value="2" min="1" style="width: 60px;"> <label for="retryAttempts">재시도 횟수:</label> <input type="number" id="retryAttempts" value="3" min="1" style="width: 60px;"> <label for="retryInterval">재시도 간격 (ms):</label> <input type="number" id="retryInterval" value="500" min="100" style="width: 80px;"> </div> <!-- 전체 필터링 활성화/비활성화 스위치 --> <div class="filters"> <label>전체 필터링 활성화 <label class="switch"> <input type="checkbox" id="masterFilterToggle" checked> <span class="slider"></span> </label> </label> </div> <!-- 진행률 표시 섹션 --> <div class="progress-section"> <progress id="progressBar" value="0" max="100"></progress> <span id="progressText">0%</span> </div> <!-- 상태 정보 섹션 --> <div class="status"> 현재 페이지: <span id="currentPage">0</span> <br> 방문된 사이트: <span id="visitedCount">0</span> <br> 경과 시간: <span id="elapsedTime">00:00:00</span> <br> 예상 남은 시간: <span id="remainingTime">00:00:00</span> </div> <!-- 차트 섹션 --> <div class="chart-container"> <canvas id="crawlChart"></canvas> </div> </div> <div class="tab-content" id="results"> <div style="margin-top:10px; overflow: auto;"> <table id="resultsTable"> <thead> <tr> <th>사이트 이름</th> <th>주소</th> <th>설명</th> <th>이미지</th> <th>HTML 링크</th> <th>페이지 로딩 시간 (ms)</th> </tr> </thead> <tbody id="resultsBody"> </tbody> </table> <iframe class="html-display" src=""></iframe> </div> </div> <div class="tab-content" id="logs"> <div class="log" id="log"> <strong>로그:</strong> </div> </div> <div class="tab-content" id="site-filters"> <div class="site-filters"> <label for="siteFilterInput">추가 사이트 필터링 단어 (제목 또는 내용 포함 시 제외, 정규식 지원):</label> <input type="text" id="siteFilterInput" placeholder="예: 기부, 광고, /promo/i"> </div> </div> <div class="search-engine-popup"> <button class="search-engine-btn" data-url="https://www.google.com/">Google</button> <button class="search-engine-btn" data-url="https://www.bing.com/">Bing</button> <button class="search-engine-btn" data-url="https://www.daum.net/">Daum</button> <button class="search-engine-btn" data-url="https://www.naver.com/">Naver</button> <button class="search-engine-btn" data-url="https://www.yahoo.com/">Yahoo</button> <button class="search-engine-btn" data-url="https://duckduckgo.com/">DuckDuckGo</button> <button class="search-engine-btn" data-url="https://www.ecosia.org/">Ecosia</button> <button class="search-engine-btn" data-url="https://www.startpage.com/">StartPage</button> </div> `; document.body.appendChild(container); // 드래그 가능하게 설정 (function makeDraggable(elmnt) { const header = elmnt.querySelector('header'); const closeBtn = elmnt.querySelector('.close-btn'); let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0; header.onmousedown = dragMouseDown; closeBtn.onclick = () => { elmnt.style.display = 'none'; } function dragMouseDown(e) { e = e || window.event; e.preventDefault(); pos3 = e.clientX; pos4 = e.clientY; document.onmouseup = closeDragElement; document.onmousemove = elementDrag; } function elementDrag(e) { e = e || window.event; e.preventDefault(); pos1 = pos3 - e.clientX; pos2 = pos4 - e.clientY; pos3 = e.clientX; pos4 = e.clientY; elmnt.style.top = (elmnt.offsetTop - pos2) + "px"; elmnt.style.left = (elmnt.offsetLeft - pos1) + "px"; } function closeDragElement() { document.onmouseup = null; document.onmousemove = null; } })(container); // 탭 기능 구현 (function setupTabs() { const tabs = container.querySelectorAll('.tab'); const tabContents = container.querySelectorAll('.tab-content'); tabs.forEach(tab => { tab.addEventListener('click', () => { tabs.forEach(t => t.classList.remove('active')); tab.classList.add('active'); const target = tab.getAttribute('data-tab'); tabContents.forEach(content => { if(content.id === target){ content.classList.add('active'); } else { content.classList.remove('active'); } }); }); }); })(); // 변수 초기화 let isRunning = false; let isPaused = false; let currentPage = 1; let results = []; let searchQuery = ''; let searchEngine = ''; let visitedLinks = new Map(); // 도메인별 방문 횟수 추적 let logMessages = []; let filterPatterns = []; let excludeDomains = []; let siteFilterKeywords = []; let duplicateThreshold = 2; // 중복 허용 횟수 let retryAttempts = 3; // 재시도 횟수 let retryInterval = 500; // 재시도 간격 (ms) let enableSiteFiltering = true; let masterFilterEnabled = true; // 전체 필터링 활성화 상태 let startTime = null; let elapsedInterval = null; let crawlChart = null; let crawlData = { labels: [], // 도메인 이름 datasets: [{ label: '방문 횟수', data: [], backgroundColor: 'rgba(75, 192, 192, 0.6)', borderColor: 'rgba(75, 192, 192, 1)', borderWidth: 1 }] }; // 버튼 및 요소 가져오기 const startBtn = document.getElementById('startBtn'); const pauseBtn = document.getElementById('pauseBtn'); const stopBtn = document.getElementById('stopBtn'); const resetBtn = document.getElementById('resetBtn'); const exportBtn = document.getElementById('exportBtn'); const searchEnginesBtn = document.getElementById('searchEnginesBtn'); const progressBar = document.getElementById('progressBar'); const progressText = document.getElementById('progressText'); const resultsBody = document.getElementById('resultsBody'); const logContainer = document.getElementById('log'); const currentPageElem = document.getElementById('currentPage'); const toggleHTML = document.getElementById('toggleHTML'); const toggleImages = document.getElementById('toggleImages'); const toggleAds = document.getElementById('toggleAds'); const filterInput = document.getElementById('filterInput'); const excludeDomainsInput = document.getElementById('excludeDomainsInput'); const siteFilterInput = document.getElementById('siteFilterInput'); const duplicateThresholdInput = document.getElementById('duplicateThreshold'); const retryAttemptsInput = document.getElementById('retryAttempts'); const retryIntervalInput = document.getElementById('retryInterval'); const enableSiteFilteringCheckbox = document.getElementById('enableSiteFiltering'); const masterFilterToggle = document.getElementById('masterFilterToggle'); const visitedCountElem = document.getElementById('visitedCount'); const elapsedTimeElem = document.getElementById('elapsedTime'); const remainingTimeElem = document.getElementById('remainingTime'); const crawlChartCtx = document.getElementById('crawlChart').getContext('2d'); const searchEnginePopup = container.querySelector('.search-engine-popup'); const htmlDisplayIframe = container.querySelector('.html-display'); // 이벤트 리스너 startBtn.addEventListener('click', startCrawling); pauseBtn.addEventListener('click', togglePause); stopBtn.addEventListener('click', stopCrawling); resetBtn.addEventListener('click', resetCrawling); exportBtn.addEventListener('click', exportResults); searchEnginesBtn.addEventListener('click', toggleSearchEnginesPopup); filterInput.addEventListener('input', updateFilterPatterns); excludeDomainsInput.addEventListener('input', updateExcludeDomains); siteFilterInput.addEventListener('input', updateSiteFilterPatterns); duplicateThresholdInput.addEventListener('change', updateDuplicateThreshold); retryAttemptsInput.addEventListener('change', updateRetryAttempts); retryIntervalInput.addEventListener('change', updateRetryInterval); enableSiteFilteringCheckbox.addEventListener('change', updateEnableSiteFiltering); masterFilterToggle.addEventListener('change', toggleMasterFilter); searchEnginePopup.addEventListener('click', function(event) { if (event.target.classList.contains('search-engine-btn')) { window.open(event.target.getAttribute('data-url'), '_blank'); } }); // 외부 클릭 시 검색 엔진 팝업 닫기 document.addEventListener('click', function(event) { if (!searchEnginePopup.contains(event.target) && event.target !== searchEnginesBtn) { searchEnginePopup.style.display = 'none'; } }); // 페이지 새로 고침 시 크롤링 초기화 window.addEventListener('beforeunload', () => { resetCrawling(); }); // 초기화 로드 loadLogs(); loadCrawlData(); // 차트 초기화 function initializeChart() { crawlChart = new Chart(crawlChartCtx, { type: 'bar', data: crawlData, options: { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: true } }, plugins: { legend: { display: false }, tooltip: { enabled: true } } } }); } initializeChart(); // 로깅 함수 function log(message) { const time = new Date().toLocaleTimeString(); const entry = `[${time}] ${message}`; logMessages.push(entry); logContainer.innerHTML += `${entry}<br>`; logContainer.scrollTop = logContainer.scrollHeight; // 저장 GM_setValue('crawlerLogs', JSON.stringify(logMessages)); } function loadLogs() { const storedLogs = GM_getValue('crawlerLogs', []); if (storedLogs.length > 0) { logMessages = JSON.parse(storedLogs); logContainer.innerHTML = `<strong>로그:</strong><br>` + logMessages.join('<br>'); logContainer.scrollTop = logContainer.scrollHeight; } } function updateFilterPatterns() { const input = filterInput.value.trim(); filterPatterns = masterFilterEnabled && input ? input.split(',').map(word => { word = word.trim(); if (word.startsWith('/') && word.endsWith('/')) { try { const regexBody = word.slice(1, -1); const lastSlash = regexBody.lastIndexOf('/'); if (lastSlash !== -1) { const pattern = regexBody.slice(0, lastSlash); const flags = regexBody.slice(lastSlash + 1); return new RegExp(pattern, flags); } else { return new RegExp(regexBody, 'i'); } } catch (e) { log(`⚠️ 유효하지 않은 정규식: ${word}`); return null; } } else { return new RegExp(word, 'i'); } }).filter(regex => regex !== null) : []; log(`🛠 필터 패턴 업데이트: [${filterPatterns.map(r => r.toString()).join(', ')}]`); } function updateExcludeDomains() { const input = excludeDomainsInput.value.trim(); excludeDomains = masterFilterEnabled && input ? input.split(',').map(domain => domain.trim().toLowerCase()) : []; log(`🚫 제외 도메인 업데이트: [${excludeDomains.join(', ')}]`); } function updateSiteFilterPatterns() { const input = siteFilterInput.value.trim(); siteFilterKeywords = masterFilterEnabled && input ? input.split(',').map(word => word.trim().toLowerCase()) : []; log(`🛠 사이트 필터링 키워드 업데이트: [${siteFilterKeywords.join(', ')}]`); } function updateDuplicateThreshold() { const value = parseInt(duplicateThresholdInput.value); duplicateThreshold = isNaN(value) || value < 1 ? 2 : value; log(`🔄 중복 허용 횟수 설정: ${duplicateThreshold}`); } function updateRetryAttempts() { const value = parseInt(retryAttemptsInput.value); retryAttempts = isNaN(value) || value < 1 ? 3 : value; log(`🔄 재시도 횟수 설정: ${retryAttempts}`); } function updateRetryInterval() { const value = parseInt(retryIntervalInput.value); retryInterval = isNaN(value) || value < 100 ? 500 : value; log(`🔄 재시도 간격 설정: ${retryInterval}ms`); } function updateEnableSiteFiltering() { enableSiteFiltering = enableSiteFilteringCheckbox.checked && masterFilterEnabled; log(`🔄 사이트 필터링 기능 ${enableSiteFiltering ? '활성화' : '비활성화'}됨.`); } function toggleMasterFilter() { masterFilterEnabled = masterFilterToggle.checked; if (!masterFilterEnabled) { // 모든 필터 비활성화 toggleHTML.checked = false; toggleImages.checked = false; toggleAds.checked = false; enableSiteFilteringCheckbox.checked = false; filterInput.value = ''; excludeDomainsInput.value = ''; siteFilterInput.value = ''; filterPatterns = []; excludeDomains = []; siteFilterKeywords = []; log(`🔄 전체 필터링 비활성화됨.`); } else { // 필터링 재활성화 상태 toggleHTML.checked = true; toggleImages.checked = true; toggleAds.checked = true; enableSiteFilteringCheckbox.checked = true; updateFilterPatterns(); updateExcludeDomains(); updateSiteFilterPatterns(); updateEnableSiteFiltering(); log(`🔄 전체 필터링 활성화됨.`); } } function getSearchQueryAndEngine() { const url = window.location.href; if (url.includes('google.com/search')) { const params = new URLSearchParams(window.location.search); searchQuery = params.get('q') || ''; searchEngine = 'google'; } else if (url.includes('bing.com/search')) { const params = new URLSearchParams(window.location.search); searchQuery = params.get('q') || ''; searchEngine = 'bing'; } else if (url.includes('daum.net/search')) { const params = new URLSearchParams(window.location.search); searchQuery = params.get('q') || ''; searchEngine = 'daum'; } else if (url.includes('search.naver.com/search')) { const params = new URLSearchParams(window.location.search); searchQuery = params.get('query') || ''; searchEngine = 'naver'; } else if (url.includes('search.yahoo.com/search')) { const params = new URLSearchParams(window.location.search); searchQuery = params.get('p') || ''; searchEngine = 'yahoo'; } else if (url.includes('duckduckgo.com/')) { const params = new URLSearchParams(window.location.search); searchQuery = params.get('q') || ''; searchEngine = 'duckduckgo'; } else if (url.includes('ecosia.org/search')) { const params = new URLSearchParams(window.location.search); searchQuery = params.get('q') || ''; searchEngine = 'ecosia'; } else if (url.includes('startpage.com/do/search')) { const params = new URLSearchParams(window.location.search); searchQuery = params.get('query') || ''; searchEngine = 'startpage'; } else { searchQuery = ''; searchEngine = ''; } log(`🔍 검색 엔진: ${searchEngine}, 검색어: "${searchQuery}"`); } async function startCrawling() { if (isRunning) { alert('이미 크롤링이 진행 중입니다.'); return; } getSearchQueryAndEngine(); if (!searchQuery) { alert('현재 페이지에서 검색어를 찾을 수 없습니다.'); log('⚠️ 검색어 미입력 또는 인식 실패.'); return; } isRunning = true; isPaused = false; currentPage = 1; results = []; visitedLinks.clear(); resultsBody.innerHTML = ''; visitedCountElem.innerText = '0'; elapsedTimeElem.innerText = '00:00:00'; remainingTimeElem.innerText = '00:00:00'; logMessages = []; logContainer.innerHTML = `<strong>로그:</strong><br>`; GM_setValue('crawlerLogs', JSON.stringify(logMessages)); log('✅ 크롤링을 시작합니다.'); updateDuplicateThreshold(); updateRetryAttempts(); updateRetryInterval(); updateFilterPatterns(); updateExcludeDomains(); updateSiteFilterPatterns(); updateEnableSiteFiltering(); startTime = Date.now(); elapsedInterval = setInterval(updateElapsedTime, 1000); initializeChart(); await crawlPage(); } function togglePause() { if (!isRunning) { alert('일시정지/재개할 크롤링이 없습니다.'); return; } isPaused = !isPaused; if (isPaused) { log('⏸️ 크롤링을 일시정지하였습니다.'); pauseBtn.innerHTML = '<i>▶️</i> 재개'; } else { log('▶️ 크롤링을 재개하였습니다.'); pauseBtn.innerHTML = '<i>⏸️</i> 일시정지'; crawlPage(); } } function stopCrawling() { if (!isRunning) { alert('중지할 크롤링이 없습니다.'); return; } isRunning = false; isPaused = false; pauseBtn.innerHTML = '<i>⏸️</i> 일시정지'; clearInterval(elapsedInterval); updateProgress(); log('🚫 크롤링을 중지하였습니다.'); GM_notification({ text: '크롤링이 중지되었습니다.', title: '웹 크롤러 7.8', timeout: 3000 }); } async function crawlPage() { if (!isRunning || isPaused) { return; } // 검색 엔진에 따른 URL 구성 let url = ''; if (searchEngine === 'google') { url = `https://www.google.com/search?q=${encodeURIComponent(searchQuery)}&start=${(currentPage-1)*10}`; } else if (searchEngine === 'bing') { url = `https://www.bing.com/search?q=${encodeURIComponent(searchQuery)}&first=${(currentPage-1)*10 +1}`; } else if (searchEngine === 'daum') { url = `https://search.daum.net/search?q=${encodeURIComponent(searchQuery)}&page=${currentPage}`; } else if (searchEngine === 'naver') { url = `https://search.naver.com/search.naver?query=${encodeURIComponent(searchQuery)}&start=${(currentPage-1)*10 +1}`; } else if (searchEngine === 'yahoo') { url = `https://search.yahoo.com/search?p=${encodeURIComponent(searchQuery)}&b=${(currentPage-1)*10 +1}`; } else if (searchEngine === 'duckduckgo') { url = `https://duckduckgo.com/html/?q=${encodeURIComponent(searchQuery)}&s=${(currentPage-1)*10}`; } else if (searchEngine === 'ecosia') { url = `https://www.ecosia.org/search?q=${encodeURIComponent(searchQuery)}&page=${currentPage}`; } else if (searchEngine === 'startpage') { url = `https://www.startpage.com/do/search?query=${encodeURIComponent(searchQuery)}&page=${currentPage}`; } else { alert('지원하지 않는 검색 엔진입니다.'); log('❌ 지원하지 않는 검색 엔진.'); isRunning = false; return; } log(`📄 페이지 ${currentPage} 크롤링 중: ${url}`); GM_xmlhttpRequest({ method: "GET", url: url, headers: { "User-Agent": navigator.userAgent, "Accept": "text/html" }, onload: async function(response) { if (response.status !== 200) { log(`❌ 페이지 ${currentPage} 로드 실패: 상태 ${response.status}`); await handleCrawlError(currentPage, retryAttempts); return; } const parser = new DOMParser(); const doc = parser.parseFromString(response.responseText, 'text/html'); let items = []; if (searchEngine === 'google') { items = doc.querySelectorAll('div.g'); } else if (searchEngine === 'bing') { items = doc.querySelectorAll('li.b_algo'); } else if (searchEngine === 'daum') { items = doc.querySelectorAll('div.wrap_cont'); } else if (searchEngine === 'naver') { items = doc.querySelectorAll('div.basic1'); // 네이버 최신 선택자 확인 필요 } else if (searchEngine === 'yahoo') { items = doc.querySelectorAll('div.dd.algo'); // 야후 최신 선택자 확인 필요 } else if (searchEngine === 'duckduckgo') { items = doc.querySelectorAll('div.result'); } else if (searchEngine === 'ecosia') { items = doc.querySelectorAll('div.result'); } else if (searchEngine === 'startpage') { items = doc.querySelectorAll('div.result'); // StartPage 최신 선택자 확인 필요 } // 검색 결과가 없으면 크롤링 종료 if (items.length === 0) { log('🔍 더 이상 크롤링할 페이지가 없습니다. 크롤링을 종료합니다.'); isRunning = false; isPaused = false; pauseBtn.innerHTML = '<i>⏸️</i> 일시정지'; clearInterval(elapsedInterval); updateProgress(); GM_notification({ text: '크롤링이 완료되었습니다.', title: '웹 크롤러 7.8', timeout: 3000 }); return; } log(`📊 페이지 ${currentPage}에서 ${items.length}개 항목 발견.`); // 병렬 처리: Promise.all을 이용하여 비동기적으로 처리 const itemPromises = Array.from(items).map(async (item) => { let title = 'N/A'; let link = 'N/A'; let description = 'N/A'; let image = 'N/A'; let htmlLink = 'N/A'; let pageLoadTime = 'N/A'; // 각 검색 엔진에 따른 데이터 추출 if (searchEngine === 'google') { const titleElem = item.querySelector('h3'); const linkElem = item.querySelector('a'); const descElem = item.querySelector('.IsZvec') || item.querySelector('.VwiC3b'); if (titleElem) title = titleElem.innerText; if (linkElem) link = linkElem.href; if (descElem) description = descElem.innerText; // 이미지 가져오기 (가능한 경우) const imgElem = item.querySelector('img'); if (imgElem && imgElem.src) { image = `<img src="${imgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`; } // HTML 보기 링크 if (toggleHTML.checked && link !== 'N/A') { htmlLink = `<button class="html-btn" data-url="${encodeURIComponent(link)}"><i>🔗</i> 보기</button>`; } } else if (searchEngine === 'bing') { const titleElem = item.querySelector('h2 a'); const descElem = item.querySelector('p'); if (titleElem) { title = titleElem.innerText; link = titleElem.href; } if (descElem) description = descElem.innerText; // 이미지 가져오기 (가능한 경우) const imgElem = item.querySelector('img'); if (imgElem && imgElem.src) { image = `<img src="${imgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`; } // HTML 보기 링크 if (toggleHTML.checked && link !== 'N/A') { htmlLink = `<button class="html-btn" data-url="${encodeURIComponent(link)}"><i>🔗</i> 보기</button>`; } } else if (searchEngine === 'daum') { const titleElem = item.querySelector('a.link_fax'); const descElem = item.querySelector('div.cont_inner'); if (titleElem) { title = titleElem.innerText.trim(); link = titleElem.href; } if (descElem) description = descElem.innerText.trim(); // 이미지 가져오기 (가능한 경우) const imgElem = item.querySelector('img'); if (imgElem && imgElem.src) { image = `<img src="${imgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`; } // HTML 보기 링크 if (toggleHTML.checked && link !== 'N/A') { htmlLink = `<button class="html-btn" data-url="${encodeURIComponent(link)}"><i>🔗</i> 보기</button>`; } } else if (searchEngine === 'naver') { const titleElem = item.querySelector('a.tit'); const descElem = item.querySelector('div.desc'); if (titleElem) { title = titleElem.innerText; link = titleElem.href; } if (descElem) description = descElem.innerText; // 이미지 가져오기 (가능한 경우) const imgElem = item.querySelector('img.thumb'); if (imgElem && imgElem.src) { image = `<img src="${imgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`; } // HTML 보기 링크 if (toggleHTML.checked && link !== 'N/A') { htmlLink = `<button class="html-btn" data-url="${encodeURIComponent(link)}"><i>🔗</i> 보기</button>`; } } else if (searchEngine === 'yahoo') { const titleElem = item.querySelector('h3'); const linkElem = item.querySelector('a'); const descElem = item.querySelector('div.compText'); if (titleElem) title = titleElem.innerText; if (linkElem) link = linkElem.href; if (descElem) description = descElem.innerText; // 이미지 가져오기 (가능한 경우) const imgElem = item.querySelector('img'); if (imgElem && imgElem.src) { image = `<img src="${imgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`; } // HTML 보기 링크 if (toggleHTML.checked && link !== 'N/A') { htmlLink = `<button class="html-btn" data-url="${encodeURIComponent(link)}"><i>🔗</i> 보기</button>`; } } else if (searchEngine === 'duckduckgo') { const titleElem = item.querySelector('a.result__a'); const descElem = item.querySelector('a.result__snippet'); if (titleElem) { title = titleElem.innerText; link = titleElem.href; } if (descElem) description = descElem.innerText; // 이미지 가져오기 (가능한 경우) const imgElem = item.querySelector('img.result__thumbnail'); if (imgElem && imgElem.src) { image = `<img src="${imgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`; } // HTML 보기 링크 if (toggleHTML.checked && link !== 'N/A') { htmlLink = `<button class="html-btn" data-url="${encodeURIComponent(link)}"><i>🔗</i> 보기</button>`; } } else if (searchEngine === 'ecosia') { const titleElem = item.querySelector('a.result-title'); const descElem = item.querySelector('div.result-description'); if (titleElem) { title = titleElem.innerText; link = titleElem.href; } if (descElem) description = descElem.innerText; // 이미지 가져오기 (가능한 경우) const imgElem = item.querySelector('img.result-image'); if (imgElem && imgElem.src) { image = `<img src="${imgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`; } // HTML 보기 링크 if (toggleHTML.checked && link !== 'N/A') { htmlLink = `<button class="html-btn" data-url="${encodeURIComponent(link)}"><i>🔗</i> 보기</button>`; } } else if (searchEngine === 'startpage') { const titleElem = item.querySelector('a.result-link'); const descElem = item.querySelector('div.result-description'); if (titleElem) { title = titleElem.innerText; link = titleElem.href; } if (descElem) description = descElem.innerText; // 이미지 가져오기 (가능한 경우) const imgElem = item.querySelector('img.result-image'); if (imgElem && imgElem.src) { image = `<img src="${imgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`; } // HTML 보기 링크 if (toggleHTML.checked && link !== 'N/A') { htmlLink = `<button class="html-btn" data-url="${encodeURIComponent(link)}"><i>🔗</i> 보기</button>`; } } // 마스터 필터링이 활성화된 경우에만 필터 적용 if (masterFilterEnabled) { // 광고 제외 기능 적용 if (toggleAds.checked) { const combinedText = `${title} ${description}`.toLowerCase(); const isAd = combinedText.includes('advertisement') || combinedText.includes('광고'); if (isAd) { log(`🚫 광고 항목 제외: "${title}"`); return null; } } // 필터 단어 적용 if (filterPatterns.length > 0) { const combinedText = `${title} ${description}`; const isFiltered = filterPatterns.some(regex => regex.test(combinedText)); if (isFiltered) { log(`❌ 필터 단어 포함 항목 제외: "${title}"`); return null; } } // 사이트 필터링 기능 활성화 시 추가 필터 적용 if (enableSiteFiltering && siteFilterKeywords.length > 0) { const combinedText = `${title} ${description}`.toLowerCase(); // 키워드 기반 필터링 if (siteFilterKeywords.length > 0) { const isKeywordPresent = siteFilterKeywords.some(keyword => combinedText.includes(keyword)); if (isKeywordPresent) { log(`🚫 사이트 필터 키워드 포함 항목 제외: "${title}"`); return null; } } } // 도메인 추출 const domain = extractDomain(link); if (!domain) return null; // 제외 도메인 검사 if (excludeDomains.includes(domain.toLowerCase())) { log(`🚫 제외 도메인 항목 제외: "${link}"`); return null; } // 중복 검사 (도메인별 방문 횟수) let visitCount = visitedLinks.get(domain) || 0; if (visitCount >= duplicateThreshold) { log(`🔄 중복 방문 제한: "${domain}"`); return null; } // 방문 횟수 업데이트 visitedLinks.set(domain, visitCount + 1); visitedCountElem.innerText = visitedLinks.size.toString(); // 페이지 로딩 시간 측정 const loadStart = performance.now(); try { // mode: 'cors'로 변경하여 실제 응답을 받을 수 있도록 함 const fetchResponse = await fetch(link, { mode: 'cors' }); if (fetchResponse.ok) { const loadEnd = performance.now(); pageLoadTime = Math.round(loadEnd - loadStart); } else { pageLoadTime = '응답 불량'; } } catch (err) { pageLoadTime = '계산 불가'; } // HTML 콘텐츠 필터링 if (enableSiteFiltering && siteFilterKeywords.length > 0) { try { const siteResponse = await fetch(link, { mode: 'cors' }); if (siteResponse.ok) { const siteText = await siteResponse.text(); const siteHTML = siteText.toLowerCase(); const containsKeyword = siteFilterKeywords.some(keyword => siteHTML.includes(keyword)); if (containsKeyword) { log(`🚫 HTML 콘텐츠에 필터 키워드 포함: "${title}"`); // 기존에 추가한 결과 제거 const lastResult = results[results.length - 1]; if (lastResult) { results.pop(); const lastRow = resultsBody.lastChild; if (lastRow) lastRow.remove(); } return null; } } } catch (err) { log(`⚠️ HTML 콘텐츠 필터링 중 오류 발생: ${err.message}`); } } } else { // 마스터 필터링 비활성화 시 방문 횟수만 갱신 const domain = extractDomain(link); if (domain) { let visitCount = visitedLinks.get(domain) || 0; visitedLinks.set(domain, visitCount + 1); visitedCountElem.innerText = visitedLinks.size.toString(); // 페이지 로딩 시간 측정 const loadStart = performance.now(); try { const fetchResponse = await fetch(link, { mode: 'cors' }); if (fetchResponse.ok) { const loadEnd = performance.now(); pageLoadTime = Math.round(loadEnd - loadStart); } else { pageLoadTime = '응답 불량'; } } catch (err) { pageLoadTime = '계산 불가'; } // HTML 옵션 if (!toggleHTML.checked) { htmlLink = '비활성화'; } // 이미지 옵션 if (!toggleImages.checked) { image = '비활성화'; } const result = { title, link, description, image, htmlLink, pageLoadTime }; results.push(result); } } // 마스터 필터링이 활성화된 경우에만 필터링된 결과를 저장 if (masterFilterEnabled && (filterPatterns.some(regex => regex.test(`${title} ${description}`)) || toggleAds.checked && `${title} ${description}`.toLowerCase().includes('광고'))) { return null; // 필터링된 항목은 저장하지 않음 } // 결과 테이블에 추가 const row = document.createElement('tr'); row.innerHTML = ` <td>${escapeHTML(title)}</td> <td><a href="${escapeHTML(link)}" target="_blank">${escapeHTML(link)}</a></td> <td>${escapeHTML(description)}</td> <td>${image}</td> <td>${htmlLink}</td> <td>${pageLoadTime}</td> `; resultsBody.appendChild(row); return result; }); // Promise.all을 통해 모든 항목 처리 완료 대기 const resultsProcessed = await Promise.all(itemPromises); // 필터링으로 인해 제거된 결과는 null이므로 제거 results = resultsProcessed.filter(item => item !== null); // 데이터 시각화 업데이트 updateChart(); // 진행률 업데이트 updateProgress(); // 다음 페이지로 이동 currentPage++; currentPageElem.innerText = currentPage; // 대기 시간 추가하여 서버에 부담 주지 않기 setTimeout(() => { crawlPage(); }, isPaused ? 0 : 1500); // 1.5초 대기 }, onerror: function() { log(`❌ 페이지 ${currentPage} 요청 중 오류 발생.`); handleCrawlError(currentPage, retryAttempts); } }); } async function handleCrawlError(page, retriesLeft) { if (retriesLeft > 0 && isRunning) { log(`🔄 페이지 ${page} 재시도 (${retriesLeft}회 남음).`); setTimeout(() => { const url = constructURL(page); GM_xmlhttpRequest({ method: "GET", url: url, headers: { "User-Agent": navigator.userAgent, "Accept": "text/html" }, onload: async function(response) { if (response.status === 200) { log(`✅ 페이지 ${page} 재시도 성공.`); await crawlPage(); } else { await handleCrawlError(page, retriesLeft - 1); } }, onerror: async function() { await handleCrawlError(page, retriesLeft - 1); } }); }, retryInterval); } else { log(`❌ 페이지 ${page} 로드 실패: 최대 재시도 횟수 초과.`); // 크롤링을 중지하지 않고 다음 페이지로 넘어감 currentPage++; currentPageElem.innerText = currentPage; setTimeout(() => { crawlPage(); }, 1500); } } function constructURL(page) { if (searchEngine === 'google') { return `https://www.google.com/search?q=${encodeURIComponent(searchQuery)}&start=${(page-1)*10}`; } else if (searchEngine === 'bing') { return `https://www.bing.com/search?q=${encodeURIComponent(searchQuery)}&first=${(page-1)*10 +1}`; } else if (searchEngine === 'daum') { return `https://search.daum.net/search?q=${encodeURIComponent(searchQuery)}&page=${page}`; } else if (searchEngine === 'naver') { return `https://search.naver.com/search.naver?query=${encodeURIComponent(searchQuery)}&start=${(page-1)*10 +1}`; } else if (searchEngine === 'yahoo') { return `https://search.yahoo.com/search?p=${encodeURIComponent(searchQuery)}&b=${(page-1)*10 +1}`; } else if (searchEngine === 'duckduckgo') { return `https://duckduckgo.com/html/?q=${encodeURIComponent(searchQuery)}&s=${(page-1)*10}`; } else if (searchEngine === 'ecosia') { return `https://www.ecosia.org/search?q=${encodeURIComponent(searchQuery)}&page=${page}`; } else if (searchEngine === 'startpage') { return `https://www.startpage.com/do/search?query=${encodeURIComponent(searchQuery)}&page=${page}`; } else { return ''; } } function updateProgress() { // 무제한이므로 진행률을 페이지 수에 기반하여 표시 const progressPercent = (currentPage % 100) * 1; // 100페이지마다 100%로 리셋 progressBar.value = progressPercent > 100 ? 100 : progressPercent; progressText.innerText = `페이지 ${currentPage}`; if (progressPercent >= 100) { progressBar.value = 0; } } function resetCrawling() { isRunning = false; isPaused = false; currentPage = 1; results = []; visitedLinks.clear(); resultsBody.innerHTML = ''; progressBar.value = 0; progressText.innerText = '0%'; currentPageElem.innerText = '0'; visitedCountElem.innerText = '0'; elapsedTimeElem.innerText = '00:00:00'; remainingTimeElem.innerText = '00:00:00'; logMessages = []; logContainer.innerHTML = `<strong>로그:</strong><br>`; GM_setValue('crawlerLogs', JSON.stringify(logMessages)); // 차트 초기화 crawlData.labels = []; crawlData.datasets[0].data = []; if (crawlChart) { crawlChart.update(); } clearInterval(elapsedInterval); log('🔄 크롤링을 초기화하였습니다.'); } function exportResults() { if (results.length === 0) { alert('내보낼 결과가 없습니다.'); return; } const format = prompt('내보낼 형식을 선택하세요 (xlsx, csv, json):', 'xlsx'); if (!format) return; if (format.toLowerCase() === 'xlsx') { const ws = XLSX.utils.json_to_sheet(results); const wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, ws, "결과"); XLSX.writeFile(wb, "크롤링_결과.xlsx"); log('💾 결과를 "크롤링_결과.xlsx" 파일로 내보냈습니다.'); GM_notification({ text: '결과를 "크롤링_결과.xlsx" 파일로 내보냈습니다.', title: '웹 크롤러 7.8', timeout: 3000 }); } else if (format.toLowerCase() === 'csv') { const csv = results.map(row => `"${escapeCSV(row.title)}","${escapeCSV(row.link)}","${escapeCSV(row.description)}","${escapeCSV(row.image)}","${escapeCSV(row.htmlLink)}","${escapeCSV(row.pageLoadTime)}"`).join('\n'); const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = '크롤링_결과.csv'; a.click(); log('💾 결과를 "크롤링_결과.csv" 파일로 내보냈습니다.'); GM_notification({ text: '결과를 "크롤링_결과.csv" 파일로 내보냈습니다.', title: '웹 크롤러 7.8', timeout: 3000 }); } else if (format.toLowerCase() === 'json') { const json = JSON.stringify(results, null, 2); const blob = new Blob([json], { type: 'application/json;charset=utf-8;' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = '크롤링_결과.json'; a.click(); log('💾 결과를 "크롤링_결과.json" 파일로 내보냈습니다.'); GM_notification({ text: '결과를 "크롤링_결과.json" 파일로 내보냈습니다.', title: '웹 크롤러 7.8', timeout: 3000 }); } else { alert('지원하지 않는 형식입니다.'); } } function escapeHTML(str) { if (!str) return ''; return str.replace(/&/g, "&") .replace(/</g, "<") .replace(/>/g, ">") .replace(/"/g, """) .replace(/'/g, "'"); } function escapeCSV(str) { if (!str) return ''; return str.replace(/"/g, '""'); } function extractDomain(url) { try { const urlObj = new URL(url); return urlObj.hostname.replace('www.', ''); } catch (e) { return null; } } function updateElapsedTime() { if (!startTime) return; const now = Date.now(); const elapsed = Math.floor((now - startTime) / 1000); elapsedTimeElem.innerText = formatTime(elapsed); const estimatedTotal = currentPage * 1.5; // 예측: 각 페이지 1.5초 const remaining = Math.max(estimatedTotal - elapsed, 0); remainingTimeElem.innerText = formatTime(Math.floor(remaining)); } function formatTime(seconds) { const hrs = String(Math.floor(seconds / 3600)).padStart(2, '0'); const mins = String(Math.floor((seconds % 3600) / 60)).padStart(2, '0'); const secs = String(seconds % 60).padStart(2, '0'); return `${hrs}:${mins}:${secs}`; } function updateChart() { crawlData.labels = Array.from(visitedLinks.keys()); crawlData.datasets[0].data = Array.from(visitedLinks.values()); if (crawlChart) { crawlChart.update(); } // 저장 GM_setValue('crawlerData', JSON.stringify(crawlData)); } function loadCrawlData() { const storedData = GM_getValue('crawlerData', null); if (storedData) { const parsedData = JSON.parse(storedData); crawlData = parsedData; if (crawlChart) { crawlChart.data = crawlData; crawlChart.update(); } } } function saveCrawlData() { GM_setValue('crawlerData', JSON.stringify(crawlData)); } // 주기적으로 크롤링 데이터를 저장 setInterval(saveCrawlData, 5000); // 검색 엔진 바로 가기 버튼 기능 function toggleSearchEnginesPopup() { if (searchEnginePopup.style.display === 'block') { searchEnginePopup.style.display = 'none'; } else { searchEnginePopup.style.display = 'block'; } } // HTML 버튼 클릭 및 호버 기능 추가 container.addEventListener('click', function(event) { if (event.target.classList.contains('html-btn') || event.target.parentElement.classList.contains('html-btn')) { const btn = event.target.classList.contains('html-btn') ? event.target : event.target.parentElement; const url = decodeURIComponent(btn.getAttribute('data-url')); showHTMLInUI(url); } }); container.addEventListener('mouseover', function(event) { const btn = event.target.classList.contains('html-btn') ? event.target : event.target.parentElement; if (btn && btn.classList.contains('html-btn')) { const url = decodeURIComponent(btn.getAttribute('data-url')); showPreviewPopup(btn, url); } }); container.addEventListener('mouseout', function(event) { if (event.target.classList.contains('html-btn') || event.target.parentElement.classList.contains('html-btn')) { const popup = container.querySelector('.preview-popup'); if (popup) { popup.style.display = 'none'; } } }); function showHTMLInUI(url) { // UI 내에 iframe을 사용하여 사이트 내용 표시 if (!htmlDisplayIframe) return; htmlDisplayIframe.src = url; htmlDisplayIframe.style.display = 'block'; // 탭을 '결과'로 전환 switchTab('results'); } function showPreviewPopup(target, url) { // 팝업 생성 let popup = container.querySelector('.preview-popup'); if (!popup) { popup = document.createElement('div'); popup.className = 'preview-popup'; container.appendChild(popup); } popup.style.display = 'block'; const targetRect = target.getBoundingClientRect(); const containerRect = container.getBoundingClientRect(); popup.style.left = `${target.offsetLeft}px`; popup.style.top = `${target.offsetTop + target.offsetHeight + 5}px`; popup.innerHTML = `<iframe src="${url}" style="width:100%; height:100%; border:none;"></iframe>`; } function switchTab(tabId) { const tabs = container.querySelectorAll('.tab'); const tabContents = container.querySelectorAll('.tab-content'); tabs.forEach(t => { if(t.getAttribute('data-tab') === tabId){ t.classList.add('active'); } else { t.classList.remove('active'); } }); tabContents.forEach(content => { if(content.id === tabId){ content.classList.add('active'); } else { content.classList.remove('active'); } }); } // 주기적으로 크롤링 데이터를 저장 setInterval(saveCrawlData, 5000); - Assistant