cjc0013 commited on
Commit
82bfb41
·
verified ·
1 Parent(s): 92277ab

Delete chat-traffic-gate-leader-softcap

Browse files
chat-traffic-gate-leader-softcap/background.js DELETED
@@ -1,227 +0,0 @@
1
- // background.js — Firefox MV3 event page
2
- // Tight history gating: only cancel true pagination. No blanket GET cancels.
3
- // Leader/follower model: only the active GPT tab runs keepalive pings.
4
-
5
- const api = (typeof browser !== 'undefined') ? browser : chrome;
6
-
7
- let cfg = { blockHistory: true, debug: false };
8
- const intent = new Map(); // tabId -> bool (user intends history load)
9
- const allowUntil = new Map(); // tabId -> ms timestamp
10
-
11
- const GPT_URLS = ['https://chat.openai.com/*', 'https://chatgpt.com/*'];
12
- const GPT_HOST_RE = /^(chat\.openai\.com|chatgpt\.com)$/;
13
-
14
- let leaderTabId = null;
15
-
16
- function isGptUrl(url) {
17
- try {
18
- const u = new URL(url);
19
- return GPT_HOST_RE.test(u.hostname);
20
- } catch { return false; }
21
- }
22
-
23
- async function getActiveTabId() {
24
- try {
25
- const tabs = await api.tabs.query({ active: true, currentWindow: true });
26
- if (!tabs || !tabs.length) return null;
27
- const t = tabs[0];
28
- if (t && typeof t.id === 'number' && isGptUrl(t.url || '')) return t.id;
29
- } catch {}
30
- return null;
31
- }
32
-
33
- async function setLeader(tabId) {
34
- try {
35
- const newLeader = (typeof tabId === 'number') ? tabId : await getActiveTabId();
36
- if (newLeader === leaderTabId) return;
37
-
38
- const oldLeader = leaderTabId;
39
- leaderTabId = newLeader;
40
-
41
- // Tell old leader to stand down
42
- if (typeof oldLeader === 'number') {
43
- api.tabs.sendMessage(oldLeader, { type: 'tgRole', role: 'follower' }).catch(()=>{});
44
- }
45
- // Tell new leader to take over
46
- if (typeof leaderTabId === 'number') {
47
- api.tabs.sendMessage(leaderTabId, { type: 'tgRole', role: 'leader' }).catch(()=>{});
48
- }
49
- } catch {}
50
- }
51
-
52
- // Wake the event page periodically (Firefox MV3 event page)
53
- try { api.alarms?.create('tg-ping', { periodInMinutes: 4 }); } catch {}
54
-
55
- (async () => {
56
- try {
57
- const got = await api.storage.local.get({ blockHistory: true, debug: false });
58
- cfg.blockHistory = !!got.blockHistory;
59
- cfg.debug = !!got.debug;
60
- } catch {}
61
- // Establish an initial leader if a GPT tab is already active
62
- await setLeader(null);
63
- })();
64
-
65
- api.storage.onChanged.addListener((c, area) => {
66
- if (area !== 'local') return;
67
- if (c.blockHistory) cfg.blockHistory = !!c.blockHistory.newValue;
68
- if (c.debug) cfg.debug = !!c.debug.newValue;
69
- });
70
-
71
- // Cleanup per-tab state to avoid stale intent/timers.
72
- try {
73
- api.tabs?.onRemoved?.addListener((tabId) => {
74
- try { intent.delete(tabId); } catch {}
75
- try { allowUntil.delete(tabId); } catch {}
76
- if (leaderTabId === tabId) {
77
- leaderTabId = null;
78
- setLeader(null);
79
- }
80
- });
81
-
82
- api.tabs?.onUpdated?.addListener((tabId, changeInfo, tab) => {
83
- try {
84
- if (!changeInfo) return;
85
-
86
- // If the tab navigates away from GPT, clear state
87
- if (changeInfo.url && !isGptUrl(changeInfo.url)) {
88
- intent.delete(tabId);
89
- allowUntil.delete(tabId);
90
- if (leaderTabId === tabId) {
91
- leaderTabId = null;
92
- setLeader(null);
93
- }
94
- }
95
-
96
- // If this tab becomes active and is GPT, promote to leader
97
- if (tab && tab.active && isGptUrl(tab.url || changeInfo.url || '')) {
98
- setLeader(tabId);
99
- }
100
- } catch {}
101
- });
102
-
103
- api.tabs?.onActivated?.addListener(async (info) => {
104
- try {
105
- const tab = await api.tabs.get(info.tabId);
106
- if (tab && isGptUrl(tab.url || '')) await setLeader(info.tabId);
107
- } catch {}
108
- });
109
- } catch {}
110
-
111
- // Background ping (best-effort) — only when at least one GPT tab exists.
112
- async function anyGptTabsOpen() {
113
- try {
114
- const tabs = await api.tabs.query({ url: GPT_URLS });
115
- return !!(tabs && tabs.length);
116
- } catch { return false; }
117
- }
118
-
119
- async function bgPingOnce(url) {
120
- try {
121
- const ctl = new AbortController();
122
- const t = setTimeout(() => { try { ctl.abort(); } catch {} }, 6000);
123
- const res = await fetch(url, { method: 'GET', cache: 'no-store', credentials: 'include', signal: ctl.signal });
124
- clearTimeout(t);
125
- return !!res;
126
- } catch { return false; }
127
- }
128
-
129
- try {
130
- api.alarms?.onAlarm?.addListener(async (a) => {
131
- if (!a || a.name !== 'tg-ping') return;
132
- if (!(await anyGptTabsOpen())) return;
133
-
134
- // Ping both; whichever has cookies will work. Ignore failures.
135
- await bgPingOnce('https://chatgpt.com/api/auth/session');
136
- await bgPingOnce('https://chat.openai.com/api/auth/session');
137
- });
138
- } catch {}
139
-
140
- api.runtime.onMessage.addListener((msg, sender) => {
141
- const tabId = sender?.tab?.id;
142
- if (typeof tabId !== 'number') return;
143
- try {
144
- if (msg?.type === 'historyIntent') {
145
- intent.set(tabId, !!msg.value);
146
- } else if (msg?.type === 'toggleBlockHistory') {
147
- cfg.blockHistory = !!msg.value;
148
- api.storage.local.set({ blockHistory: cfg.blockHistory });
149
- } else if (msg?.type === 'requestStatus') {
150
- const role = (leaderTabId === tabId) ? 'leader' : 'follower';
151
- return Promise.resolve({
152
- blockHistory: cfg.blockHistory,
153
- intent: !!intent.get(tabId),
154
- allowUntil: allowUntil.get(tabId) || 0,
155
- role
156
- });
157
- } else if (msg?.type === 'allowHistoryForMs') {
158
- const ms = Math.max(2000, Math.min(60000, Number(msg.ms) || 10000));
159
- const until = Date.now() + ms;
160
- allowUntil.set(tabId, until);
161
- setTimeout(() => {
162
- if ((allowUntil.get(tabId) || 0) <= Date.now()) allowUntil.delete(tabId);
163
- }, ms + 250);
164
- } else if (msg?.type === 'becomeLeader') {
165
- // Optional: content can request leadership if it is the visible tab.
166
- setLeader(tabId);
167
- }
168
- } catch (e) {
169
- console.warn('[TrafficGate] bg onMessage error', e);
170
- }
171
- });
172
-
173
- function hasPagination(u) {
174
- try {
175
- const q = u.searchParams;
176
- if (q.has('cursor') || q.has('before')) return true;
177
- if (q.has('offset') && Number(q.get('offset')) > 0) return true;
178
- if (q.has('page') && Number(q.get('page')) > 1) return true;
179
- const dir = (q.get('direction') || '').toLowerCase();
180
- if (/back|prev|previous/.test(dir)) return true;
181
- } catch {}
182
- return false;
183
- }
184
-
185
- function isHistoryLoad(details) {
186
- try {
187
- const u = new URL(details.url);
188
- if (!GPT_HOST_RE.test(u.hostname)) return false;
189
- const method = (details.method || 'GET').toUpperCase();
190
- if (method !== 'GET' && method !== 'POST') return false;
191
-
192
- const p = u.pathname.toLowerCase();
193
-
194
- // Allow-list some essentials outright
195
- if (/\/api\/auth\/session$/.test(p)) return false;
196
- if (/\/backend-api\/models$/.test(p)) return false;
197
-
198
- // Consider "history-like" paths but only block when explicit pagination shows up
199
- const looksHistoryPath = /(backend-api\/conversation|backend-api\/conversations|backend-api\/messages|\/history|\/messages|\/conversation|\/threads|\/graphql|\/gql|\/v1\/messages|\/v1\/threads)/.test(p);
200
- if (!looksHistoryPath) return false;
201
-
202
- // Only treat as history when pagination markers are present
203
- return hasPagination(u);
204
- } catch { return false; }
205
- }
206
-
207
- try {
208
- api.webRequest?.onBeforeRequest.addListener(
209
- (details) => {
210
- try {
211
- if (!cfg.blockHistory) return {};
212
- if (details.type !== 'xmlhttprequest' && details.type !== 'fetch') return {};
213
- const tabId = details.tabId;
214
- const now = Date.now();
215
- const okByTimer = (allowUntil.get(tabId) || 0) > now;
216
- const okByIntent = !!intent.get(tabId);
217
- if (!okByTimer && !okByIntent && isHistoryLoad(details)) {
218
- if (cfg.debug) console.log('[TrafficGate] CANCEL', details.url);
219
- return { cancel: true };
220
- }
221
- } catch (e) { console.warn('[TrafficGate] onBeforeRequest', e); }
222
- return {};
223
- },
224
- { urls: ['https://chat.openai.com/*', 'https://chatgpt.com/*'] },
225
- ['blocking', 'requestBody']
226
- );
227
- } catch {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
chat-traffic-gate-leader-softcap/content/autopilot.js DELETED
@@ -1,118 +0,0 @@
1
- // content/autopilot.js — visible-tab autopilot only (reduces background overhead)
2
-
3
- (function () {
4
- 'use strict';
5
- const api = (typeof browser !== 'undefined') ? browser : chrome;
6
-
7
- const stats = { cancels: 0, disconnects: 0, longtasks: 0, lastTurnCount: 0 };
8
- const cfg = { topPx: 180, minTopPx: 80, softcapKeep: 60, minKeep: 30 };
9
-
10
- Object.defineProperty(window, '__tgTelemetry', {
11
- value: function (event, data) {
12
- try {
13
- if (event === 'historyCancel') stats.cancels++;
14
- else if (event === 'disconnect') stats.disconnects++;
15
- else if (event === 'turnCount' && typeof data?.count === 'number') stats.lastTurnCount = data.count;
16
- } catch {}
17
- },
18
- writable: false, configurable: false, enumerable: false
19
- });
20
-
21
- let po = null;
22
- function startLongTaskObserver() {
23
- try {
24
- if (po) return;
25
- po = new PerformanceObserver((list) => {
26
- for (const e of list.getEntries()) if (e.duration >= 200) stats.longtasks++;
27
- });
28
- po.observe({ entryTypes: ['longtask'] });
29
- } catch { po = null; }
30
- }
31
- function stopLongTaskObserver() {
32
- try { if (po) po.disconnect(); } catch {}
33
- po = null;
34
- }
35
-
36
- let lastScrollTop = 0;
37
- let lastUpAt = 0;
38
- let scrollHandler = null;
39
- let tuneTimer = null;
40
- let intentTimer = null;
41
-
42
- function updateIntent() {
43
- if (document.visibilityState !== 'visible') return;
44
- const sc = document.scrollingElement || document.documentElement;
45
- const st = sc.scrollTop || 0;
46
- const now = Date.now();
47
- if (st < lastScrollTop - 2) lastUpAt = now;
48
- lastScrollTop = st;
49
-
50
- const nearTop = (st < cfg.topPx);
51
- const recentUp = (now - lastUpAt) < 1500;
52
- const allow = !!(nearTop || recentUp);
53
-
54
- try { window.__chatTrafficGate?.setIntent(allow); } catch {}
55
- api.runtime.sendMessage({ type: 'historyIntent', value: allow }).catch(()=>{});
56
- }
57
-
58
- async function tune() {
59
- if (document.visibilityState !== 'visible') return;
60
- const cancels = stats.cancels, disc = stats.disconnects, jank = stats.longtasks, turns = stats.lastTurnCount;
61
- stats.cancels = stats.disconnects = stats.longtasks = 0;
62
-
63
- if (disc >= 2) {
64
- try { window.__chatKeepalive?.setMinutes(3); } catch {}
65
- try { window.__chatKeepalive?.setAutoReconnect(true); } catch {}
66
- try { window.__chatKeepalive?.setAllowReloads(true); } catch {}
67
- }
68
- if (jank >= 4 || (turns && turns > cfg.softcapKeep + 10)) {
69
- cfg.softcapKeep = Math.max(cfg.minKeep, (cfg.softcapKeep || 60) - 10);
70
- try { window.__chatSoftCap?.setConfig({ enabled: true, keep: cfg.softcapKeep }); } catch {}
71
- }
72
- if (cancels >= 20) cfg.topPx = Math.max(cfg.minTopPx, cfg.topPx - 20);
73
-
74
- if (disc === 0 && jank <= 1 && cancels < 5) {
75
- if ((cfg.softcapKeep || 60) < 60) {
76
- cfg.softcapKeep = Math.min(60, (cfg.softcapKeep || 60) + 10);
77
- try { window.__chatSoftCap?.setConfig({ enabled: true, keep: cfg.softcapKeep }); } catch {}
78
- }
79
- if (cfg.topPx < 180) cfg.topPx += 10;
80
- try { window.__chatKeepalive?.setMinutes(4); } catch {}
81
- try { window.__chatKeepalive?.setAllowReloads(false); } catch {}
82
- }
83
- }
84
-
85
- function startVisibleMode() {
86
- startLongTaskObserver();
87
-
88
- if (!scrollHandler) {
89
- scrollHandler = () => updateIntent();
90
- window.addEventListener('scroll', scrollHandler, { passive: true });
91
- }
92
- if (!intentTimer) intentTimer = setInterval(updateIntent, 2000);
93
- if (!tuneTimer) tuneTimer = setInterval(tune, 40000);
94
-
95
- updateIntent();
96
- setTimeout(tune, 5000);
97
- }
98
-
99
- function stopVisibleMode() {
100
- stopLongTaskObserver();
101
- if (scrollHandler) {
102
- try { window.removeEventListener('scroll', scrollHandler); } catch {}
103
- scrollHandler = null;
104
- }
105
- if (intentTimer) { clearInterval(intentTimer); intentTimer = null; }
106
- if (tuneTimer) { clearInterval(tuneTimer); tuneTimer = null; }
107
- try { window.__chatTrafficGate?.setIntent(false); } catch {}
108
- api.runtime.sendMessage({ type: 'historyIntent', value: false }).catch(()=>{});
109
- }
110
-
111
- document.addEventListener('visibilitychange', () => {
112
- if (document.visibilityState === 'visible') startVisibleMode();
113
- else stopVisibleMode();
114
- }, { passive: true });
115
-
116
- if (document.visibilityState === 'visible') startVisibleMode();
117
- else stopVisibleMode();
118
- })();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
chat-traffic-gate-leader-softcap/content/dom-softcap.js DELETED
@@ -1,161 +0,0 @@
1
- // content/dom-softcap.js — dynamic softcap per tab visibility (active vs background)
2
-
3
- (function () {
4
- 'use strict';
5
- const SELECTOR_TURN = '[data-testid^="conversation-turn-"]';
6
- const state = {
7
- enabled: true,
8
- keep: 60, // current effective keep
9
- keepActive: 60, // when tab is visible
10
- keepHidden: 20, // when tab is hidden
11
- keepDeepHidden: 12, // after being hidden for a while
12
- deepHiddenAfterMs: 10 * 60 * 1000,
13
- hiddenSince: null,
14
- container: null,
15
- observer: null,
16
- firstDone: false,
17
- dirty: true,
18
- lastTrim: 0
19
- };
20
-
21
- const tlog = (...args) => { try { window.__tgTelemetry?.apply(null, args); } catch {} };
22
-
23
- Object.defineProperty(window, '__chatSoftCap', {
24
- value: {
25
- setConfig: (cfg) => {
26
- if (!cfg || typeof cfg !== 'object') return;
27
- if (typeof cfg.enabled === 'boolean') state.enabled = cfg.enabled;
28
- if (typeof cfg.keep === 'number' && isFinite(cfg.keep)) state.keepActive = Math.max(20, Math.min(300, Math.floor(cfg.keep)));
29
- if (typeof cfg.keepHidden === 'number' && isFinite(cfg.keepHidden)) state.keepHidden = Math.max(10, Math.min(200, Math.floor(cfg.keepHidden)));
30
- if (typeof cfg.keepDeepHidden === 'number' && isFinite(cfg.keepDeepHidden)) state.keepDeepHidden = Math.max(5, Math.min(100, Math.floor(cfg.keepDeepHidden)));
31
- state.dirty = true;
32
- applyMode();
33
- schedule(30);
34
- }
35
- },
36
- writable: false, configurable: false, enumerable: false
37
- });
38
-
39
- function applyMode() {
40
- const vis = document.visibilityState;
41
- const now = Date.now();
42
- if (vis === 'hidden') {
43
- if (!state.hiddenSince) state.hiddenSince = now;
44
- const deep = (now - state.hiddenSince) >= state.deepHiddenAfterMs;
45
- state.keep = deep ? state.keepDeepHidden : state.keepHidden;
46
- } else {
47
- state.hiddenSince = null;
48
- state.keep = state.keepActive;
49
- }
50
- }
51
-
52
- function findContainer() {
53
- const first = document.querySelector(SELECTOR_TURN);
54
- if (!first) return null;
55
- let p = first.parentElement;
56
- while (p && p !== document.body) {
57
- const kids = Array.from(p.children).filter((el) => el.nodeType === 1);
58
- if (kids.length && kids.every((el) => el.matches(SELECTOR_TURN))) return p;
59
- p = p.parentElement;
60
- }
61
- return first.parentElement || null;
62
- }
63
-
64
- function isPure(node) {
65
- if (!node) return false;
66
- const kids = Array.from(node.children).filter((el) => el.nodeType === 1);
67
- return kids.length && kids.every((el) => el.matches(SELECTOR_TURN));
68
- }
69
-
70
- function nodes() {
71
- if (!state.container) return [];
72
- return Array.from(state.container.querySelectorAll(SELECTOR_TURN));
73
- }
74
-
75
- function doTrimWork() {
76
- if (!state.enabled || !state.container) return;
77
- applyMode();
78
-
79
- const list = nodes();
80
- const tot = list.length;
81
-
82
- tlog('turnCount', { count: tot, keep: state.keep, vis: document.visibilityState });
83
-
84
- const extra = tot - state.keep;
85
- if (extra > 0) {
86
- const cutoff = tot - state.keep;
87
- const keep = list.slice(cutoff);
88
- const old = state.container.style.display;
89
- state.container.style.display = 'none';
90
- if (isPure(state.container)) {
91
- state.container.replaceChildren(...keep);
92
- } else {
93
- for (let i = 0; i < cutoff; i++) list[i].remove();
94
- }
95
- state.container.style.display = old;
96
- tlog('trim', { removed: cutoff, kept: state.keep });
97
- }
98
-
99
- state.lastTrim = Date.now();
100
- state.dirty = false;
101
-
102
- if (!state.firstDone) {
103
- state.firstDone = true;
104
- try { window.dispatchEvent(new Event('tg-unshield')); } catch {}
105
- }
106
- }
107
-
108
- function trim() { try { doTrimWork(); } catch {} }
109
-
110
- let t = null;
111
- function schedule(ms = 0) {
112
- if (t) clearTimeout(t);
113
- t = setTimeout(() => {
114
- try {
115
- if ('requestIdleCallback' in window) {
116
- requestIdleCallback(() => trim(), { timeout: 1200 });
117
- } else {
118
- trim();
119
- }
120
- } catch { trim(); }
121
- }, ms);
122
- }
123
-
124
- function watch() {
125
- const c = findContainer();
126
- if (!c) return;
127
- if (state.container !== c) {
128
- if (state.observer) try { state.observer.disconnect(); } catch {}
129
- state.container = c;
130
- state.dirty = true;
131
- state.observer = new MutationObserver(() => { state.dirty = true; schedule(40); });
132
- state.observer.observe(state.container, { childList: true });
133
- schedule(80);
134
- }
135
- }
136
-
137
- function heartbeat() {
138
- watch();
139
- if (state.dirty) schedule(80);
140
- }
141
-
142
- document.addEventListener('visibilitychange', () => {
143
- applyMode();
144
- state.dirty = true;
145
- schedule(120);
146
- }, { passive: true });
147
-
148
- if (document.readyState === 'loading') {
149
- document.addEventListener('DOMContentLoaded', () => {
150
- watch();
151
- applyMode();
152
- schedule(160);
153
- setInterval(heartbeat, 2000);
154
- }, { once: true });
155
- } else {
156
- watch();
157
- applyMode();
158
- schedule(160);
159
- setInterval(heartbeat, 2000);
160
- }
161
- })();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
chat-traffic-gate-leader-softcap/content/early-shield.js DELETED
@@ -1,30 +0,0 @@
1
- // content/early-shield.js — document_start CSS shield (auto-unshields safely)
2
-
3
- (() => {
4
- try {
5
- const style = document.createElement('style');
6
- style.id = 'tg-early-shield';
7
- style.textContent = `
8
- html.tg-shield [data-testid^="conversation-turn-"] { display: none !important; }
9
- html.tg-shield [data-testid="conversation-turns"] { visibility: hidden !important; }
10
- `;
11
- document.documentElement.classList.add('tg-shield');
12
- document.documentElement.appendChild(style);
13
-
14
- // Safety valve: auto-unshield after 2.5s even if no trim fired
15
- setTimeout(() => {
16
- try {
17
- document.documentElement.classList.remove('tg-shield');
18
- style.remove();
19
- } catch {}
20
- }, 2500);
21
-
22
- // Preferred path: listen for explicit unshield event
23
- window.addEventListener('tg-unshield', () => {
24
- try {
25
- document.documentElement.classList.remove('tg-shield');
26
- style.remove();
27
- } catch {}
28
- }, { once: true });
29
- } catch {}
30
- })();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
chat-traffic-gate-leader-softcap/content/keepalive.js DELETED
@@ -1,195 +0,0 @@
1
- // content/keepalive.js — keep session warm; leader-only pinger; no auto-discard
2
-
3
- (function() {
4
- 'use strict';
5
- const api = (typeof browser !== 'undefined') ? browser : chrome;
6
- const tlog = (...args) => { try { window.__tgTelemetry?.apply(null, args); } catch {} };
7
-
8
- const state = {
9
- enabled: true, // overall module on/off
10
- pingEnabled: false, // leader-only pings (big reducer when many tabs)
11
- role: 'follower', // 'leader' | 'follower'
12
- minutes: 4,
13
- autoReconnect: true,
14
- allowReloads: false, // SAFE DEFAULT: off
15
- lastReload: 0,
16
- chosenPath: null
17
- };
18
-
19
- Object.defineProperty(window, '__chatKeepalive', {
20
- value: {
21
- setEnabled(v){ state.enabled = !!v; schedule(); },
22
- setMinutes(m){ m = Math.max(2, Math.min(30, Math.floor(m||state.minutes))); state.minutes = m; schedule(); },
23
- setAutoReconnect(v){ state.autoReconnect = !!v; },
24
- setAllowReloads(v){ state.allowReloads = !!v; },
25
- setPingEnabled(v){ state.pingEnabled = !!v; schedule(); },
26
- setRole(r){
27
- state.role = (r === 'leader') ? 'leader' : 'follower';
28
- state.pingEnabled = (state.role === 'leader');
29
- schedule();
30
- },
31
- reconnectNow(){ tryClickRetry() || (state.allowReloads && softReload()); }
32
- },
33
- writable: false, configurable: false, enumerable: false
34
- });
35
-
36
- // Role updates from background
37
- try {
38
- api.runtime.onMessage.addListener((msg) => {
39
- if (msg?.type === 'tgRole') {
40
- try { window.__chatKeepalive?.setRole(msg.role); } catch {}
41
- }
42
- });
43
- } catch {}
44
-
45
- (async () => {
46
- try {
47
- const got = await api.storage.local.get({
48
- keepaliveEnabled: true,
49
- keepaliveMinutes: 4,
50
- autoReconnect: true,
51
- allowReloads: false
52
- });
53
- state.enabled = !!got.keepaliveEnabled;
54
- state.minutes = Number(got.keepaliveMinutes) || 4;
55
- state.autoReconnect = !!got.autoReconnect;
56
- state.allowReloads = !!got.allowReloads;
57
- } catch {}
58
-
59
- // Ask background who we are. If visible and background hasn't elected yet,
60
- // briefly act as leader to keep the session warm until the role message arrives.
61
- try {
62
- const resp = await api.runtime.sendMessage({ type: 'requestStatus' });
63
- if (resp?.role) {
64
- state.role = resp.role;
65
- state.pingEnabled = (resp.role === 'leader');
66
- } else {
67
- state.pingEnabled = (document.visibilityState === 'visible');
68
- }
69
- } catch {
70
- state.pingEnabled = (document.visibilityState === 'visible');
71
- }
72
-
73
- // If visible, nudge background to elect us leader.
74
- if (document.visibilityState === 'visible') {
75
- api.runtime.sendMessage({ type: 'becomeLeader' }).catch(()=>{});
76
- }
77
-
78
- schedule();
79
- })();
80
-
81
- async function pickEndpoint() {
82
- const candidates = [
83
- '/api/auth/session',
84
- '/backend-api/models',
85
- '/backend-api/conversations?offset=0&limit=1',
86
- '/favicon.ico',
87
- '/'
88
- ];
89
- for (const path of candidates) { try { if (await headOrGet(path)) return path; } catch {} }
90
- return '/';
91
- }
92
-
93
- async function headOrGet(path) {
94
- const url = new URL(path, location.origin).toString();
95
- try {
96
- const ctl = new AbortController(); const t = setTimeout(()=>ctl.abort(), 6000);
97
- const res = await fetch(url, { method: 'HEAD', cache: 'no-store', credentials: 'include', keepalive: true, signal: ctl.signal });
98
- clearTimeout(t);
99
- return !!res && (res.ok || res.type === 'opaqueredirect');
100
- } catch {}
101
- try {
102
- const ctl = new AbortController(); const t = setTimeout(()=>ctl.abort(), 6000);
103
- const res = await fetch(url, { method: 'GET', cache: 'no-store', credentials: 'include', keepalive: true, signal: ctl.signal, mode: 'same-origin' });
104
- clearTimeout(t);
105
- return !!res && (res.ok || res.type === 'opaqueredirect');
106
- } catch {}
107
- try {
108
- if (document.visibilityState !== 'visible' && 'sendBeacon' in navigator) {
109
- const blob = new Blob([], { type: 'application/octet-stream' });
110
- navigator.sendBeacon(url, blob);
111
- return true;
112
- }
113
- } catch {}
114
- return false;
115
- }
116
-
117
- let timer = null;
118
- let visListenerAdded = false;
119
-
120
- function schedule() {
121
- if (timer) clearInterval(timer);
122
- if (!state.enabled || !state.pingEnabled) return;
123
-
124
- const base = Math.max(2, Math.min(30, state.minutes));
125
- const jitter = 0.25 + Math.random() * 0.25;
126
- const ms = Math.floor(base * jitter * 60000);
127
- timer = setInterval(ping, ms);
128
-
129
- if (!visListenerAdded) {
130
- visListenerAdded = true;
131
- document.addEventListener('visibilitychange', () => {
132
- if (document.visibilityState === 'visible') {
133
- api.runtime.sendMessage({ type: 'becomeLeader' }).catch(()=>{});
134
- if (state.role !== 'leader') { state.pingEnabled = true; schedule(); }
135
- setTimeout(ping, 1200);
136
- } else {
137
- if (state.role !== 'leader') { state.pingEnabled = false; schedule(); }
138
- }
139
- }, { passive: true });
140
- }
141
-
142
- setTimeout(ping, 3000);
143
- }
144
-
145
- async function ping() {
146
- if (!state.enabled || !state.pingEnabled) return;
147
- if (!state.chosenPath) state.chosenPath = await pickEndpoint();
148
- try { await headOrGet(state.chosenPath); tlog('ping', { role: state.role }); } catch {}
149
- }
150
-
151
- function visible() { return document.visibilityState === 'visible'; }
152
- function notTyping() {
153
- const ae = document.activeElement;
154
- return !(ae && (ae.tagName === 'TEXTAREA' || (ae.tagName === 'INPUT' && /text|search|url|email|password/.test(ae.type||''))));
155
- }
156
-
157
- function tryClickRetry() {
158
- const labels = ['reload','retry','try again','reconnect'];
159
- const btns = Array.from(document.querySelectorAll('button, a[role="button"]'));
160
- for (const b of btns) {
161
- const t = (b.textContent||'').trim().toLowerCase();
162
- if (labels.some(L => t.includes(L))) { b.click(); tlog('retryClick'); return true; }
163
- }
164
- return false;
165
- }
166
-
167
- function softReload() {
168
- const now = Date.now();
169
- if (now - state.lastReload < 30000) return;
170
- if (!visible() || !notTyping()) return;
171
- state.lastReload = now;
172
- tlog('softReload');
173
- location.reload();
174
- }
175
-
176
- const kw = /(trying to reconnect|attempting to connect|reconnecting|network error|disconnected|lost connection)/i;
177
- const moErr = new MutationObserver((muts) => {
178
- if (!state.autoReconnect) return;
179
- for (const m of muts) for (const n of (m.addedNodes || [])) {
180
- if (n.nodeType === 1) {
181
- const txt = (n.textContent||'').slice(0, 4096);
182
- if (kw.test(txt)) {
183
- tlog('disconnect');
184
- if (!tryClickRetry() && state.allowReloads) setTimeout(softReload, 2500);
185
- return;
186
- }
187
- }
188
- }
189
- });
190
- moErr.observe(document.documentElement || document.body, { childList: true, subtree: true });
191
-
192
- window.addEventListener('online', () => {
193
- if (state.autoReconnect && state.allowReloads) setTimeout(() => { if (!tryClickRetry()) softReload(); }, 1200);
194
- });
195
- })();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
chat-traffic-gate-leader-softcap/content/net-guard.js DELETED
@@ -1,207 +0,0 @@
1
- // content/net-guard.js — document_start guard with SAFE JSON thinning + safer soft-block for list pagination
2
-
3
- (() => {
4
- 'use strict';
5
- const HOSTS = /^(chat\.openai\.com|chatgpt\.com)$/;
6
- const PATHS = /(backend-api\/conversation|backend-api\/conversations|backend-api\/messages|\/history|\/messages|\/conversation|\/threads|\/graphql|\/gql|\/v1\/messages|\/v1\/threads)/i;
7
- const KEEP = 60;
8
-
9
- // Soft-block only on *list-like* pagination endpoints where an empty page is safe.
10
- const SOFT_BLOCK_LIST_PATHS = /(\/backend-api\/conversations\b|\/history\b|\/threads\b|\/v1\/threads\b)/i;
11
-
12
- const api = (typeof browser !== 'undefined') ? browser : chrome;
13
- const gate = { enabled: true, intent: false, allowUntil: 0 };
14
-
15
- const tlog = (...args) => { try { window.__tgTelemetry?.apply(null, args); } catch {} };
16
-
17
- (async () => {
18
- try {
19
- const s = await api.storage.local.get({ blockHistory: true });
20
- gate.enabled = !!s.blockHistory;
21
- } catch {}
22
- try {
23
- const r = await api.runtime.sendMessage({ type: 'requestStatus' });
24
- if (r) { gate.enabled = !!r.blockHistory; gate.intent = !!r.intent; gate.allowUntil = Number(r.allowUntil || 0); }
25
- } catch {}
26
- })();
27
-
28
- Object.defineProperty(window, '__chatTrafficGate', {
29
- value: {
30
- setEnabled(v) { gate.enabled = !!v; },
31
- setIntent(v) { gate.intent = !!v; },
32
- allowForMs(ms) { gate.allowUntil = Date.now() + Math.max(2000, Math.min(60000, Number(ms)||10000)); }
33
- },
34
- writable: false, configurable: false, enumerable: false
35
- });
36
-
37
- function hasPagination(u) {
38
- try {
39
- const q = u.searchParams;
40
- if (q.has('cursor') || q.has('before')) return true;
41
- if (q.has('offset') && Number(q.get('offset')) > 0) return true;
42
- if (q.has('page') && Number(q.get('page')) > 1) return true;
43
- const dir = (q.get('direction') || '').toLowerCase();
44
- if (/back|prev|previous/.test(dir)) return true;
45
- } catch {}
46
- return false;
47
- }
48
-
49
- function looksHistory(url) {
50
- try {
51
- const u = (typeof url === 'string') ? new URL(url, location.href) : (url instanceof URL ? url : null);
52
- if (!u) return false;
53
- if (!HOSTS.test(u.hostname)) return false;
54
- if (!PATHS.test(u.pathname)) return false;
55
- return hasPagination(u);
56
- } catch { return false; }
57
- }
58
-
59
- function shouldBlock(method, url) {
60
- const now = Date.now();
61
- return gate.enabled && (now < gate.allowUntil ? false : !gate.intent) &&
62
- (method === 'GET' || method === 'POST') && looksHistory(url);
63
- }
64
-
65
- function isSoftBlockCandidate(url) {
66
- try {
67
- const u = new URL(url, location.href);
68
- return SOFT_BLOCK_LIST_PATHS.test(u.pathname);
69
- } catch { return false; }
70
- }
71
-
72
- function softBlockResponse(url) {
73
- // Generic empty page response for list-like pagination endpoints.
74
- const body = JSON.stringify({ items: [], has_more: false });
75
- return new Response(body, {
76
- status: 200,
77
- headers: { 'content-type': 'application/json; charset=utf-8' }
78
- });
79
- }
80
-
81
- function thinMappingWithAncestors(data) {
82
- try {
83
- const mapping = data?.mapping;
84
- if (!mapping || typeof mapping !== 'object') return { data, changed: false };
85
- const ids = Object.keys(mapping);
86
- if (ids.length <= KEEP + 10) return { data, changed: false };
87
-
88
- const nodes = ids.map((id) => {
89
- const n = mapping[id] || {};
90
- const t = (n?.message?.create_time || n?.message?.create_time_ms || n?.create_time || 0);
91
- return { id, t: Number(t) || 0 };
92
- }).sort((a, b) => a.t - b.t);
93
-
94
- const recent = nodes.slice(-KEEP).map(x => x.id);
95
- const keepSet = new Set(recent);
96
-
97
- // Always keep current_node chain if present.
98
- const cur = data?.current_node;
99
- if (typeof cur === 'string' && cur in mapping) keepSet.add(cur);
100
-
101
- // Pull ancestor chains for all kept nodes.
102
- const addAncestors = (startId) => {
103
- let id = startId;
104
- let guard = 0;
105
- while (id && guard++ < 500) {
106
- const n = mapping[id];
107
- if (!n) break;
108
- const p = n.parent;
109
- if (!p || typeof p !== 'string') break;
110
- if (keepSet.has(p)) break;
111
- keepSet.add(p);
112
- id = p;
113
- }
114
- };
115
-
116
- for (const id of Array.from(keepSet)) addAncestors(id);
117
-
118
- // If there is an explicit root, keep it.
119
- if (typeof data?.root === 'string' && data.root in mapping) keepSet.add(data.root);
120
-
121
- const newMap = {};
122
- for (const id of keepSet) if (id in mapping) newMap[id] = mapping[id];
123
- data.mapping = newMap;
124
- return { data, changed: true };
125
- } catch {
126
- return { data, changed: false };
127
- }
128
- }
129
-
130
- async function thinIfNeeded(res) {
131
- try {
132
- const ct = res.headers.get('content-type') || '';
133
- if (!/application\/json|json/.test(ct)) return res;
134
- const clone = res.clone();
135
- const data = await clone.json();
136
- let changed = false;
137
-
138
- // Only thin *large* payloads to avoid breaking expectations
139
- if (Array.isArray(data?.messages) && data.messages.length > KEEP + 10) {
140
- data.messages.sort((a, b) => (a.create_time || 0) - (b.create_time || 0));
141
- data.messages = data.messages.slice(-KEEP);
142
- changed = true;
143
- } else if (data?.mapping && typeof data.mapping === 'object') {
144
- const out = thinMappingWithAncestors(data);
145
- changed = changed || out.changed;
146
- } else if (Array.isArray(data?.items) && data.items.length > KEEP + 10) {
147
- data.items = data.items.slice(-KEEP);
148
- changed = true;
149
- }
150
-
151
- if (!changed) return res;
152
- const headers = new Headers(res.headers);
153
- try { headers.delete('content-length'); } catch {}
154
- if (!headers.get('content-type')) headers.set('content-type', 'application/json; charset=utf-8');
155
- const body = JSON.stringify(data);
156
- return new Response(body, { status: res.status, statusText: res.statusText, headers });
157
- } catch {
158
- return res;
159
- }
160
- }
161
-
162
- const _fetch = window.fetch;
163
- if (typeof _fetch === 'function') {
164
- window.fetch = async function patchedFetch(input, init) {
165
- try {
166
- const method = ((init && init.method) || 'GET').toUpperCase();
167
- const url = (input && input.url) ? input.url : String(input);
168
-
169
- if (shouldBlock(method, url)) {
170
- tlog('historyCancel');
171
- // Prefer soft-block for list pagination: keeps UI calmer than an AbortError.
172
- if (isSoftBlockCandidate(url)) return softBlockResponse(url);
173
- const err = new DOMException('Blocked by Chat Traffic Gate', 'AbortError');
174
- return Promise.reject(err);
175
- }
176
-
177
- const p = _fetch.apply(this, arguments);
178
-
179
- // Thin only paginated history responses (when allowed)
180
- if (looksHistory(url)) {
181
- const res = await p;
182
- return thinIfNeeded(res);
183
- }
184
- return p;
185
- } catch {}
186
- return _fetch.apply(this, arguments);
187
- };
188
- }
189
-
190
- const XHR = window.XMLHttpRequest;
191
- if (XHR && XHR.prototype) {
192
- const _open = XHR.prototype.open, _send = XHR.prototype.send;
193
- XHR.prototype.open = function(method, url) {
194
- try { this.__tgMethod = String(method||'GET').toUpperCase(); this.__tgURL = url; } catch {}
195
- return _open.apply(this, arguments);
196
- };
197
- XHR.prototype.send = function(body) {
198
- try {
199
- if (shouldBlock(this.__tgMethod, this.__tgURL)) {
200
- try{ this.abort(); }catch{}; try{ this.dispatchEvent(new Event('error')); }catch{};
201
- tlog('historyCancel'); return;
202
- }
203
- } catch {}
204
- return _send.apply(this, arguments);
205
- };
206
- }
207
- })();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
chat-traffic-gate-leader-softcap/content/traffic-ui.js DELETED
@@ -1,106 +0,0 @@
1
- // content/traffic-ui.js — minimal pill (fixed scope + clearer state)
2
-
3
- (function () {
4
- const api = (typeof browser !== 'undefined') ? browser : chrome;
5
- let status = { blockHistory: true, intent: false, allowUntil: 0 };
6
-
7
- let pill = null;
8
- let hideTimer = null;
9
-
10
- let gateBtn = null;
11
- let allow10Btn = null;
12
- let ledSpan = null;
13
-
14
- function styleBtn(b) {
15
- Object.assign(b.style, {
16
- padding: '4px 8px', borderRadius: '8px',
17
- border: '1px solid #444', background: '#2a2a2a',
18
- color: '#fff', cursor: 'pointer'
19
- });
20
- b.onmouseenter = () => b.style.background = '#333';
21
- b.onmouseleave = () => b.style.background = '#2a2a2a';
22
- }
23
-
24
- function scheduleHide() {
25
- clearTimeout(hideTimer);
26
- hideTimer = setTimeout(() => { pill && (pill.style.opacity = '0.35'); }, 5000);
27
- }
28
-
29
- function ensurePill() {
30
- if (pill && document.body && document.body.contains(pill)) return;
31
-
32
- pill = document.createElement('div');
33
- Object.assign(pill.style, {
34
- position: 'fixed', right: '10px', bottom: '52px', zIndex: 2147483647,
35
- fontFamily: 'ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial',
36
- fontSize: '12px', background: 'rgba(18,18,18,0.9)', color: '#fff',
37
- padding: '8px 10px', borderRadius: '12px', boxShadow: '0 6px 18px rgba(0,0,0,0.35)',
38
- display: 'flex', alignItems: 'center', gap: '10px', userSelect: 'none', opacity: '0.85'
39
- });
40
-
41
- ledSpan = document.createElement('span');
42
- ledSpan.textContent = '🤖 Auto';
43
- ledSpan.title = 'AutoPilot active';
44
-
45
- gateBtn = document.createElement('button');
46
- gateBtn.textContent = '🚦 On';
47
- styleBtn(gateBtn);
48
- gateBtn.title = 'Toggle network gate (AutoPilot respects this)';
49
- gateBtn.addEventListener('click', async () => {
50
- status.blockHistory = !status.blockHistory;
51
- try { window.__chatTrafficGate?.setEnabled(status.blockHistory); } catch {}
52
- try { await api.storage.local.set({ blockHistory: status.blockHistory }); } catch {}
53
- try { await api.runtime.sendMessage({ type: "toggleBlockHistory", value: status.blockHistory }); } catch {}
54
- render();
55
- });
56
-
57
- allow10Btn = document.createElement('button');
58
- styleBtn(allow10Btn);
59
- allow10Btn.textContent = 'Allow 10s';
60
- allow10Btn.title = 'Temporarily allow history for 10 seconds (this tab)';
61
- allow10Btn.addEventListener('click', async () => {
62
- const ms = 10000;
63
- try { window.__chatTrafficGate?.allowForMs(ms); } catch {}
64
- try { await api.runtime.sendMessage({ type: 'allowHistoryForMs', ms }); } catch {}
65
- // Optimistic local timer for UI; background is authoritative.
66
- status.allowUntil = Date.now() + ms;
67
- render();
68
- });
69
-
70
- pill.append(ledSpan, gateBtn, allow10Btn);
71
- document.documentElement.appendChild(pill);
72
-
73
- scheduleHide();
74
- pill.addEventListener('mouseenter', () => { clearTimeout(hideTimer); pill.style.opacity = '1'; });
75
- pill.addEventListener('mouseleave', scheduleHide);
76
- }
77
-
78
- function render() {
79
- if (!pill || !gateBtn) return;
80
- const now = Date.now();
81
- const inAllow = now < (status.allowUntil || 0);
82
-
83
- gateBtn.textContent = status.blockHistory ? '🚦 On' : '🚦 Off';
84
- allow10Btn.textContent = inAllow ? `Allow ${(Math.max(0, Math.ceil((status.allowUntil - now)/1000)))}s` : 'Allow 10s';
85
-
86
- pill.title = inAllow ? 'History temporarily allowed (timer)' : 'History blocked by default';
87
- // Slight visual hint when temporarily allowed.
88
- pill.style.outline = inAllow ? '1px solid rgba(120,220,120,0.65)' : 'none';
89
- }
90
-
91
- async function init() {
92
- ensurePill();
93
- try {
94
- const resp = await api.runtime.sendMessage({ type: "requestStatus" });
95
- if (resp) {
96
- status.blockHistory = !!resp.blockHistory;
97
- status.intent = !!resp.intent;
98
- status.allowUntil = Number(resp.allowUntil || 0);
99
- }
100
- } catch {}
101
- render();
102
- }
103
-
104
- if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init, { once: true });
105
- else init();
106
- })();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
chat-traffic-gate-leader-softcap/manifest.json DELETED
@@ -1,56 +0,0 @@
1
- {
2
- "manifest_version": 3,
3
- "name": "Chat Traffic Gate (ChatGPT) — AutoPilot v2.2 (Safer)",
4
- "version": "0.8.0",
5
- "description": "Stops giant history loads at the network layer, thins large JSONs, caps DOM, keeps sessions warm — with safer defaults and fewer reconnect loops.",
6
- "permissions": [
7
- "storage",
8
- "webRequest",
9
- "webRequestBlocking",
10
- "alarms",
11
- "tabs"
12
- ],
13
- "host_permissions": [
14
- "https://chat.openai.com/*",
15
- "https://chatgpt.com/*"
16
- ],
17
- "background": {
18
- "scripts": [
19
- "background.js"
20
- ]
21
- },
22
- "content_scripts": [
23
- {
24
- "matches": [
25
- "https://chat.openai.com/*",
26
- "https://chatgpt.com/*"
27
- ],
28
- "js": [
29
- "content/early-shield.js",
30
- "content/net-guard.js"
31
- ],
32
- "run_at": "document_start",
33
- "all_frames": false
34
- },
35
- {
36
- "matches": [
37
- "https://chat.openai.com/*",
38
- "https://chatgpt.com/*"
39
- ],
40
- "js": [
41
- "content/dom-softcap.js",
42
- "content/keepalive.js",
43
- "content/autopilot.js",
44
- "content/traffic-ui.js"
45
- ],
46
- "run_at": "document_idle",
47
- "all_frames": false
48
- }
49
- ],
50
- "browser_specific_settings": {
51
- "gecko": {
52
- "id": "chat-traffic-gate@local",
53
- "strict_min_version": "109.0"
54
- }
55
- }
56
- }