Last active
October 23, 2025 10:53
-
-
Save lunamoth/f098edd37fa903e6b42ac6ca1604467f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // manifest.json | |
| { | |
| "manifest_version": 3, | |
| "name": "더블 검색 (자동 수정판)", | |
| "version": "1.3", | |
| "description": "주소창에서 구글 검색 시 자동으로 Google AI 검색 탭을 함께 엽니다.", | |
| "permissions": [ | |
| "tabs" | |
| ], | |
| "background": { | |
| "service_worker": "background.js" | |
| } | |
| } | |
| // background.js | |
| chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { | |
| // 탭의 URL이 변경되었을 때만 코드를 실행합니다. | |
| if (changeInfo.url) { | |
| try { | |
| const url = new URL(changeInfo.url); | |
| // 변경된 URL이 구글 검색 결과 페이지인지 확인합니다. | |
| if (url.hostname === 'www.google.com' && url.pathname === '/search') { | |
| // URL에서 검색어('q' 파라미터)를 가져옵니다. | |
| const query = url.searchParams.get('q'); | |
| // 주소창에서 실행된 '최초의 검색'인지 확인합니다. (무한 루프 방지) | |
| const isFirstSearch = url.searchParams.has('sourceid'); | |
| if (query && isFirstSearch) { | |
| // 요청하신 Google AI 검색 URL을 생성합니다. | |
| const aiSearchUrl = `https://google.com/ai?q=${encodeURIComponent(query)}`; | |
| // ★★★ 2초 딜레이 추가 ★★★ | |
| // setTimeout 함수를 사용하여 2000밀리초(2초) 후에 코드를 실행합니다. | |
| setTimeout(() => { | |
| // 새 탭에서 AI 검색을 엽니다. | |
| chrome.tabs.create({ url: aiSearchUrl }); | |
| }, 2000); // 딜레이 시간 (1000 = 1초) | |
| } | |
| } | |
| } catch (e) { | |
| // 유효하지 않은 URL 형식 등의 오류는 무시합니다. | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment