Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1fb37e2
fix(perplexity): import isSynthetic from @nolly/ai and drop re-export…
thenolle Nov 10, 2026
b50f153
refactor(perplexity): merge duplicate @nolly/ai imports
thenolle Nov 10, 2026
a693061
feat(ai): hoist Enter as Newline into @nolly/ai; add messages, file b…
thenolle Nov 10, 2026
246d65b
fix(perplexity): register Enter as Newline from @nolly/ai
thenolle Nov 10, 2026
265cd95
feat(ai): hoist Draft Guard into @nolly/ai and enable it in better-ch…
thenolle Nov 10, 2026
47623b2
fix(ai): export DraftGuardFeature from the features barrel
thenolle Nov 10, 2026
99edbdb
feat(ai): hoist Message Splitter into @nolly/ai and enable it in bett…
thenolle Nov 10, 2026
62d8f9c
feat(ai): hoist Command Palette, Prompt Library, Prompt Queue and Rec…
thenolle Nov 10, 2026
39e82c2
fix(ai): repair hoisted dialog id constants
thenolle Nov 10, 2026
277c33c
feat(ai): hoist Batch Runner, Selection Toolbar and Max Width into @n…
thenolle Nov 10, 2026
b9890b3
fix(perplexity): import tutorial shortcut helpers from @nolly/ai
thenolle Nov 10, 2026
67f6a85
feat(ai): hoist Code Block Pro into @nolly/ai and enable it in better…
thenolle Nov 10, 2026
82f797b
feat(ai): hoist Exporter and Update checker; ChatGPT export from the …
thenolle Nov 10, 2026
bcff04c
feat(chatgpt): usage status; header diagnostics (step 10a)
thenolle Nov 10, 2026
aad8100
refactor(ai): ready-gated start for ChatGPT, one settings dialog, bat…
thenolle Nov 10, 2026
73e3065
fix(chatgpt): style header buttons with ChatGPT's own toolbar classes
thenolle Nov 10, 2026
41050a6
fix(chatgpt): turn locator for the current DOM, converter for the new…
thenolle Nov 10, 2026
1164c89
chore(chatgpt): header layout diagnostics
thenolle Nov 10, 2026
2753eee
release(chatgpt): 1.0.0
thenolle Nov 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,30 @@ By submitting a pull request, issue attachment or prompt, you confirm that you w
## Ways to contribute

- **Bug reports and ideas:** use the issue forms.
- **Community prompts:** use the "Prompt submission" form, or open a pull request that adds an entry to `better-perplexity/prompts/library.json`.
- **Community prompts:** use the "Prompt submission" form, or open a pull request that adds an entry to `ai/perplexity/prompts/library.json`.
- **Code:** open an issue first for anything larger than a small fix.

## Repository layout

| Folder | Package | Purpose |
| --------------- | ---------------------- | ---------------------------------------------------- |
| `core/` | `@nolly/core` | Runtime, storage, DOM, HTTP, build tooling |
| `core/ai` | `@nolly/ai` | Platform-agnostic code shared by AI-chat userscripts |
| `ai/perplexity` | `@nolly/ai-perplexity` | Better Perplexity |
| `ai/chatgpt` | `@nolly/ai-chatgpt` | Better ChatGPT |

## Development setup

```bash
bun install # at the repository root (Bun workspace)
cd better-perplexity
cd ai/perplexity # or ai/chatgpt
bun run dev # unminified, rebuilds on change
bun run typecheck
bun run validate:prompts
bun run build # minified output in dist/
```

Install `dist/better-perplexity.user.js` in your userscript manager to test. Shared code lives in `core/` and is published as the workspace package `@nolly/core`; script-specific code stays in the script's own folder. Start a new script with `bun scripts/new-userscript.ts <slug> "<Name>"`.
Install the file in `dist/` in your userscript manager to test. Code that does not depend on one site belongs in `core/ai`; site-specific selectors and modules stay in the script's folder. Start a new script with `bun scripts/new-userscript.ts <slug> "<Name>" [parent-folder]`, for example `bun scripts/new-userscript.ts better-claude "Better Claude" ai`.

## Code style

Expand All @@ -33,7 +42,7 @@ Install `dist/better-perplexity.user.js` in your userscript manager to test. Sha

## Releasing

1. Bump `version` in the script's `package.json`.
1. Bump `version` in the script's `package.json`. Each script also declares its `userscript.slug` there, which names its tag and its folder on the `dist` branch.
2. Add a section to its `CHANGELOG.md` in the form `## [x.y.z] - YYYY-MM-DD`.
3. Merge to `master`. The release workflow does the rest.

Expand Down
14 changes: 14 additions & 0 deletions ai/chatgpt/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog

## [1.0.0] - 2026-11-10

- Exporter built from the conversation view (Markdown, text, Word, PDF, JSON) and update checker.
- Batch Runner, Selection Toolbar (Ask, Explain, Summarize, Fact-check, Quote) and Max Width.
- Initial skeleton: composer and header detection, response observer, session state and diagnostics.
- Starts only after the page has loaded and the composer has rendered, so it doesn't interfere with ChatGPT's own startup.
- Header settings button and settings dialog from the shared UI kit; `betterChatgptSend(text)` for testing the composer.
- Draft Guard: autosaved drafts, size meter and unsent-text warning.
- Message Splitter: send oversized prompts in parts or attach them as a file (respects remaining uploads).
- Code Block Pro: language badges, highlighting, line numbers, wrap, fold, copy and download.
- Prompt Library (shared community prompts), Command Palette, Message Queue and Recall.
- Usage Status: remaining reasoning, upload, image and research limits with reset times, plan and rolling window, and alerts.
71 changes: 71 additions & 0 deletions ai/chatgpt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Better ChatGPT

A modular userscript that adds the missing parts of ChatGPT: limits at a glance, better code blocks, long-message handling, a prompt library, batch runs and real exports.

[Changelog](CHANGELOG.md) · [Report a bug](https://github.com/thenolle/userscripts/issues/new?template=bug_report.yml)

## Install

1. Install [Violentmonkey](https://violentmonkey.github.io/) or [Tampermonkey](https://www.tampermonkey.net/).
2. Open the **Install** link on the project website and confirm.
3. Open chatgpt.com. The settings button sits in the header next to ChatGPT's own buttons.

Updates arrive automatically. The script also checks on its own and offers to update.

## Features

| Feature | What you get |
| ----------------- | ---------------------------------------------------------------------------------------------------- |
| Usage Status | Remaining reasoning, upload, image and research limits with reset times, your plan, low/empty alerts |
| Code Block Pro | Language badges, syntax colours, line numbers, wrap, fold, download, indentation-safe copy |
| Message Splitter | Paste any amount of text; split into parts or attach as a file only when needed |
| Prompt Library | Your prompts plus community prompts, with a form for placeholders |
| Batch Runner | Run one template over a list, with pause, resume and reload recovery |
| Selection Toolbar | Ask, explain, summarize, fact-check or quote highlighted text |
| Exporter | Markdown, text, Word, PDF and JSON |
| Draft Guard | Drafts survive reloads; size meter; warning before closing with unsent text |
| Command Palette | Search every action |
| Enter as Newline | Enter adds a line, a shortcut sends |
| Message Queue | Queue follow-ups while an answer generates; they send one by one |
| Recall | Search everything you sent and reuse it |
| Max Width | Full-width conversations, optional sidebar removal |
| Update Checker | Checks on load and every few minutes, tells you once per version |

## Shortcuts

| Action | Default |
| --------------- | --------------------------- |
| Command palette | Alt + Shift + P |
| Prompt library | Alt + Shift + L |
| Recall | Alt + Shift + H |
| Send message | Ctrl + Enter or Cmd + Enter |

All of them can be changed from the settings dialog.

## Privacy

No analytics and no server of its own. The script reads ChatGPT's own responses in your session (for limits and the model in use) and talks to `raw.githubusercontent.com` for update checks and community prompts. Drafts, prompts and settings stay in your userscript manager's storage.

## Troubleshooting

- **A button is missing:** open the settings dialog and check the module is on. In the browser console, `betterChatgptDump()` prints what the script found on the page; attach it to a bug report.
- **Export says no messages found:** ChatGPT changed its layout. Run `betterChatgptDump()` and attach it.
- **Limits look empty:** they come from ChatGPT's own responses and appear after the page loads or a message is sent.

## Built on the shared packages

Better ChatGPT is built on [`@nolly/core`](../../core/README.md) and [`@nolly/ai`](../../core/ai/README.md). Both are bundled into `better-chatgpt.user.js` at build time. Only what is specific to ChatGPT lives here: selectors, the network observer, limits, the exporter source and the header placement.

## Development

```bash
bun install # at the repository root
cd ai/chatgpt
bun run dev # unminified, rebuilds on change
bun run typecheck
bun run build # minified userscript in dist/
```

## License

[PolyForm Strict License 1.0.0](../../LICENSE).
22 changes: 22 additions & 0 deletions ai/chatgpt/docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Architecture
description: How Better ChatGPT is built on the shared packages.
section: Reference
order: 900
---

# Architecture

Better ChatGPT is a thin layer on top of two shared packages, both bundled into the final `.user.js`.

- **`@nolly/core`** is the runtime: features, storage, logging, DOM helpers and the build.
- **`@nolly/ai`** holds everything that is not specific to one site: the composer, prompt and generation handling, the UI kit and the features themselves. A site fills in a small registry once at startup.

What stays in this folder:

- selectors and the page locators (message box, header, messages);
- the network observer that reads limits, the model in use and when an answer starts and ends;
- the exporter source, which converts the conversation view to Markdown;
- the usage feature and the header placement.

The script starts only after the page has loaded and the message box has rendered, so it never touches the page while ChatGPT is still starting up.
17 changes: 17 additions & 0 deletions ai/chatgpt/docs/exporting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Exporting a conversation
description: Markdown, text, Word, PDF and JSON.
section: Guides
order: 30
---

# Exporting a conversation

Open a conversation and click the download icon in the header. Pick a format:

- **Markdown** keeps headings, lists, tables and code blocks with their language.
- **Plain text** strips the formatting.
- **Word** and **PDF** are generated in your browser from the Markdown.
- **JSON** lists each message with its role and Markdown.

The export is built from what is on the page, so scroll to load a very long conversation first.
17 changes: 17 additions & 0 deletions ai/chatgpt/docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Getting started
description: Install Better ChatGPT and find your way around.
section: Guides
order: 10
---

# Getting started

Install a userscript manager, then the script, and open chatgpt.com. After the page has loaded you will see:

- **Settings** (sliders icon) in the header: turn modules on or off and open each module's own settings.
- **Usage** pill: your remaining reasoning messages. Hover for every limit, click for details.
- **Download** icon inside a conversation: exports it.
- Extra buttons next to the message box for big messages, prompts, batches, queue and recall.

Press Alt + Shift + P at any time to search every action.
15 changes: 15 additions & 0 deletions ai/chatgpt/docs/troubleshooting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Troubleshooting
description: Fixes for missing buttons, empty limits and failed exports.
section: Reference
order: 800
---

# Troubleshooting

Open the browser console on chatgpt.com and run `betterChatgptDump()`. It prints what the script found: the composer, the header, your messages and the current limits. Attach it to any bug report.

- **No header buttons:** the script waits for the page and the message box to finish loading. Wait a few seconds, or check the module is on in settings.
- **Export finds no messages:** ChatGPT changed how it marks messages. The dump shows `page.turns`; if both counts are 0 while messages are on screen, report it.
- **Limits are empty:** send a message or reload the page.
- **Update check failed (404):** the first release has not been published yet.
14 changes: 14 additions & 0 deletions ai/chatgpt/docs/usage-tracking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Usage tracking
description: Where the numbers come from and when they refresh.
section: Guides
order: 20
---

# Usage tracking

ChatGPT reports your remaining limits itself. Better ChatGPT reads those responses in your session: file uploads, pasted text turned into files, image generation, deep research and reasoning messages, each with its reset time. It also shows your plan and the rolling window.

The numbers refresh when ChatGPT refreshes them: when you load a page and after each message. There are no totals or refill estimates, because ChatGPT only reports what is left.

Alerts appear when a limit runs out, runs low, or becomes available again. Choose which limit the header pill shows from the settings dialog.
3 changes: 2 additions & 1 deletion ai/chatgpt/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@nolly/ai-chatgpt",
"version": "0.1.0",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "PolyForm-Strict-1.0.0",
"userscript": { "slug": "better-chatgpt" },
"repository": {
"type": "git",
"url": "git+https://github.com/thenolle/userscripts.git",
Expand Down
4 changes: 3 additions & 1 deletion ai/chatgpt/src/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ConversationRef, PlatformAdapter } from '@nolly/ai'
import { isOwnUi } from './dom'
import { findAttachButton, findComposerForm, findHeaderSlot, findModeToggles, findPrimaryAction, findSendButton, findSidebar, findStopButton, labelOf, locateEditable, rejectEditable } from './locate'
import { countTurns } from './messages'

const CHAT_PATH = /^\/(?:g\/g-p-[0-9a-f]+[^/]*\/)?c\/([^/?#]+)/
const PROJECT_PATH = /^\/g\/(g-p-[0-9a-f]+)/
Expand Down Expand Up @@ -43,6 +44,7 @@ export const chatgptAdapter: PlatformAdapter = {
attach: brief(findAttachButton()),
modeToggles: findModeToggles().map(({ element }) => brief(element)),
headerSlot: findHeaderSlot() !== null,
sidebar: findSidebar() !== null
sidebar: findSidebar() !== null,
turns: countTurns(),
})
}
10 changes: 5 additions & 5 deletions ai/chatgpt/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Userscript, createLogger } from '@nolly/core'
import { toggleSettingsDialog } from '@nolly/ai'
import { Userscript } from '@nolly/core'
import { CONFIG, OBSERVER_OPTIONS } from './config'
import { uiMarker } from './dom'

const logger = createLogger('better-chatgpt')
import { findComposerForm } from './locate'

export class App extends Userscript {
constructor() {
Expand All @@ -16,8 +16,8 @@ export class App extends Userscript {
initializationDelay: CONFIG.initializationDelay,
safetyInterval: CONFIG.safetyInterval,
clearConsole: false,
isReady: () => Boolean(document.querySelector('main')),
openSettings: () => logger.info('The settings dialog arrives in step 2.')
isReady: () => document.readyState === 'complete' && findComposerForm() !== null,
openSettings: (script) => toggleSettingsDialog(script)
})
}
}
25 changes: 25 additions & 0 deletions ai/chatgpt/src/budget.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { ChatSession } from './session'

export const FILES_PER_MESSAGE = 20

export interface FileBudget {
readonly perMessage: number
readonly remainingUploads: number | null
readonly uploadResetsAt: string | null
readonly remainingPasteToFile: number | null
readonly pasteResetsAt: string | null
readonly maxFileMb: number | null
}

export const fileBudget = (session: ChatSession): FileBudget => {
const upload = session.limit('file_upload')
const paste = session.limit('paste_text_to_file')
return {
perMessage: FILES_PER_MESSAGE,
remainingUploads: upload?.remaining ?? null,
uploadResetsAt: upload?.resetAfter ?? null,
remainingPasteToFile: paste?.remaining ?? null,
pasteResetsAt: paste?.resetAfter ?? null,
maxFileMb: session.maxFileMb
}
}
6 changes: 5 additions & 1 deletion ai/chatgpt/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import type { SplitterSettings } from '@nolly/ai'

export const CONFIG = {
initializationDelay: 500,
initializationDelay: 1_500,
safetyInterval: 2_000
} as const

export const SPLITTER_DEFAULTS: Partial<SplitterSettings> = { limit: 30_000 }

export const OBSERVER_OPTIONS: MutationObserverInit = {
childList: true,
subtree: true,
Expand Down
Loading
Loading