New options page to add domain regexes to a whitelist#5
Conversation
We have an internal issue tracking github.dev -- this would require a modification of our vscode extension to support the web environment. I've previously looked at CodeSandbox. I think it doesn't work for a similar reason as described in #4 (comment) |
pqn
left a comment
There was a problem hiding this comment.
Really appreciate the PR! I just left a few comments.
|
|
||
| document.getElementById('go-to-options')?.addEventListener('click', () => { | ||
| chrome.runtime.openOptionsPage(); | ||
| chrome.tabs.create({ url: 'chrome://extensions/?options=' + chrome.runtime.id }); |
There was a problem hiding this comment.
What's the reason for this change?
There was a problem hiding this comment.
I don't think the options page is large enough to take up one whole tab, so use this link to go to the extension detail page and pop up the options window.
| if (host.test(window.location.href)) { | ||
| // the url matches the whitelist | ||
| addMonacoInject(); | ||
| addCodeMirrorInject(); |
There was a problem hiding this comment.
Is it possible that both addCodeMirrorInject and addCodeMirror5Inject will run on the same site?
There was a problem hiding this comment.
Yep, I tried on Code Share and it gave completion twice. Thanks for pointing the bug out.
|
Thank you so much for reviewing this PR and valuable suggestions. I pushed some new commits to complete:
Can you take a look and give more feedback? |
pqn
left a comment
There was a problem hiding this comment.
Thanks, left some additional comments.
| useEffect(() => { | ||
| (async () => { | ||
| const whitelist = await getStorageItem('whitelist'); | ||
| setText(whitelist.join('\n')); |
There was a problem hiding this comment.
Prefer calling this allowlist instead of whitelist everywhere.
| <script src="options.js"></script> | ||
| </body> | ||
| </html> | ||
| </html> No newline at end of file |
There was a problem hiding this comment.
Merge/rebase on main and some additional CI checks will run. I think they might complain about missing \n here.
There was a problem hiding this comment.
Looks like we still need the merge/rebase (CI is still failing)
| @@ -0,0 +1,183 @@ | |||
| import React, { createRef, useEffect, useRef, useState } from 'react'; | |||
| textTransform: 'none', | ||
| }} | ||
| > | ||
| Save <SaveAltIcon /> |
There was a problem hiding this comment.
It's ambiguous from the UI if the Save button will also save the token field or not.
| if (pattern.pattern.test(window.location.href)) { | ||
| let injectCodeMirror = false; | ||
|
|
||
| const addCodeMirrorInject = () => |
There was a problem hiding this comment.
Let's call this one addCodeMirror5GlobalInject and the other one addCodeMirror5LocalInject, since both only work on CodeMirror 5.
pqn
left a comment
There was a problem hiding this comment.
I forgot to mention earlier, but let's have a Reset button for the regex field to restore the default settings.
| /> | ||
| </Typography> | ||
| <Typography variant="body2"> | ||
| Domains to allow auto-completion, double-click to edit, use regex format |
There was a problem hiding this comment.
| Domains to allow auto-completion, double-click to edit, use regex format | |
| Domains to allow auto-completion. Use one regex per line. |
| <Button | ||
| variant="text" | ||
| onClick={() => { | ||
| const lst = text.split('\n').map((x) => x.trim()); |
There was a problem hiding this comment.
Filter empty strings (so we can tolerate newlines as spacing).
|
@pqn Thanks for your comment. I updated the code as you suggested. Now, the new UI looks like: I'm uncertain whether it should be "allow list" or "allowed list" (since I'm not a native English speaker...) |
|
|
||
| return ( | ||
| <> | ||
| <Typography variant="h6">Allow List</Typography> |
There was a problem hiding this comment.
| <Typography variant="h6">Allow List</Typography> | |
| <Typography variant="h6">Allowlist</Typography> |
(Similar changes elsewhere.)
| textTransform: 'none', | ||
| }} | ||
| > | ||
| Save the Allow List |
There was a problem hiding this comment.
| Save the Allow List | |
| Save Allowlist |
|
Looks like the rebase or merge had some issue and the commits are showing up in the PR history. |
|
Update: add the reset button and remove the exit button. |
pqn
left a comment
There was a problem hiding this comment.
One small change I missed, otherwise this looks good to merge!
| } | ||
|
|
||
| export const OMonacoSite = { | ||
| UNSPECIFIED: 0, |
There was a problem hiding this comment.
Sorry, to be more specific, let's keep UNSPECIFIED = 0 and add CUSTOM as a new value.
There was a problem hiding this comment.
No problem, I recovered it.
|
Thanks! 🎉 |


I really appreciate this project and look forward to a new version that I can use on more websites more flexibly. I attempted to modify a few lines of code as below:
script.ts