From 8df2d648dd2337dbe6675b962ca7ecc4dec9c595 Mon Sep 17 00:00:00 2001 From: Jamie Brunton Date: Sat, 8 Aug 2026 20:20:03 +0100 Subject: [PATCH] fix: open the dedicated Reddit Chat host --- extensions/reddit-session-exporter/README.md | 2 +- extensions/reddit-session-exporter/manifest.json | 2 +- extensions/reddit-session-exporter/service-worker.js | 9 ++++++++- extensions/reddit-session-exporter/session-export.js | 1 + tests/reddit-session-exporter.test.ts | 5 +++++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/extensions/reddit-session-exporter/README.md b/extensions/reddit-session-exporter/README.md index 1abc917..1a135a5 100644 --- a/extensions/reddit-session-exporter/README.md +++ b/extensions/reddit-session-exporter/README.md @@ -7,7 +7,7 @@ This local Chrome extension exports `reddit.com` cookies and the current Reddit 1. In Chrome, open `chrome://extensions`, enable **Developer mode**, then choose **Load unpacked** and select this folder. If it was already loaded, click its **Reload** button after updating these files so Chrome starts the new service worker. 2. Sign in to Reddit in the same Chrome profile. -3. Open [Reddit Chat](https://www.reddit.com/chat/) and wait for it to finish loading. The extension badge changes to `OK` when it captures the Matrix credential. +3. Open [Reddit Chat](https://chat.reddit.com/) and wait for it to finish loading. Do not use `www.reddit.com/chat/`: its Matrix bridge can return HTTP 405. The extension badge changes to `OK` when it captures the Matrix credential. If no credential has been captured yet, clicking the extension opens the correct Chat host automatically. 4. Click the **RedditBot Session Exporter** toolbar icon and save `redditbot-session.json`. 5. In RedditBot Dashboard > Settings > Access, choose **Import Reddit session** and select the exported file. 6. Delete the downloaded JSON file once the dashboard confirms that the session is authenticated. diff --git a/extensions/reddit-session-exporter/manifest.json b/extensions/reddit-session-exporter/manifest.json index 528842f..b8caf40 100644 --- a/extensions/reddit-session-exporter/manifest.json +++ b/extensions/reddit-session-exporter/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "RedditBot Session Exporter", - "version": "1.1.0", + "version": "1.1.1", "description": "Exports Reddit cookies and Reddit Chat credentials for a self-hosted RedditBot dashboard.", "permissions": ["cookies", "downloads", "storage", "webRequest"], "host_permissions": [ diff --git a/extensions/reddit-session-exporter/service-worker.js b/extensions/reddit-session-exporter/service-worker.js index ab0eee7..7f845ba 100644 --- a/extensions/reddit-session-exporter/service-worker.js +++ b/extensions/reddit-session-exporter/service-worker.js @@ -1,6 +1,7 @@ import { assertMatchingSessionIdentity, createSessionExportDownload, + REDDIT_CHAT_URL, } from './session-export.js'; const MATRIX_URLS = [ @@ -64,7 +65,13 @@ chrome.action.onClicked.addListener(async () => { const cookies = await chrome.cookies.getAll({ domain: 'reddit.com' }); const { matrixCapture } = await chrome.storage.local.get('matrixCapture'); if (!matrixCapture) { - throw new Error('Open Reddit Chat, wait for it to load, then click the extension again.'); + await chrome.tabs.create({ url: REDDIT_CHAT_URL }); + await chrome.action.setBadgeText({ text: '...' }); + await chrome.action.setBadgeBackgroundColor({ color: '#6c757d' }); + await chrome.action.setTitle({ + title: 'Reddit Chat opened. Wait for the badge to show OK, then click again.', + }); + return; } const whoami = await fetch(`${matrixCapture.homeserver}/_matrix/client/v3/account/whoami`, { diff --git a/extensions/reddit-session-exporter/session-export.js b/extensions/reddit-session-exporter/session-export.js index b6c7aa4..28eaa47 100644 --- a/extensions/reddit-session-exporter/session-export.js +++ b/extensions/reddit-session-exporter/session-export.js @@ -1,4 +1,5 @@ const REDDITBOT_SESSION_FILENAME = 'redditbot-session.json'; +export const REDDIT_CHAT_URL = 'https://chat.reddit.com/'; export function normalizeRedditAccountId(accountId) { const trimmed = String(accountId ?? '').trim(); diff --git a/tests/reddit-session-exporter.test.ts b/tests/reddit-session-exporter.test.ts index f283897..7c22fba 100644 --- a/tests/reddit-session-exporter.test.ts +++ b/tests/reddit-session-exporter.test.ts @@ -2,8 +2,13 @@ import { describe, expect, it } from 'vitest'; import { assertMatchingSessionIdentity, createSessionExportDownload, + REDDIT_CHAT_URL, } from '../extensions/reddit-session-exporter/session-export.js'; +it('uses the dedicated Reddit Chat host for Matrix credential capture', () => { + expect(REDDIT_CHAT_URL).toBe('https://chat.reddit.com/'); +}); + describe('createSessionExportDownload', () => { it('creates a JSON data URL that Chrome can download from a service worker', () => { const download = createSessionExportDownload([