-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
420 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: "Build extension" | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Cache pnpm modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules/ | ||
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}- | ||
- name: Use Node.js 16.x | ||
uses: actions/setup-node@v3.4.1 | ||
with: | ||
node-version: 16.x | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Build the extension | ||
run: npm run build -- --zip | ||
|
||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: Extension | ||
path: build/chrome-mv3-prod.zip |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
import { Storage } from "@plasmohq/storage" | ||
import { Assistent } from "openapi/assistent"; | ||
import { Storage } from "@plasmohq/storage"; | ||
import { OpenAI } from "provides/openai"; | ||
import { Telegram } from "provides/telegram"; | ||
|
||
|
||
const main = async () => { | ||
const storage = new Storage(); | ||
|
||
const openaiKey = await storage.get("openaiKey"); | ||
const openaiModel = await storage.get("openaiModel"); | ||
const ai = new Assistent(openaiKey, openaiModel); | ||
const ai = new OpenAI(openaiKey, openaiModel); | ||
|
||
const tgBotToken = await storage.get("tgBotToken"); | ||
const tgChatId = await storage.get("tgChatId"); | ||
const tg = new Telegram(tgBotToken, tgChatId) | ||
|
||
storage.watch({ | ||
"openaiKey": (c) => ai.setApiKey(c.newValue), | ||
"openaiModel": (c) => ai.setModel(c.newValue), | ||
"tgBotToken": (c) => tg.setBotToken(c.newValue), | ||
"tgChatId": (c) => tg.setChatId(c.newValue), | ||
}) | ||
|
||
chrome.runtime.onMessage.addListener(async (message, _, sendResponse) => | ||
await ai.getAnswer(message, sendResponse)); | ||
chrome.runtime.onMessage.addListener(async (message, sender, sendResponse) => { | ||
tg.setTabId(sender.tab.id); | ||
|
||
const answer = await ai.getAnswer(message, sendResponse); | ||
await tg.sendQuestion(message, answer); | ||
}); | ||
|
||
// long polling updates | ||
await tg.pollUpdates(); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { v4 as uuidv4 } from 'uuid'; | ||
import { nanoid } from 'domain/uuid'; | ||
|
||
export class GFOption { | ||
id: string; | ||
el: HTMLElement; | ||
|
||
constructor(el: HTMLElement) { | ||
this.id = uuidv4(); | ||
this.id = nanoid(); | ||
this.el = el; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { customAlphabet } from 'nanoid' | ||
|
||
export const nanoid = customAlphabet('1234567890abcdef', 10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.