Exafunction / codeium-chrome

Free, ultrafast code autocomplete for Chrome
https://www.codeium.com/
MIT License
121 stars 19 forks source link

New options page to add domain regexes to a whitelist #5

Closed li-xin-yi closed 1 year ago

li-xin-yi commented 1 year ago

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:

  1. Refactor the options page by React, and support users to edit their own domain lists on which Codeium is allowed to complete code. The default list is the following 11 regular expressions, extracted from script.ts
https:\/\/colab.research\.google\.com\/.*
https:\/\/(.*\.)?stackblitz\.com\/.*
https:\/\/(.*\.)?deepnote\.com\/.*
https:\/\/(.*\.)?(databricks\.com|azuredatabricks\.net)\/.*
https:\/\/(.*\.)?quadratichq\.com\/.*
https?:\/\/(.*\.)?jsfiddle\.net(\/.*)?
https:\/\/(.*\.)?codepen\.io(\/.*)?
https:\/\/(.*\.)?codeshare\.io(\/.*)?
https:\/\/console\.paperspace\.com\/.*\/notebook\/.*
https?:\/\/www\.codewars\.com(\/.*)?
https:\/\/(.*\.)?github\.com(\/.*)?
image
  1. Test the feature on some web pages with the online editor, e.g., leetcode.com, codepod.io, and some web apps I deployed on local env with URL starting by localhost. It works when I write a correct regex for them. And also in reverse, removing some default regexes above can disable the code completion of Codeium on those websites.
  2. Though it extends the application scenarios for Codeium further, it may not work on many websites even if they apply Monaco or CodeMirror as their online editors (for example, online vs code/github.dev, codesandbox). The rules are too rough to support them well for now.
pqn commented 1 year ago

Though it extends the application scenarios for Codeium further, it may not work on many websites even if they apply Monaco or CodeMirror as their online editors (for example, online vs code/github.dev, codesandbox). The rules are too rough to support them well for now.

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 https://github.com/Exafunction/codeium-chrome/issues/4#issuecomment-1519231767

li-xin-yi commented 1 year ago

@pqn

Thank you so much for reviewing this PR and valuable suggestions. I pushed some new commits to complete:

  1. Change the font of domain inputs to "monospace"
  2. Validate the domain inputs, add toast notification on success/error when clicking on the save button
  3. Fix the duplicated injection issue

Can you take a look and give more feedback?

li-xin-yi commented 1 year ago

@pqn Thanks for your comment. I updated the code as you suggested. Now, the new UI looks like:

image

I'm uncertain whether it should be "allow list" or "allowed list" (since I'm not a native English speaker...)

pqn commented 1 year ago

Looks like the rebase or merge had some issue and the commits are showing up in the PR history.

li-xin-yi commented 1 year ago

Update: add the reset button and remove the exit button.

pqn commented 1 year ago

Thanks! 🎉