-
Notifications
You must be signed in to change notification settings - Fork 71
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 5 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 |
|---|---|---|
| @@ -1,114 +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</title> | ||
| <link href="https://fonts.googleapis.com/css2?family=Exo+2:wght@600&display=swap" rel="stylesheet" /> | ||
| <style> | ||
| html, | ||
| body { | ||
| height: 100%; | ||
| margin: 0; | ||
| padding: 0; | ||
| } | ||
| body { | ||
| padding: 1rem; | ||
| padding-left: 1.5rem; | ||
| min-width: 280px; | ||
| max-width: 340px; | ||
| min-height: 220px; | ||
| background: #fafafa; | ||
| color: #222; | ||
| font-family: | ||
| "Exo 2", | ||
| -apple-system, | ||
| BlinkMacSystemFont, | ||
| "Segoe UI", | ||
| Roboto, | ||
| "Helvetica Neue", | ||
| Arial, | ||
| sans-serif; | ||
| border: 1px solid #ececec; | ||
| box-sizing: border-box; | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: space-between; | ||
| height: 100%; | ||
| } | ||
| .title { | ||
| font-size: 1.5rem; | ||
| font-weight: 600; | ||
| letter-spacing: 0.02em; | ||
| text-align: left; | ||
| font-family: "Exo 2", sans-serif; | ||
| } | ||
| .subtitle { | ||
| font-size: 1rem; | ||
| font-weight: 600; | ||
| letter-spacing: 0.02em; | ||
| text-align: left; | ||
| font-family: "Exo 2", sans-serif; | ||
| } | ||
| .steps { | ||
| margin: 0.5rem 0 0 0; | ||
| padding: 0 0rem; | ||
| flex: 1; | ||
| } | ||
| .step { | ||
| font-size: 0.9rem; | ||
| font-weight: 400; | ||
| margin-bottom: 0.7rem; | ||
| line-height: 1.5; | ||
| border-left: 3px solid #e0e0e0; | ||
| padding-left: 0.7em; | ||
| background: none; | ||
| border-radius: 0; | ||
| } | ||
| .step strong { | ||
| color: #3b82f6; | ||
| font-weight: 600; | ||
| margin-right: 0.3em; | ||
| } | ||
| .footer { | ||
| font-size: 0.75rem; | ||
| text-align: right; | ||
| font-weight: 100; | ||
| color: #888; | ||
| padding: 0.7rem 1.2rem 1.1rem 0; | ||
| border-top: 1px solid #ececec; | ||
| background: none; | ||
| border-radius: 0; | ||
| letter-spacing: 0.01em; | ||
| } | ||
| .highlight { | ||
| color: #3b82f6; | ||
| font-weight: 600; | ||
| } | ||
| .noselect { | ||
| -webkit-user-select: none; | ||
| -moz-user-select: none; | ||
| -ms-user-select: none; | ||
| user-select: none; | ||
| } | ||
| .nodrag { | ||
| -webkit-user-drag: none; | ||
| -webkit-user-select: none; | ||
| -webkit-user-select: none; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body oncontextmenu="return false" class="nodrag"> | ||
| <div oncontextmenu="return false" class="title noselect">PaperDebugger</div> | ||
| <div class="subtitle noselect">How to use</div> | ||
| <div class="steps noselect"> | ||
| <div class="step"> | ||
| <strong>1.</strong>In | ||
| <a class="highlight nodrag" href="https://overleaf.com/project" target="_blank">overleaf.com</a>, open any of | ||
| your projects. | ||
| </div> | ||
| <div class="step"><strong>2.</strong>PaperDebugger is in the <b>top left</b> of the project page.</div> | ||
| </div> | ||
| <div class="footer noselect">Happy writing!</div> | ||
| </body> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>PaperDebugger Popup</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="popup.js"></script> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <!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,24 @@ | ||
| // can not running in content_script. registerContentScripts can only be called in service_worker. | ||
| export async function registerContentScripts() { | ||
| const origins = (await chrome.permissions.getAll()).origins || []; | ||
| const scriptIds = (await chrome.scripting.getRegisteredContentScripts()).map(script => script.id); | ||
|
|
||
| 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: origins, | ||
| world: "MAIN", | ||
| }, { | ||
| id: "content-script-intermediate", | ||
| js: ["intermediate.js"], | ||
| persistAcrossSessions: true, | ||
| matches: origins, | ||
| runAt: "document_start" | ||
| }]) | ||
|
Junyi-99 marked this conversation as resolved.
Outdated
Junyi-99 marked this conversation as resolved.
Outdated
|
||
|
|
||
| console.log("[PaperDebugger] Registration complete", origins); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * 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 中的实现 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Junyi-99 marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /* | |
| * 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}`); | |
| } | |
| }); |
Uh oh!
There was an error while loading. Please reload this page.