-
Notifications
You must be signed in to change notification settings - Fork 63
feat: self-hosted overleaf #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for self-hosted Overleaf instances by implementing a browser extension settings page where users can request host permissions for their custom domains. The implementation enables PaperDebugger to work with any Overleaf instance, not just the official overleaf.com domain.
Key Changes:
- Added extension settings and popup UI pages with React-based components for managing host permissions
- Implemented dynamic content script registration based on granted permissions
- Added optional host permissions (
*://*/*) to support arbitrary self-hosted domains
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
vite.config.ts |
Added build configurations for settings and popup entry points |
package.json |
Added build scripts for settings and popup bundles |
manifest.json |
Added optional host permissions, scripting permission, and options page; removed static content_scripts in favor of dynamic registration |
shared/constants.ts |
Added REQUEST_HOST_PERMISSION handler name constant |
background.ts |
Added requestHostPermissionHandler and initialized content script registration |
intermediate.ts |
Exported requestHostPermission function using makeFunction pattern |
libs/permissions.ts |
Implemented dynamic content script registration based on granted permissions |
views/extension-settings/* |
Created settings page with host permission management UI components |
views/extension-popup/* |
Refactored popup from static HTML to React-based implementation with self-hosted setup instructions |
popup.ts |
Added standalone popup script (appears to be unused/test code) |
public/settings.html |
Added HTML entry point for settings page |
public/popup.html |
Simplified popup HTML to load React app instead of inline styles |
main.tsx |
Added debug logging for PaperDebugger initialization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...app/src/views/extension-settings/components/HostPermissionWidget/useHostPermissionManager.ts
Outdated
Show resolved
Hide resolved
...webapp/src/views/extension-settings/components/HostPermissionWidget/HostPermissionWidget.tsx
Outdated
Show resolved
Hide resolved
...webapp/src/views/extension-settings/components/HostPermissionWidget/HostPermissionWidget.tsx
Outdated
Show resolved
Hide resolved
webapp/_webapp/src/popup.ts
Outdated
| /* | ||
| * popup.ts | ||
| * | ||
| * Script for the extension popup page. | ||
| * Handles the request host permission button click. | ||
| */ | ||
|
|
||
| // Disable context menu (right-click) to comply with CSP | ||
| document.addEventListener('contextmenu', (e) => { | ||
| e.preventDefault(); | ||
| return false; | ||
| }); | ||
|
|
||
| document.getElementById('myButton')?.addEventListener('click', async () => { | ||
| const origin = "https://www.google.com/"; | ||
|
|
||
| try { | ||
| // 直接调用 background script,类似于 intermediate.ts 中的实现 | ||
| const response = await chrome.runtime.sendMessage({ | ||
| action: "requestHostPermission", | ||
| args: origin, | ||
| }); | ||
|
|
||
| if (response?.error) { | ||
| console.error("Error requesting permissions:", response.error); | ||
| alert(`Permission request failed: ${response.error}`); | ||
| } else if (response === true) { | ||
| console.log(`Permission granted for ${origin}`); | ||
| alert(`Permission granted for ${origin}`); | ||
| } else { | ||
| console.log(`Permission denied for ${origin}`); | ||
| alert(`Permission denied for ${origin}`); | ||
| } | ||
| } catch (error) { | ||
| console.error("Error requesting permissions:", error); | ||
| const errorMessage = error instanceof Error ? error.message : String(error); | ||
| alert(`Error: ${errorMessage}`); | ||
| } | ||
| }); | ||
|
|
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file (popup.ts) appears to be unused/dead code. The popup is implemented using React in src/views/extension-popup/app.tsx, making this vanilla JavaScript implementation redundant. Additionally, it references a non-existent myButton element and contains hardcoded test logic for requesting Google permissions. Consider removing this file.
| /* | |
| * popup.ts | |
| * | |
| * Script for the extension popup page. | |
| * Handles the request host permission button click. | |
| */ | |
| // Disable context menu (right-click) to comply with CSP | |
| document.addEventListener('contextmenu', (e) => { | |
| e.preventDefault(); | |
| return false; | |
| }); | |
| document.getElementById('myButton')?.addEventListener('click', async () => { | |
| const origin = "https://www.google.com/"; | |
| try { | |
| // 直接调用 background script,类似于 intermediate.ts 中的实现 | |
| const response = await chrome.runtime.sendMessage({ | |
| action: "requestHostPermission", | |
| args: origin, | |
| }); | |
| if (response?.error) { | |
| console.error("Error requesting permissions:", response.error); | |
| alert(`Permission request failed: ${response.error}`); | |
| } else if (response === true) { | |
| console.log(`Permission granted for ${origin}`); | |
| alert(`Permission granted for ${origin}`); | |
| } else { | |
| console.log(`Permission denied for ${origin}`); | |
| alert(`Permission denied for ${origin}`); | |
| } | |
| } catch (error) { | |
| console.error("Error requesting permissions:", error); | |
| const errorMessage = error instanceof Error ? error.message : String(error); | |
| alert(`Error: ${errorMessage}`); | |
| } | |
| }); |
webapp/_webapp/src/views/extension-settings/components/ExtensionSettings.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
...app/src/views/extension-settings/components/HostPermissionWidget/useHostPermissionManager.ts
Outdated
Show resolved
Hide resolved
…missionWidget/useHostPermissionManager.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
...app/src/views/extension-settings/components/HostPermissionWidget/useHostPermissionManager.ts
Outdated
Show resolved
Hide resolved
...webapp/src/views/extension-settings/components/HostPermissionWidget/HostPermissionWidget.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…onSettings.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…missionWidget/HostPermissionWidget.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Junyi-99
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs change
Junyi-99
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but needs test
| }, | ||
| "host_permissions": ["*://*.overleaf.com/"], | ||
| "permissions": ["cookies", "storage"], | ||
| "optional_host_permissions": ["*://*/*"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Host permission pattern missing wildcard for paths
The host_permissions value *://*.overleaf.com/ only matches the root path (e.g., https://www.overleaf.com/) due to the trailing / without a wildcard. The extension needs to work on project pages like https://www.overleaf.com/project/abc123, which won't match this pattern. The pattern needs *://*.overleaf.com/* (with /* at the end) to match all paths and allow the content scripts to be injected on project pages.
Note
Adds a settings page to request host permissions and dynamically register content scripts, enabling self-hosted Overleaf support; converts the popup to a React app and updates build/manifest.
content_scriptswith dynamic registration viascriptingAPI; widenweb_accessible_resourcesto*://*/*.optional_host_permissions: '*://*/*', new permissions (scripting,activeTab), andoptions_page(settings.html).host_permissionsfor Overleaf; strippermissions_explanationat build time.requestHostPermissionhandler and auto-register content scripts when permissions are granted (registerContentScriptsIfPermitted).libs/permissions.tsto (un)register content scripts for granted origins.requestHostPermissioninintermediate.tsand add handler name inconstants.public/settings.html,views/extension-settings/...) with Host Permission widget to request and list granted origins (useschrome.permissions).public/popup.html,views/extension-popup/...) and guidance + link to settings.package.jsonscripts updated to buildsettingsandpopupbundles.main.tsx.Written by Cursor Bugbot for commit 677ab6b. This will update automatically on new commits. Configure here.