cjc0013 commited on
Commit
17ed4c1
·
verified ·
1 Parent(s): 978488a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +58 -115
README.md CHANGED
@@ -1,162 +1,105 @@
1
- ---
2
- license: mit
3
- tags:
4
- - browser-extension
5
- - firefox
6
- - chatgpt
7
- - performance
8
- - memory
9
- ---
10
 
11
- # ChatGPT Traffic Gate (Firefox MV3) — AutoPilot v2.2 (Safer)
 
 
12
 
13
- This repo is **not a dataset** in the normal HF sense. It’s a place to host a **Firefox MV3 extension** that tries to keep ChatGPT usable when you have **lots of tabs** and/or **very long conversations**.
14
 
15
- ## What it does (plain version)
16
 
17
- - **Blocks “load more history” pagination requests** by default (the big ones that spike RAM / lag / churn).
18
- - If history pagination is allowed, it can **thin huge JSON responses** (keeps the latest chunk and the needed ancestors for ChatGPT’s conversation mapping).
19
- - **Soft-caps the chat DOM** by trimming old conversation turns out of the page:
20
- - visible tab: keep ~60 turns
21
- - hidden tab: keep ~20 turns
22
- - hidden for ~10 minutes: keep ~12 turns
23
- - **Keeps the session warm** with low-overhead pings:
24
- - **leader-only** pings from the active tab
25
- - plus a low-frequency **background event-page ping** (single place, not per-tab)
26
- - Adds a tiny **UI pill** so you can quickly toggle the gate or temporarily allow history.
27
 
28
- This does **not** delete your chats on the server. It only changes what loads and what stays in the DOM.
29
 
30
- ---
31
 
32
- ## Repo contents
33
 
34
- You get the extension **two ways**:
35
 
36
- - `chat-traffic-gate-leader-softcap/` unpacked extension folder
37
- - `chat-traffic-gate-leader-softcap.zip` — the same thing, zipped
38
 
39
- Inside the folder:
40
 
41
- - `manifest.json` MV3 manifest (Firefox)
42
- - `background.js` — request gating + leader/follower role assignment + background alarm ping
43
- - `content/early-shield.js` — briefly hides turns at page start, then unshields
44
- - `content/net-guard.js` — patches `fetch` + XHR at `document_start` to block pagination and (when allowed) thin big JSON
45
- - `content/dom-softcap.js` — trims old conversation turns out of the DOM (changes based on tab visibility)
46
- - `content/keepalive.js` — leader-only keepalive pings + reconnect helper (reloads OFF by default)
47
- - `content/autopilot.js` — visible-tab tuning (intent detection + adjusts keepalive/softcap if things look bad)
48
- - `content/traffic-ui.js` — UI pill (“🚦 On/Off” + “Allow 10s”)
49
 
50
- ---
51
 
52
- ## Install (fast / lazy)
53
 
54
- ### Option A — load unpacked folder (recommended)
55
- 1. Download `chat-traffic-gate-leader-softcap.zip` from this repo and unzip it.
56
- 2. In Firefox, open: `about:debugging#/runtime/this-firefox`
57
- 3. Click **Load Temporary Add-on…**
58
- 4. Select the **`manifest.json`** inside the unzipped folder.
59
 
60
- Temporary addons disappear when Firefox restarts (that’s normal).
61
 
62
- ### Option B — use the unpacked folder in the repo
63
- Same process as above, but download the folder contents and point Firefox at `manifest.json`.
64
 
65
- ---
66
 
67
- ## How the “history gate” works
68
 
69
- ### Background layer (webRequest)
70
- `background.js` uses `webRequestBlocking` to cancel only **true pagination** requests:
71
- - it looks for query params like `cursor`, `before`, `offset>0`, `page>1`, or backward direction markers
72
- - it only applies to “history-like” endpoints
73
- - it avoids blanket blocking (session and models endpoints are allow-listed)
74
 
75
- ### Page layer (fetch/XHR patch)
76
- `content/net-guard.js` runs at `document_start` and patches:
77
- - `window.fetch`
78
- - `XMLHttpRequest`
79
 
80
- If a request is a paginated history load **and** you didn’t indicate intent:
81
- - some list endpoints get a **safe empty page JSON** (soft-block)
82
- - others get an AbortError / aborted XHR (hard-block)
83
 
84
- ### Intent + temporary allow
85
- The extension decides “intent” mostly from **scroll behavior**:
86
- - near the top, or scrolling upward recently → intent = true
87
- - otherwise intent = false
88
 
89
- You can also force allow pagination for a short window:
90
- - UI pill: **Allow 10s**
91
- - programmatic: `__chatTrafficGate.allowForMs(10000)`
92
 
93
- ---
94
 
95
- ## JSON thinning (what it actually does)
96
 
97
- Only when a request is a **paginated history request** (the same pagination detection as above), it may thin JSON:
98
- - if `messages[]` is huge → keep the newest ~60
99
- - if `items[]` is huge → keep the newest ~60
100
- - if ChatGPT’s `mapping{}` is huge → keep the newest ~60 nodes **plus ancestors** (and keep `current_node` / `root` when present)
101
 
102
- Goal: reduce payload size while keeping the mapping structurally coherent.
103
 
104
- ---
105
 
106
- ## DOM soft-cap (memory control)
107
 
108
- The softcap script trims old turn nodes from the DOM using:
109
 
110
- - selector: `[data-testid^="conversation-turn-"]`
111
 
112
- It tries to keep the UI stable by:
113
- - trimming in batches
114
- - briefly hiding the container while trimming to reduce layout thrash
115
- - unshielding the early CSS shield once the first trim completes
116
 
117
- ---
118
 
119
- ## Keepalive + reconnect behavior
120
 
121
- ### Leader-only pings
122
- Only the **active tab** is intended to be “leader” and run keepalive pings. Background assigns roles and tells tabs to switch.
123
 
124
- ### Endpoints it tries
125
- It probes a small set and sticks with the first one that works, e.g.:
126
- - `/api/auth/session`
127
- - `/backend-api/models`
128
- - `/backend-api/conversations?offset=0&limit=1`
129
- - `/favicon.ico`
130
- - `/`
131
 
132
- ### Reconnect helper
133
- It watches the DOM for text like “reconnecting / disconnected / network error” and tries:
134
- - click buttons with text like “Retry / Reconnect / Try again”
135
- - **reload is OFF by default** (AutoPilot may enable it temporarily if disconnects are bad)
136
 
137
- ---
138
 
139
- ## UI controls
140
 
141
- A small pill appears on the page:
142
 
143
- - **🚦 On / Off**: toggles history gating
144
- - **Allow 10s**: allows pagination for 10 seconds in that tab
145
 
146
- ---
147
 
148
- ## Dev / power-user globals
149
 
150
- These are intentionally exposed by the scripts:
151
 
152
- ```js
153
- __chatTrafficGate.setEnabled(true|false)
154
- __chatTrafficGate.setIntent(true|false)
155
- __chatTrafficGate.allowForMs(10000)
156
 
157
- __chatSoftCap.setConfig({ enabled: true, keep: 60, keepHidden: 20, keepDeepHidden: 12 })
 
 
 
 
 
 
 
 
158
 
159
- __chatKeepalive.setMinutes(4)
160
- __chatKeepalive.setAutoReconnect(true)
161
- __chatKeepalive.setAllowReloads(false)
162
- __chatKeepalive.reconnectNow()
 
1
+ Chat Traffic Gate (ChatGPT) — AutoPilot v3.1 - UPDATED VERSION
2
+ Status
 
 
 
 
 
 
 
3
 
4
+ WIP (work in progress).
5
+ This is not perfect and still changing.
6
+ It might help your workflow, or it might not. Use it if you want.
7
 
8
+ I use this myself, and I notice when it is not running.
9
 
10
+ What this is
11
 
12
+ A Firefox browser extension focused on ChatGPT tabs, built to help manage heavy/long sessions with a traffic-gating approach.
 
 
 
 
 
 
 
 
 
13
 
14
+ Current extension metadata and scope:
15
 
16
+ Name: Chat Traffic Gate (ChatGPT) — AutoPilot v3.1 (Orchestrated Diagnostics)
17
 
18
+ Version: 1.3.0
19
 
20
+ Manifest: v2
21
 
22
+ Target sites: chat.openai.com and chatgpt.com
 
23
 
24
+ manifest
25
 
26
+ What is currently included
 
 
 
 
 
 
 
27
 
28
+ Content scripts are split by load phase:
29
 
30
+ At document_start:
31
 
32
+ content/core-utils.js
 
 
 
 
33
 
34
+ content/early-shield.js
35
 
36
+ content/net-guard.js
 
37
 
38
+ At document_idle:
39
 
40
+ content/core-utils.js
41
 
42
+ content/dom-softcap.js
 
 
 
 
43
 
44
+ content/keepalive.js
 
 
 
45
 
46
+ content/autopilot.js
 
 
47
 
48
+ content/traffic-ui.js
 
 
 
49
 
50
+ manifest
 
 
51
 
52
+ Background script:
53
 
54
+ background.js (non-persistent background)
55
 
56
+ manifest
 
 
 
57
 
58
+ Permissions
59
 
60
+ The manifest currently requests:
61
 
62
+ storage
63
 
64
+ webRequest
65
 
66
+ alarms
67
 
68
+ tabs
 
 
 
69
 
70
+ notifications
71
 
72
+ Site access for https://chat.openai.com/* and https://chatgpt.com/*
73
 
74
+ manifest
 
75
 
76
+ Browser target
 
 
 
 
 
 
77
 
78
+ This build includes Gecko settings with:
 
 
 
79
 
80
+ Extension ID: chat-traffic-gate@local
81
 
82
+ strict_min_version: 109.0
83
 
84
+ manifest
85
 
86
+ Install (Firefox, temporary load)
 
87
 
88
+ Download/clone this repo.
89
 
90
+ Open Firefox and go to about:debugging#/runtime/this-firefox
91
 
92
+ Click Load Temporary Add-on
93
 
94
+ Select manifest.json
 
 
 
95
 
96
+ Reality check
97
+
98
+ This is a personal tool and actively being worked on.
99
+
100
+ It is not a promise, not polished, and not guaranteed.
101
+
102
+ It may help some users, and do nothing for others.
103
+
104
+ If it helps you, great. If not, skip it.
105