Dernière activité 1778119947

在办公室使用gpt会被同事追问:你怎么用上的?怎么翻墙的?能给我用用吗?而你又不想给这类 “等人喂饭” 的人群分享时,那么这个脚本就可以帮助到你了

doracoin's Avatar doracoin a révisé ce gist 1778119937. Aller à la révision

1 file changed, 48 insertions, 19 deletions

change-gpt-logo.user.js

@@ -1,10 +1,13 @@
1 1 // ==UserScript==
2 2 // @name ChatGPT Logo 换成 DeepSeek
3 3 // @namespace https://gist.doracoin.cc/doracoin/39fd3ec77d3044fc95b408bdf6c0ac13
4 - // @version 2026.01.15
4 + // @version 2026.05.07
5 5 // @license MIT
6 6 // @description 替换 ChatGPT 左上角 sidebar-header 的 SVG logo 为 DeepSeek logo,并实现 #page-header 向上收缩(垂直折叠),支持 SPA 重绘、状态记忆,并增加可配置项与主题适配按钮。
7 - // @author Doracoin
7 + // @author Doracoin <[email protected]>
8 + // @homepageURL https://gist.doracoin.cc/doracoin/39fd3ec77d3044fc95b408bdf6c0ac13
9 + // @updateURL https://gist.doracoin.cc/doracoin/39fd3ec77d3044fc95b408bdf6c0ac13/raw/HEAD/change-gpt-logo.user.js
10 + // @downloadURL https://gist.doracoin.cc/doracoin/39fd3ec77d3044fc95b408bdf6c0ac13/download/HEAD/change-gpt-logo.user.js
8 11 // @match https://chatgpt.com/*
9 12 // @icon https://deepseek.com/favicon.ico
10 13 // @run-at document-body
@@ -17,11 +20,12 @@
17 20 // ====== 配置区 ======
18 21 const CONFIG = {
19 22 deepseekLogoUrl: 'https://commons.wikimedia.org/wiki/Special:Redirect/file/DeepSeek_logo.svg',
23 + deepseekSquareIconUrl: 'https://deepseek.com/favicon.ico',
20 24 storageKey: 'deepseek_header_collapsed_v2',
21 - headerMaxHeight: 82, // header 默认高度
22 - buttonSize: 36, // 按钮尺寸(px)
23 - buttonPosition: { top: 10, right: 12 }, // 按钮固定位置
24 - enableLogs: false // 是否启用 console.log 调试
25 + headerMaxHeight: 82,
26 + buttonSize: 36,
27 + buttonPosition: { top: 10, right: 12 },
28 + enableLogs: false
25 29 };
26 30 // ====================
27 31
@@ -86,34 +90,31 @@
86 90 if (CONFIG.enableLogs) console.log('[DeepSeek]', ...args);
87 91 }
88 92
89 - // 替换 sidebar header logo(保留用户调整的宽高逻辑)
90 93 function replaceLogo() {
91 94 try {
92 - const sidebarHeader = document.querySelector('.sidebar-header') || document.querySelector('.sidebar .header') || document.querySelector('nav[aria-label]');
95 + const sidebarHeader = document.querySelector('#sidebar-header');
93 96 if (!sidebarHeader) return;
94 97
95 - const origSvg = sidebarHeader.querySelector('svg');
96 - const origImg = sidebarHeader.querySelector('img');
97 -
98 98 if (sidebarHeader.querySelector('img[data-deepseek-logo]')) return;
99 99
100 + const logoLink = sidebarHeader.querySelector('a[aria-label="主页"]');
101 + if (!logoLink) return;
102 +
100 103 const img = document.createElement('img');
101 104 img.setAttribute('src', CONFIG.deepseekLogoUrl);
102 105 img.setAttribute('alt', 'DeepSeek');
103 106 img.setAttribute('data-deepseek-logo', '1');
104 - img.style.height = '28px'; // 用户修改的高度
107 + img.style.height = '28px';
105 108 img.style.width = 'auto';
106 109 img.style.objectFit = 'contain';
107 110 img.style.verticalAlign = 'middle';
108 111
109 - const parent = origSvg?.parentNode || origImg?.parentNode || sidebarHeader.querySelector('a') || sidebarHeader;
110 - parent.innerHTML = '';
111 - parent.appendChild(img);
112 + logoLink.innerHTML = '';
113 + logoLink.appendChild(img);
112 114
113 - // 调整父容器以适配新 logo 宽高
114 - if (parent.classList.contains("w-9")) {
115 - parent.classList.remove("w-9");
116 - parent.classList.add("w-21");
115 + if (logoLink.classList.contains("w-9")) {
116 + logoLink.classList.remove("w-9");
117 + logoLink.classList.add("w-21");
117 118 }
118 119
119 120 log('logo replaced');
@@ -122,6 +123,32 @@
122 123 }
123 124 }
124 125
126 + function replaceCollapsedIcon() {
127 + try {
128 + const openBtn = document.querySelector('button[aria-label="打开边栏"]');
129 + if (!openBtn) return;
130 +
131 + const firstSvg = openBtn.querySelector('svg');
132 + if (!firstSvg) return;
133 +
134 + if (openBtn.querySelector('img[data-deepseek-collapsed]')) return;
135 +
136 + const img = document.createElement('img');
137 + img.setAttribute('src', CONFIG.deepseekSquareIconUrl);
138 + img.setAttribute('alt', 'DeepSeek');
139 + img.setAttribute('data-deepseek-collapsed', '1');
140 + img.style.width = '20px';
141 + img.style.height = '20px';
142 + img.style.objectFit = 'contain';
143 +
144 + firstSvg.replaceWith(img);
145 +
146 + log('collapsed icon replaced');
147 + } catch (e) {
148 + log('replaceCollapsedIcon error', e);
149 + }
150 + }
151 +
125 152 function ensureToggle() {
126 153 let btn = document.getElementById('ds-page-header-toggle');
127 154 if (btn) return btn;
@@ -167,6 +194,7 @@
167 194 if (debounceTimer) clearTimeout(debounceTimer);
168 195 debounceTimer = setTimeout(() => {
169 196 replaceLogo();
197 + replaceCollapsedIcon();
170 198 ensureToggle();
171 199 restoreState();
172 200 }, 250);
@@ -176,6 +204,7 @@
176 204 observer.observe(document.body, { childList: true, subtree: true });
177 205
178 206 replaceLogo();
207 + replaceCollapsedIcon();
179 208 ensureToggle();
180 209 restoreState();
181 210 window.addEventListener('load', () => setTimeout(onDomChanged, 300));

doracoin a révisé ce gist 1768460476. Aller à la révision

1 file changed, 1 insertion, 1 deletion

change-gpt-logo.user.js

@@ -1,7 +1,7 @@
1 1 // ==UserScript==
2 2 // @name ChatGPT Logo 换成 DeepSeek
3 3 // @namespace https://gist.doracoin.cc/doracoin/39fd3ec77d3044fc95b408bdf6c0ac13
4 - // @version 2025.09.12
4 + // @version 2026.01.15
5 5 // @license MIT
6 6 // @description 替换 ChatGPT 左上角 sidebar-header 的 SVG logo 为 DeepSeek logo,并实现 #page-header 向上收缩(垂直折叠),支持 SPA 重绘、状态记忆,并增加可配置项与主题适配按钮。
7 7 // @author Doracoin

doracoin a révisé ce gist 1768460430. Aller à la révision

1 file changed, 1 insertion, 1 deletion

change-gpt-logo.user.js

@@ -101,7 +101,7 @@
101 101 img.setAttribute('src', CONFIG.deepseekLogoUrl);
102 102 img.setAttribute('alt', 'DeepSeek');
103 103 img.setAttribute('data-deepseek-logo', '1');
104 - img.style.height = '56px'; // 用户修改的高度
104 + img.style.height = '28px'; // 用户修改的高度
105 105 img.style.width = 'auto';
106 106 img.style.objectFit = 'contain';
107 107 img.style.verticalAlign = 'middle';

doracoin a révisé ce gist 1757902740. Aller à la révision

1 file changed, 1 insertion

change-gpt-logo.user.js

@@ -2,6 +2,7 @@
2 2 // @name ChatGPT Logo 换成 DeepSeek
3 3 // @namespace https://gist.doracoin.cc/doracoin/39fd3ec77d3044fc95b408bdf6c0ac13
4 4 // @version 2025.09.12
5 + // @license MIT
5 6 // @description 替换 ChatGPT 左上角 sidebar-header 的 SVG logo 为 DeepSeek logo,并实现 #page-header 向上收缩(垂直折叠),支持 SPA 重绘、状态记忆,并增加可配置项与主题适配按钮。
6 7 // @author Doracoin
7 8 // @match https://chatgpt.com/*

doracoin a révisé ce gist 1757902168. Aller à la révision

1 file changed, 161 insertions, 30 deletions

change-gpt-logo.user.js

@@ -1,50 +1,181 @@
1 1 // ==UserScript==
2 - // @name ChatGPT Logo 换成 DeepSeek (sidebar-header, 自定义尺寸)
2 + // @name ChatGPT Logo 换成 DeepSeek
3 3 // @namespace https://gist.doracoin.cc/doracoin/39fd3ec77d3044fc95b408bdf6c0ac13
4 - // @version 2025.09.09
5 - // @description 替换 ChatGPT 左上角 sidebar-header 的 SVG logo 为 DeepSeek logo,并调整 a 标签和 logo 尺寸。
4 + // @version 2025.09.12
5 + // @description 替换 ChatGPT 左上角 sidebar-header 的 SVG logo 为 DeepSeek logo,并实现 #page-header 向上收缩(垂直折叠),支持 SPA 重绘、状态记忆,并增加可配置项与主题适配按钮。
6 6 // @author Doracoin
7 7 // @match https://chatgpt.com/*
8 8 // @icon https://deepseek.com/favicon.ico
9 - // @grant none
9 + // @run-at document-body
10 + // @grant GM_addStyle
10 11 // ==/UserScript==
11 12
12 - (function() {
13 + (function () {
13 14 'use strict';
14 15
15 - const deepseekLogoUrl = 'https://commons.wikimedia.org/wiki/Special:Redirect/file/DeepSeek_logo.svg';
16 + // ====== 配置区 ======
17 + const CONFIG = {
18 + deepseekLogoUrl: 'https://commons.wikimedia.org/wiki/Special:Redirect/file/DeepSeek_logo.svg',
19 + storageKey: 'deepseek_header_collapsed_v2',
20 + headerMaxHeight: 82, // header 默认高度
21 + buttonSize: 36, // 按钮尺寸(px)
22 + buttonPosition: { top: 10, right: 12 }, // 按钮固定位置
23 + enableLogs: false // 是否启用 console.log 调试
24 + };
25 + // ====================
16 26
27 + // 动态样式,支持深色/浅色主题自动适配
28 + GM_addStyle(`
29 + #page-header {
30 + --ds-header-max-height: ${CONFIG.headerMaxHeight}px;
31 + max-height: var(--ds-header-max-height);
32 + overflow: hidden;
33 + transition: max-height 260ms ease, padding 260ms ease;
34 + }
35 + #page-header.collapsed {
36 + max-height: 0 !important;
37 + padding-top: 0 !important;
38 + padding-bottom: 0 !important;
39 + }
40 + #page-header.collapsed * {
41 + visibility: hidden;
42 + pointer-events: none;
43 + }
44 +
45 + #ds-page-header-toggle {
46 + position: fixed;
47 + top: ${CONFIG.buttonPosition.top}px;
48 + right: ${CONFIG.buttonPosition.right}px;
49 + z-index: 2147483647;
50 + display: inline-flex;
51 + align-items: center;
52 + justify-content: center;
53 + width: ${CONFIG.buttonSize}px;
54 + height: ${CONFIG.buttonSize}px;
55 + border-radius: 6px;
56 + font-size: 16px;
57 + line-height: 1;
58 + background: var(--ds-btn-bg, rgba(0,0,0,0.6));
59 + color: var(--ds-btn-fg, #fff);
60 + cursor: pointer;
61 + user-select: none;
62 + transition: transform 140ms ease, opacity 140ms ease, background 200ms ease;
63 + box-shadow: 0 6px 18px rgba(0,0,0,0.35);
64 + margin-top: 38px;
65 + }
66 + #ds-page-header-toggle:hover {
67 + transform: translateY(-2px);
68 + }
69 +
70 + @media (prefers-color-scheme: light) {
71 + #ds-page-header-toggle {
72 + --ds-btn-bg: rgba(255,255,255,0.85);
73 + --ds-btn-fg: #000;
74 + }
75 + }
76 + @media (prefers-color-scheme: dark) {
77 + #ds-page-header-toggle {
78 + --ds-btn-bg: rgba(0,0,0,0.6);
79 + --ds-btn-fg: #fff;
80 + }
81 + }
82 + `);
83 +
84 + function log(...args) {
85 + if (CONFIG.enableLogs) console.log('[DeepSeek]', ...args);
86 + }
87 +
88 + // 替换 sidebar header logo(保留用户调整的宽高逻辑)
17 89 function replaceLogo() {
18 - const link = document.querySelector('#sidebar-header a');
19 - if (link && !link.classList.contains("deepseek-logo-replaced")) {
20 - // 修改 a 标签 class
21 - if (link.classList.contains("h-9")) {
22 - link.classList.remove("h-9");
23 - link.classList.add("h-10");
24 - }
25 - if (link.classList.contains("w-9")) {
26 - link.classList.remove("w-9");
27 - link.classList.add("w-68");
28 - }
90 + try {
91 + const sidebarHeader = document.querySelector('.sidebar-header') || document.querySelector('.sidebar .header') || document.querySelector('nav[aria-label]');
92 + if (!sidebarHeader) return;
29 93
30 - // 清空原始内容(ChatGPT 内联 SVG)
31 - link.innerHTML = '';
94 + const origSvg = sidebarHeader.querySelector('svg');
95 + const origImg = sidebarHeader.querySelector('img');
96 +
97 + if (sidebarHeader.querySelector('img[data-deepseek-logo]')) return;
32 98
33 - // 插入 DeepSeek logo
34 99 const img = document.createElement('img');
35 - img.src = deepseekLogoUrl;
36 - img.alt = "DeepSeek";
37 - img.style.width = "145px";
38 - img.style.height = "31px";
39 - img.style.objectFit = "contain";
40 -
41 - link.appendChild(img);
42 - link.classList.add("deepseek-logo-replaced");
100 + img.setAttribute('src', CONFIG.deepseekLogoUrl);
101 + img.setAttribute('alt', 'DeepSeek');
102 + img.setAttribute('data-deepseek-logo', '1');
103 + img.style.height = '56px'; // 用户修改的高度
104 + img.style.width = 'auto';
105 + img.style.objectFit = 'contain';
106 + img.style.verticalAlign = 'middle';
107 +
108 + const parent = origSvg?.parentNode || origImg?.parentNode || sidebarHeader.querySelector('a') || sidebarHeader;
109 + parent.innerHTML = '';
110 + parent.appendChild(img);
111 +
112 + // 调整父容器以适配新 logo 宽高
113 + if (parent.classList.contains("w-9")) {
114 + parent.classList.remove("w-9");
115 + parent.classList.add("w-21");
116 + }
117 +
118 + log('logo replaced');
119 + } catch (e) {
120 + log('replaceLogo error', e);
43 121 }
44 122 }
45 123
46 - replaceLogo();
124 + function ensureToggle() {
125 + let btn = document.getElementById('ds-page-header-toggle');
126 + if (btn) return btn;
127 +
128 + btn = document.createElement('div');
129 + btn.id = 'ds-page-header-toggle';
130 + btn.setAttribute('role', 'button');
131 + btn.setAttribute('aria-pressed', 'false');
132 + btn.setAttribute('title', '折叠/展开页眉 (DeepSeek)');
133 + btn.innerText = '▲';
134 + btn.addEventListener('click', () => toggleHeader());
135 + document.body.appendChild(btn);
136 + return btn;
137 + }
138 +
139 + function getHeader() {
140 + return document.querySelector('#page-header') || document.querySelector('header') || document.querySelector('.page-header');
141 + }
142 +
143 + function toggleHeader(forceState) {
144 + const header = getHeader();
145 + if (!header) return;
146 +
147 + const shouldCollapse = typeof forceState === 'boolean' ? forceState : !header.classList.contains('collapsed');
148 + header.classList.toggle('collapsed', shouldCollapse);
149 +
150 + try { localStorage.setItem(CONFIG.storageKey, shouldCollapse ? '1' : '0'); } catch (e) {}
47 151
48 - const observer = new MutationObserver(replaceLogo);
152 + const btn = ensureToggle();
153 + btn.innerText = shouldCollapse ? '▼' : '▲';
154 + btn.setAttribute('aria-pressed', shouldCollapse ? 'true' : 'false');
155 + }
156 +
157 + function restoreState() {
158 + try {
159 + const v = localStorage.getItem(CONFIG.storageKey);
160 + if (v === '1') toggleHeader(true);
161 + } catch (e) {}
162 + }
163 +
164 + let debounceTimer = null;
165 + function onDomChanged() {
166 + if (debounceTimer) clearTimeout(debounceTimer);
167 + debounceTimer = setTimeout(() => {
168 + replaceLogo();
169 + ensureToggle();
170 + restoreState();
171 + }, 250);
172 + }
173 +
174 + const observer = new MutationObserver(onDomChanged);
49 175 observer.observe(document.body, { childList: true, subtree: true });
176 +
177 + replaceLogo();
178 + ensureToggle();
179 + restoreState();
180 + window.addEventListener('load', () => setTimeout(onDomChanged, 300));
50 181 })();

doracoin a révisé ce gist 1757401982. Aller à la révision

1 file changed, 3 insertions, 3 deletions

change-gpt-logo.user.js

@@ -1,9 +1,9 @@
1 1 // ==UserScript==
2 2 // @name ChatGPT Logo 换成 DeepSeek (sidebar-header, 自定义尺寸)
3 - // @namespace http://tampermonkey.net/
4 - // @version 1.2
3 + // @namespace https://gist.doracoin.cc/doracoin/39fd3ec77d3044fc95b408bdf6c0ac13
4 + // @version 2025.09.09
5 5 // @description 替换 ChatGPT 左上角 sidebar-header 的 SVG logo 为 DeepSeek logo,并调整 a 标签和 logo 尺寸。
6 - // @author You
6 + // @author Doracoin
7 7 // @match https://chatgpt.com/*
8 8 // @icon https://deepseek.com/favicon.ico
9 9 // @grant none

doracoin a révisé ce gist 1757401780. Aller à la révision

1 file changed, 0 insertions, 0 deletions

change-gpt-logo.js renommé en change-gpt-logo.user.js

Fichier renommé sans modifications

doracoin a révisé ce gist 1757401576. Aller à la révision

1 file changed, 50 insertions

change-gpt-logo.js(fichier créé)

@@ -0,0 +1,50 @@
1 + // ==UserScript==
2 + // @name ChatGPT Logo 换成 DeepSeek (sidebar-header, 自定义尺寸)
3 + // @namespace http://tampermonkey.net/
4 + // @version 1.2
5 + // @description 替换 ChatGPT 左上角 sidebar-header 的 SVG logo 为 DeepSeek logo,并调整 a 标签和 logo 尺寸。
6 + // @author You
7 + // @match https://chatgpt.com/*
8 + // @icon https://deepseek.com/favicon.ico
9 + // @grant none
10 + // ==/UserScript==
11 +
12 + (function() {
13 + 'use strict';
14 +
15 + const deepseekLogoUrl = 'https://commons.wikimedia.org/wiki/Special:Redirect/file/DeepSeek_logo.svg';
16 +
17 + function replaceLogo() {
18 + const link = document.querySelector('#sidebar-header a');
19 + if (link && !link.classList.contains("deepseek-logo-replaced")) {
20 + // 修改 a 标签 class
21 + if (link.classList.contains("h-9")) {
22 + link.classList.remove("h-9");
23 + link.classList.add("h-10");
24 + }
25 + if (link.classList.contains("w-9")) {
26 + link.classList.remove("w-9");
27 + link.classList.add("w-68");
28 + }
29 +
30 + // 清空原始内容(ChatGPT 内联 SVG)
31 + link.innerHTML = '';
32 +
33 + // 插入 DeepSeek logo
34 + const img = document.createElement('img');
35 + img.src = deepseekLogoUrl;
36 + img.alt = "DeepSeek";
37 + img.style.width = "145px";
38 + img.style.height = "31px";
39 + img.style.objectFit = "contain";
40 +
41 + link.appendChild(img);
42 + link.classList.add("deepseek-logo-replaced");
43 + }
44 + }
45 +
46 + replaceLogo();
47 +
48 + const observer = new MutationObserver(replaceLogo);
49 + observer.observe(document.body, { childList: true, subtree: true });
50 + })();
Plus récent Plus ancien