-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrevert_old_cot.js
More file actions
159 lines (133 loc) · 9.16 KB
/
Copy pathrevert_old_cot.js
File metadata and controls
159 lines (133 loc) · 9.16 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
// ==UserScript==
// @name Revert Old Gemini CoT
// @description Reverts the old Gemini CoT (Chain of Thoughts) UI.
// @author KlartNET
// @version 0.0
// @match https://gemini.google.com/*
// @run-at document-end
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 1. 네이티브 M3 디자인 및 오버플로우 차단 스타일 주입 (다크모드 컬러 보정 완료)
const style = document.createElement('style');
style.textContent = `
context-sidebar { position: fixed !important; left: 0 !important; top: 0 !important; width: 1px !important; height: 1px !important; overflow: hidden !important; opacity: 0 !important; pointer-events: none !important; z-index: -9999 !important; transition: none !important; animation: none !important; }
html.custom-macro-running .cdk-overlay-container, html.custom-macro-running .mat-mdc-menu-panel, html.custom-macro-running .cdk-overlay-backdrop { opacity: 0 !important; pointer-events: none !important; transition: none !important; animation: none !important; }
html.custom-macro-running, html.custom-macro-running body { overflow-x: hidden !important; position: static !important; }
.custom-thought-container { margin: 12px 0; width: 100%; display: block; overflow: hidden; border-radius: 16px; background-color: #f0f4f9; font-family: 'Google Sans', 'Product Sans', Arial, sans-serif; transition: background-color 280ms cubic-bezier(0.2, 0, 0, 1); }
.custom-thought-container:hover { background-color: #e9eef6; }
.custom-thought-summary { padding: 14px 20px; font-weight: 500; font-size: 14px; cursor: pointer; user-select: none; outline: none; list-style: none; display: flex; align-items: center; justify-content: space-between; color: #444746; transition: color 280ms cubic-bezier(0.2, 0, 0, 1); }
.custom-thought-summary::-webkit-details-marker { display: none; }
.custom-thought-summary::after { content: ''; display: inline-block; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-right: 4px; transition: transform 280ms cubic-bezier(0.2, 0, 0, 1); }
.custom-thought-container[open] .custom-thought-summary::after { transform: rotate(-135deg); }
.custom-thought-container[open] .custom-thought-summary { color: #1f1f1f; }
.custom-thought-wrapper { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 280ms cubic-bezier(0.2, 0, 0, 1); }
.custom-thought-container[open] .custom-thought-wrapper { grid-template-rows: 1fr; }
.custom-thought-content { overflow: hidden; min-height: 0; }
.custom-thought-text { padding: 0 20px 20px 20px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; max-height: 400px; overflow-y: auto; color: #1f1f1f; opacity: 0; transition: opacity 280ms cubic-bezier(0.2, 0, 0, 1); }
.custom-thought-container[open] .custom-thought-text { opacity: 1; }
@media (prefers-color-scheme: dark) {
.custom-thought-container { background-color: #1e1e1e; } .custom-thought-container:hover { background-color: #282828; }
.custom-thought-summary { color: #c4c7c5; } .custom-thought-container[open] .custom-thought-summary { color: #e3e3e3; } .custom-thought-text { color: #e3e3e3; }
}
.gb_J .custom-thought-container, html[theme="dark"] .custom-thought-container { background-color: #1e1e1e; }
.gb_J .custom-thought-container:hover, html[theme="dark"] .custom-thought-container:hover { background-color: #282828; }
.gb_J .custom-thought-summary, html[theme="dark"] .custom-thought-summary { color: #c4c7c5; }
.gb_J .custom-thought-container[open] .custom-thought-summary, html[theme="dark"] .custom-thought-container[open] .custom-thought-summary { color: #e3e3e3; }
.gb_J .custom-thought-text, html[theme="dark"] .custom-thought-text { color: #e3e3e3; }
`;
document.head.appendChild(style);
// 2. rAF 기반 비동기 엘리먼트 추적 헬퍼
const waitFor = (conditionFn) => new Promise((resolve) => {
const check = () => {
const res = conditionFn();
if (res) resolve(res);
else requestAnimationFrame(check);
};
check();
});
// 3. 메인 인터셉트 엔진
function injectThoughtBox() {
document.querySelectorAll('model-response').forEach(msg => {
if (msg.querySelector('.custom-thought-container') || !msg.querySelector('.has-thoughts')) return;
// [근거 반영] 타겟 버튼 탐색 스코프를 message-actions 영역 내부로 엄격히 제한하여 표(Table) 내부 버튼 우회
const btn = msg.querySelector('message-actions gem-icon-button[data-test-id="more-menu-button"] button, message-actions button[aria-label="옵션 더보기"]');
const tgt = msg.querySelector('structured-content-container');
if (!btn || !tgt) return;
const details = document.createElement('details');
details.className = 'custom-thought-container';
const summary = document.createElement('summary');
summary.className = 'custom-thought-summary';
summary.textContent = '✨ 생각의 과정';
const wrapper = document.createElement('div');
wrapper.className = 'custom-thought-wrapper';
const content = document.createElement('div');
content.className = 'custom-thought-content';
const textDiv = document.createElement('div');
textDiv.className = 'custom-thought-text';
textDiv.textContent = '생각의 내용을 동기화 중...';
content.append(textDiv);
wrapper.append(content);
details.append(summary, wrapper);
summary.addEventListener('click', async (e) => {
e.preventDefault();
if (details.hasAttribute('open')) {
details.removeAttribute('open');
return;
}
details.setAttribute('open', '');
if (textDiv.getAttribute('data-loaded') === 'true') return;
document.documentElement.classList.add('custom-macro-running');
let p = msg.parentElement;
while (p && p !== document.body && !['auto', 'scroll'].includes(window.getComputedStyle(p).overflowY)) {
p = p.parentElement;
}
const root = p || document.documentElement;
const top = root.scrollTop;
const orig = { view: Element.prototype.scrollIntoView, to: window.scrollTo, scr: window.scroll, foc: HTMLElement.prototype.focus };
Element.prototype.scrollIntoView = window.scrollTo = window.scroll = HTMLElement.prototype.focus = () => {};
try {
Object.defineProperty(root, 'scrollTop', { get: () => top, set: () => {}, configurable: true });
} catch (_) {}
try {
btn.click();
const target = await waitFor(() =>
Array.from(document.querySelectorAll('.mat-mdc-menu-panel [role="menuitem"], [role="menuitem"], .mat-menu-item'))
.find(i => i.textContent.includes('사고 단계') || i.textContent.includes('thinking'))
);
if (target) {
target.click();
const el = await waitFor(() => {
const s = document.querySelector('context-sidebar message-content');
return s && s.textContent.trim() ? s : null;
});
if (el) {
textDiv.textContent = el.innerText.trim();
textDiv.setAttribute('data-loaded', 'true');
document.querySelector('context-sidebar button[data-test-id="close-button"], context-sidebar button[aria-label="사이드바 닫기"]')?.click();
} else {
textDiv.textContent = "데이터 스트림 가로채기 실패.";
}
} else {
textDiv.textContent = "메뉴 진입점 확보 실패.";
document.body.click();
}
} catch (err) {
textDiv.textContent = `실행 에러: ${err.message}`;
} finally {
Object.assign(Element.prototype, { scrollIntoView: orig.view });
Object.assign(HTMLElement.prototype, { focus: orig.foc });
Object.assign(window, { scrollTo: orig.to, scroll: orig.scr });
try {
delete root.scrollTop;
root.scrollTop = top;
} catch (_) {}
document.documentElement.classList.remove('custom-macro-running');
}
});
tgt.parentNode.insertBefore(details, tgt);
});
}
new MutationObserver(injectThoughtBox).observe(document.body, { childList: true, subtree: true });
})();