-
Notifications
You must be signed in to change notification settings - Fork 62
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
Changes from all commits
ecd58f6
113447b
ac3f214
a096225
12eacbe
7004c74
a50b523
a37d0e1
6cccbc9
c11f392
e6ab4ea
40e23f7
79aa54d
122326f
677ab6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>PaperDebugger Settings</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="settings.js"></script> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // can not running in content_script. registerContentScripts can only be called in service_worker. | ||
| export async function registerContentScripts(origins?: string[]) { | ||
| try { | ||
| const resolvedOrigins = origins ?? (await chrome.permissions.getAll()).origins ?? []; | ||
| if (resolvedOrigins.length === 0) { | ||
| console.log("[PaperDebugger] No origins found, skipping content script registration"); | ||
| return; | ||
| } | ||
|
|
||
| const scriptIds = (await chrome.scripting.getRegisteredContentScripts()).map((script) => script.id); | ||
| if (scriptIds.length > 0) { | ||
| console.log("[PaperDebugger] Unregistering dynamic content scripts", scriptIds); | ||
| await chrome.scripting.unregisterContentScripts({ ids: scriptIds }); | ||
| } | ||
|
|
||
| await chrome.scripting.registerContentScripts([ | ||
| { | ||
| id: "content-script-main", | ||
| js: ["paperdebugger.js"], | ||
| persistAcrossSessions: true, | ||
| matches: resolvedOrigins, | ||
| world: "MAIN", | ||
| }, | ||
| { | ||
| id: "content-script-intermediate", | ||
| js: ["intermediate.js"], | ||
| persistAcrossSessions: true, | ||
| matches: resolvedOrigins, | ||
| runAt: "document_start", | ||
| }, | ||
| ]); | ||
|
|
||
| console.log("[PaperDebugger] Registration complete", resolvedOrigins); | ||
| } catch (error) { | ||
| console.error("[PaperDebugger] Failed to register content scripts", error); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,29 +11,20 @@ | |
| "48": "images/logo-1024.png" | ||
| }, | ||
| "host_permissions": ["*://*.overleaf.com/"], | ||
| "permissions": ["cookies", "storage"], | ||
| "optional_host_permissions": ["*://*/*"], | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Host permission pattern missing wildcard for pathsThe |
||
| "permissions_explanation": "The optional_host_permissions pattern '*://*/*' allows the extension to request access to any website. This is necessary to support self-hosted Overleaf instances and similar use cases. Users will be prompted to grant access only when needed. Please review the extension documentation for details on security and privacy implications.", | ||
| "permissions": ["cookies", "storage", "scripting", "activeTab"], | ||
| "options_page": "settings.html", | ||
| "action": { | ||
| "default_popup": "popup.html" | ||
| }, | ||
| "background": { | ||
| "service_worker": "background.js" | ||
| }, | ||
| "content_scripts": [ | ||
| { | ||
| "js": ["paperdebugger.js"], | ||
| "matches": ["https://*.overleaf.com/project/*"], | ||
| "world": "MAIN" | ||
| }, | ||
| { | ||
| "js": ["intermediate.js"], | ||
| "matches": ["https://*.overleaf.com/project/*"], | ||
| "run_at": "document_start" | ||
| } | ||
| ], | ||
| "web_accessible_resources": [ | ||
| { | ||
| "resources": ["images/*"], | ||
| "matches": ["https://*.overleaf.com/*"] | ||
| "matches": ["*://*/*"] | ||
| } | ||
| ], | ||
| "key": "[AUTO-GENERATED]" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.