-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
312 lines (284 loc) · 9.37 KB
/
content.js
File metadata and controls
312 lines (284 loc) · 9.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
// 소셜 로그인 제공업체 정의 및 감지 패턴
const socialProviders = {
'google': {
patterns: [
'accounts.google.com',
'oauth2/auth',
'google.com/signin',
'btn-google',
'google-signin',
'continue-with-google',
'sign-in-with-google',
'google로 로그인',
'asset-google-symbol',
'google로',
'login_google',
'sl_google',
'icon_login_google'
],
name: 'Google',
color: '#4285f4'
},
'kakao': {
patterns: [
'kauth.kakao.com',
'kakao.com/oauth',
'kakaocdn.net',
'btn-kakao',
'kakao-login',
'kakao_login',
'continue-with-kakao',
'kakao로 계속하기',
'카카오로 로그인',
'카카오 로그인',
'kakao계정으로',
'kakao 계정으로',
'sign-in-with-kakao',
'login-kakao',
'oauth-kakao',
'kakao-signin',
'kakao-auth',
'kakao-로그인-버튼',
'fa-comment',
'comment',
'asset-kakao-symbol',
'kakao_sign_in',
'login_kakao',
'sl_kakao',
'icon_login_kakao'
],
name: '카카오',
color: '#fee500'
},
'github': {
patterns: [
'github.com/login/oauth',
'btn-github',
'github-signin',
'continue-with-github',
'sign-in-with-github'
],
name: 'GitHub',
color: '#333'
},
'facebook': {
patterns: [
'facebook.com/login.php',
'facebook.com/dialog/oauth',
'btn-facebook',
'facebook-login',
'continue-with-facebook',
'asset-facebook-symbol',
'facebook_sign_in',
'login_facebook',
'sl_facebook',
'icon_login_facebook'
],
name: 'Facebook',
color: '#1877f2'
},
'naver': {
patterns: [
'nid.naver.com',
'naver.com/oauth2.0',
'btn-naver',
'naver-login',
'continue-with-naver',
'네이버로 로그인',
'naver로 로그인',
'asset-naver-symbol',
'naver로',
'login_naver',
'sl_naver',
'icon_login_naver'
],
name: '네이버',
color: '#03c75a'
},
'apple': {
patterns: [
'appleid.apple.com',
'btn-apple',
'apple-signin',
'continue-with-apple',
'sign-in-with-apple',
'asset-apple-symbol',
'apple_sign_in',
'login_apple',
'sl_apple',
'icon_login_apple'
],
name: 'Apple',
color: '#000'
}
};
// 중복 감지 방지용 변수
let lastDetected = null;
// 현재 페이지에서 소셜 로그인 사용 여부를 감지하는 함수
function detectSocialLogin() {
const currentUrl = window.location.href;
const currentDomain = window.location.hostname;
// 성능 최적화: 텍스트 검색을 최소화
const pageContent = document.body ? document.body.innerText.toLowerCase() : '';
const pageHTML = document.documentElement ? document.documentElement.innerHTML.toLowerCase() : '';
console.log(`[조원호 짱짱맨] ${currentDomain}에서 소셜 로그인 확인 중`);
console.log(`[조원호 짱짱맨] URL: ${currentUrl}`);
// 각 소셜 로그인 제공업체의 패턴을 확인
for (const [providerId, provider] of Object.entries(socialProviders)) {
for (const pattern of provider.patterns) {
// 로그인 관련 페이지나 요소가 있는지 확인
if (currentUrl.includes('/login') || currentUrl.includes('/signin') || currentUrl.includes('/auth') ||
currentUrl.includes('login.') || currentUrl.includes('signin.') || currentUrl.includes('auth.') ||
pageContent.includes('로그인') || pageContent.includes('login') || pageContent.includes('sign in') ||
pageHTML.includes('login') || pageHTML.includes('signin')) {
// 실제 해당 제공업체 버튼이 있는지 확인
if (currentUrl.includes(pattern) ||
pageContent.includes(pattern) ||
pageHTML.includes(pattern)) {
console.log(`[조원호 짱짱맨] 로그인 페이지에서 패턴 매칭됨: "${pattern}" → ${provider.name} (${providerId})`);
// 중복 감지 방지 (10초간만)
const detectionKey = `${currentDomain}-${providerId}`;
const now = Date.now();
if (lastDetected && lastDetected.key === detectionKey && now - lastDetected.time < 10000) {
return;
}
lastDetected = { key: detectionKey, time: now };
// 귀여운 알림 표시
showCuteLoginNotification(providerId);
// 백그라운드 스크립트에 소셜 로그인 감지 정보 전송
try {
if (typeof chrome !== 'undefined' && chrome.runtime && chrome.runtime.sendMessage) {
chrome.runtime.sendMessage({
type: 'SOCIAL_LOGIN_DETECTED',
data: {
site: currentDomain,
provider: providerId,
providerName: provider.name,
timestamp: Date.now(),
url: currentUrl
}
});
}
} catch (error) {
console.log('Extension context not available');
}
console.log(`[조원호 짱짱맨] 소셜 로그인 감지됨: ${provider.name} → ${currentDomain}`);
return;
}
}
}
}
}
// DOM 변경사항을 관찰하여 동적으로 추가되는 로그인 버튼 감지
function observeLoginButtons() {
if (!document.body) return;
let detectTimeout;
const observer = new MutationObserver(() => {
clearTimeout(detectTimeout);
detectTimeout = setTimeout(detectSocialLogin, 100);
});
observer.observe(document.body, {
childList: true,
subtree: true
});
}
// 리다이렉트 처리 (OAuth 플로우에서 발생)
function handleRedirects() {
if (window.location.href !== document.referrer) {
detectSocialLogin();
}
}
// 페이지 로딩 상태에 따른 초기화 (Chrome extension 환경에서만 실행)
if (typeof chrome !== 'undefined' && chrome.runtime) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => {
setTimeout(() => {
detectSocialLogin();
observeLoginButtons();
handleRedirects();
}, 100);
});
} else {
setTimeout(() => {
detectSocialLogin();
observeLoginButtons();
handleRedirects();
}, 100);
}
}
// 클릭 이벤트 후 소셜 로그인 감지 (Chrome extension 환경에서만)
if (typeof chrome !== 'undefined' && chrome.runtime) {
let clickTimeout;
document.addEventListener('click', (event) => {
// 로그인 관련 버튼 클릭만 감지
const target = event.target.closest('button, a, [role="button"]');
if (target) {
const text = target.textContent.toLowerCase();
const className = target.className.toLowerCase();
if (text.includes('로그인') || text.includes('login') || text.includes('signin') ||
className.includes('login') || className.includes('signin') || className.includes('btn')) {
clearTimeout(clickTimeout);
clickTimeout = setTimeout(detectSocialLogin, 100);
}
}
});
}
// 이미 표시된 알림을 추적
const shownNotifications = new Set();
// 화면 오른쪽 하단에 귀여운 알림을 표시하는 함수
function showCuteLoginNotification(providerId) {
const provider = socialProviders[providerId];
if (!provider) return;
// 중복 방지
if (shownNotifications.has(providerId)) {
return;
}
shownNotifications.add(providerId);
console.log(`[조원호 짱짱맨] ${provider.name} 귀여운 알림 표시`);
// 알림 창 생성
const notification = document.createElement('div');
notification.style.cssText = `
position: fixed !important;
bottom: 20px !important;
right: 20px !important;
background: rgba(255, 255, 255, 0.95) !important;
backdrop-filter: blur(10px) !important;
color: #333 !important;
padding: 14px 18px !important;
border-radius: 12px !important;
border: 1px solid rgba(0,0,0,0.08) !important;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
font-size: 13px !important;
font-weight: 500 !important;
z-index: 999999 !important;
box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.08) !important;
animation: slideInBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) !important;
cursor: pointer !important;
user-select: none !important;
max-width: 280px !important;
line-height: 1.4 !important;
`;
notification.innerHTML = `최근에 ${provider.name}로 로그인하셨습니다! ✨`;
// 애니메이션 키프레임 추가
if (!document.querySelector('#cute-notification-keyframes')) {
const style = document.createElement('style');
style.id = 'cute-notification-keyframes';
style.textContent = `
@keyframes slideInBounce {
0% { transform: translateY(100px) scale(0.8); opacity: 0; }
50% { transform: translateY(-5px) scale(1.02); opacity: 0.9; }
100% { transform: translateY(0) scale(1); opacity: 1; }
}
`;
document.head.appendChild(style);
}
document.body.appendChild(notification);
// 클릭 시 제거
notification.addEventListener('click', () => {
notification.remove();
});
}
// 페이지 언로드 전 마지막 감지 시도
window.addEventListener('beforeunload', () => {
detectSocialLogin();
});