vg-coder-cli 2.0.22 → 2.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/.vg/tree-state.json +9 -0
  2. package/package.json +3 -1
  3. package/scripts/build.js +49 -6
  4. package/src/server/api-server.js +46 -0
  5. package/src/server/views/css/structure.css +4 -1
  6. package/src/server/views/dashboard.css +24 -1
  7. package/src/server/views/dashboard.html +2 -0
  8. package/src/server/views/js/api.js +24 -0
  9. package/src/server/views/js/features/resize.js +57 -0
  10. package/src/server/views/js/features/structure.js +109 -16
  11. package/src/server/views/js/main.js +5 -0
  12. package/src/server/views/vg-coder/background.js +48201 -2
  13. package/src/server/views/vg-coder/controller.js +496 -1
  14. package/src/server/views/vg-coder/manifest.json +13 -5
  15. package/src/server/views/vg-coder/{options.css → sidepanel.css} +34 -32
  16. package/src/server/views/vg-coder/{options.html → sidepanel.html} +2 -2
  17. package/src/server/views/vg-coder/sidepanel.js +347 -0
  18. package/vetgo-auto/README.md +3 -0
  19. package/vetgo-auto/chrome/CSP_IMPROVEMENTS.md +147 -0
  20. package/vetgo-auto/chrome/MANIFEST_V3_MIGRATION.md +123 -0
  21. package/vetgo-auto/chrome/assets/icon128.png +0 -0
  22. package/vetgo-auto/chrome/assets/icon16.png +0 -0
  23. package/vetgo-auto/chrome/assets/icon48.png +0 -0
  24. package/vetgo-auto/chrome/environments/environment.ts +13 -0
  25. package/vetgo-auto/chrome/manifest.json +66 -0
  26. package/vetgo-auto/chrome/rules.json +23 -0
  27. package/vetgo-auto/chrome/src/background.ts +200 -0
  28. package/vetgo-auto/chrome/src/controller.ts +98 -0
  29. package/vetgo-auto/chrome/src/controllers/common.firebase.ts +31 -0
  30. package/vetgo-auto/chrome/src/controllers/firebase-crud.ts +147 -0
  31. package/vetgo-auto/chrome/src/controllers/load-common-fuc.controller.ts +24 -0
  32. package/vetgo-auto/chrome/src/controllers/load-script.controller.ts +23 -0
  33. package/vetgo-auto/chrome/src/script-injector.ts +305 -0
  34. package/vetgo-auto/chrome/src/sidepanel.css +166 -0
  35. package/vetgo-auto/chrome/src/sidepanel.html +48 -0
  36. package/vetgo-auto/chrome/src/sidepanel.ts +127 -0
  37. package/vetgo-auto/chrome/src/utils/db-utils.ts +2 -0
  38. package/vetgo-auto/chrome/src/utils/environment-storage.service.ts +85 -0
  39. package/vetgo-auto/chrome/webpack.config.js +53 -0
  40. package/vetgo-auto/chrome/webpack.config.prod.js +54 -0
  41. package/vetgo-auto/package.json +30 -0
  42. package/vetgo-auto/tsconfig.json +27 -0
  43. package/vg-coder-cli-2.0.23.tgz +0 -0
  44. package/src/server/views/vg-coder/background.js.LICENSE.txt +0 -118
  45. package/src/server/views/vg-coder/options.js +0 -1
  46. package/vg-coder-cli-2.0.21.tgz +0 -0
  47. package/vg-coder-cli-2.0.22.tgz +0 -0
  48. package/vg-coder.zip +0 -0
@@ -0,0 +1,48 @@
1
+ <!DOCTYPE html>
2
+ <html lang="vi">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>VetGo Pro - Cấu hình</title>
8
+ <link rel="stylesheet" href="sidepanel.css">
9
+ </head>
10
+
11
+ <body>
12
+ <div class="container">
13
+ <h1>⚙️ Cấu hình VetGo Pro</h1>
14
+ <p class="subtitle">Quản lý cài đặt môi trường cho extension</p>
15
+
16
+ <div id="message" class="message"></div>
17
+
18
+ <div class="current-value">
19
+ <strong>Môi trường hiện tại:</strong> <span id="currentEnv">Đang tải...</span>
20
+ </div>
21
+
22
+ <form id="configForm">
23
+ <div class="form-group">
24
+ <label for="environmentName">Tên môi trường (Environment Name)</label>
25
+ <input type="text" id="environmentName" name="environmentName"
26
+ placeholder="Nhập tên môi trường (ví dụ: midjourney, production, test)" required />
27
+ <p class="hint">Tên môi trường sẽ được sử dụng để load scripts từ Firebase: ENV/{environmentName}/script</p>
28
+ </div>
29
+
30
+ <div class="form-group">
31
+ <label for="firebaseConfig">Cấu hình Firebase (JSON)</label>
32
+ <textarea id="firebaseConfig" name="firebaseConfig" rows="8"
33
+ placeholder='{"apiKey": "...", "authDomain": "...", "databaseURL": "..."}'
34
+ style="width: 100%; padding: 12px; border: 2px solid #e0e0e0; border-radius: 8px; font-family: monospace; font-size: 13px;"></textarea>
35
+ <p class="hint">Để trống để sử dụng cấu hình mặc định của hệ thống. Nhập JSON object chứa apiKey, authDomain, databaseURL...</p>
36
+ </div>
37
+
38
+ <div class="button-group">
39
+ <button type="submit" class="btn-primary">💾 Lưu cấu hình</button>
40
+ <button type="button" id="resetBtn" class="btn-secondary">🔄 Đặt lại mặc định</button>
41
+ </div>
42
+ </form>
43
+ </div>
44
+
45
+ <script src="sidepanel.js"></script>
46
+ </body>
47
+
48
+ </html>
@@ -0,0 +1,127 @@
1
+ import { EnvironmentStorageService } from './utils/environment-storage.service';
2
+ import { environment } from '../environments/environment';
3
+
4
+ // DOM Elements
5
+ const form = document.getElementById('configForm') as HTMLFormElement;
6
+ const environmentInput = document.getElementById('environmentName') as HTMLInputElement;
7
+ const firebaseConfigInput = document.getElementById('firebaseConfig') as HTMLTextAreaElement;
8
+ const resetBtn = document.getElementById('resetBtn') as HTMLButtonElement;
9
+ const messageDiv = document.getElementById('message') as HTMLDivElement;
10
+ const currentEnvSpan = document.getElementById('currentEnv') as HTMLSpanElement;
11
+
12
+ /**
13
+ * Hiển thị thông báo cho người dùng
14
+ */
15
+ function showMessage(text: string, type: 'success' | 'error') {
16
+ messageDiv.textContent = text;
17
+ messageDiv.className = `message ${type}`;
18
+
19
+ // Tự động ẩn thông báo sau 3 giây
20
+ setTimeout(() => {
21
+ messageDiv.className = 'message';
22
+ }, 3000);
23
+ }
24
+
25
+ /**
26
+ * Load và hiển thị giá trị hiện tại
27
+ */
28
+ async function loadCurrentConfig() {
29
+ try {
30
+ // Load Env Name
31
+ const envName = await EnvironmentStorageService.getEnvironmentName();
32
+ currentEnvSpan.textContent = envName;
33
+ environmentInput.value = envName;
34
+
35
+ // Load Firebase Config
36
+ const fbConfig = await EnvironmentStorageService.getFirebaseConfig();
37
+
38
+ // Kiểm tra xem có phải config mặc định không
39
+ const isDefault = JSON.stringify(fbConfig) === JSON.stringify(environment.firebaseConfig);
40
+
41
+ if (!isDefault) {
42
+ firebaseConfigInput.value = JSON.stringify(fbConfig, null, 2);
43
+ } else {
44
+ firebaseConfigInput.value = ''; // Để trống nếu đang dùng default
45
+ firebaseConfigInput.placeholder = `Đang sử dụng mặc định:\n${JSON.stringify(environment.firebaseConfig, null, 2)}`;
46
+ }
47
+
48
+ } catch (error) {
49
+ console.error('Error loading config:', error);
50
+ currentEnvSpan.textContent = 'Lỗi khi tải cấu hình';
51
+ showMessage('Không thể tải cấu hình hiện tại', 'error');
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Xử lý sự kiện submit form
57
+ */
58
+ async function handleSubmit(event: Event) {
59
+ event.preventDefault();
60
+
61
+ const newEnvName = environmentInput.value.trim();
62
+ const firebaseConfigStr = firebaseConfigInput.value.trim();
63
+
64
+ if (!newEnvName) {
65
+ showMessage('Vui lòng nhập tên môi trường', 'error');
66
+ return;
67
+ }
68
+
69
+ try {
70
+ // 1. Lưu Environment Name
71
+ await EnvironmentStorageService.setEnvironmentName(newEnvName);
72
+ currentEnvSpan.textContent = newEnvName;
73
+
74
+ // 2. Lưu Firebase Config
75
+ if (firebaseConfigStr) {
76
+ try {
77
+ const configObj = JSON.parse(firebaseConfigStr);
78
+ // Validate sơ bộ
79
+ if (!configObj.apiKey || !configObj.databaseURL) {
80
+ throw new Error("Config thiếu apiKey hoặc databaseURL");
81
+ }
82
+ await EnvironmentStorageService.setFirebaseConfig(configObj);
83
+ } catch (e) {
84
+ showMessage('❌ JSON Firebase Config không hợp lệ: ' + (e as Error).message, 'error');
85
+ return;
86
+ }
87
+ } else {
88
+ // Nếu để trống, xóa custom config để dùng default
89
+ await new Promise<void>((resolve) => {
90
+ chrome.storage.sync.remove('firebaseConfig', () => resolve());
91
+ });
92
+ }
93
+
94
+ showMessage('✅ Lưu cấu hình thành công!', 'success');
95
+ // Reload lại hiển thị để update placeholder/value
96
+ loadCurrentConfig();
97
+
98
+ } catch (error) {
99
+ console.error('Error saving settings:', error);
100
+ showMessage('❌ Lỗi khi lưu cấu hình: ' + (error as Error).message, 'error');
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Xử lý sự kiện reset về mặc định
106
+ */
107
+ async function handleReset() {
108
+ if (!confirm('Bạn có chắc muốn đặt lại tất cả về mặc định?')) {
109
+ return;
110
+ }
111
+
112
+ try {
113
+ await EnvironmentStorageService.resetToDefault();
114
+ await loadCurrentConfig(); // Reload UI
115
+ showMessage('✅ Đã đặt lại về cấu hình mặc định!', 'success');
116
+ } catch (error) {
117
+ console.error('Error resetting environment:', error);
118
+ showMessage('❌ Lỗi khi đặt lại cấu hình', 'error');
119
+ }
120
+ }
121
+
122
+ // Event Listeners
123
+ form.addEventListener('submit', handleSubmit);
124
+ resetBtn.addEventListener('click', handleReset);
125
+
126
+ // Load giá trị hiện tại khi trang được mở
127
+ loadCurrentConfig();
@@ -0,0 +1,2 @@
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ export const uuid = (): string => uuidv4();
@@ -0,0 +1,85 @@
1
+ import { environment } from "../../environments/environment";
2
+
3
+ const STORAGE_KEY = 'environmentName';
4
+ const FIREBASE_CONFIG_KEY = 'firebaseConfig';
5
+ const DEFAULT_ENVIRONMENT = environment.environmentName;
6
+
7
+ export class EnvironmentStorageService {
8
+ /**
9
+ * Lấy environment name từ chrome.storage
10
+ */
11
+ static async getEnvironmentName(): Promise<string> {
12
+ return new Promise((resolve) => {
13
+ chrome.storage.sync.get([STORAGE_KEY], (result) => {
14
+ const envName = result[STORAGE_KEY] || DEFAULT_ENVIRONMENT;
15
+ resolve(envName);
16
+ });
17
+ });
18
+ }
19
+
20
+ /**
21
+ * Lưu environment name vào chrome.storage
22
+ */
23
+ static async setEnvironmentName(name: string): Promise<void> {
24
+ return new Promise((resolve, reject) => {
25
+ if (!name || name.trim() === '') {
26
+ reject(new Error('Environment name cannot be empty'));
27
+ return;
28
+ }
29
+
30
+ chrome.storage.sync.set({ [STORAGE_KEY]: name.trim() }, () => {
31
+ if (chrome.runtime.lastError) {
32
+ reject(chrome.runtime.lastError);
33
+ } else {
34
+ resolve();
35
+ }
36
+ });
37
+ });
38
+ }
39
+
40
+ /**
41
+ * Lấy cấu hình Firebase. Ưu tiên storage, fallback về environment mặc định
42
+ */
43
+ static async getFirebaseConfig(): Promise<any> {
44
+ return new Promise((resolve) => {
45
+ chrome.storage.sync.get([FIREBASE_CONFIG_KEY], (result) => {
46
+ const customConfig = result[FIREBASE_CONFIG_KEY];
47
+ if (customConfig && Object.keys(customConfig).length > 0) {
48
+ resolve(customConfig);
49
+ } else {
50
+ resolve(environment.firebaseConfig);
51
+ }
52
+ });
53
+ });
54
+ }
55
+
56
+ /**
57
+ * Lưu cấu hình Firebase tùy chỉnh
58
+ */
59
+ static async setFirebaseConfig(config: any): Promise<void> {
60
+ return new Promise((resolve, reject) => {
61
+ chrome.storage.sync.set({ [FIREBASE_CONFIG_KEY]: config }, () => {
62
+ if (chrome.runtime.lastError) {
63
+ reject(chrome.runtime.lastError);
64
+ } else {
65
+ resolve();
66
+ }
67
+ });
68
+ });
69
+ }
70
+
71
+ /**
72
+ * Reset về giá trị mặc định
73
+ */
74
+ static async resetToDefault(): Promise<void> {
75
+ try {
76
+ await this.setEnvironmentName(DEFAULT_ENVIRONMENT);
77
+ // Xóa config firebase custom để dùng mặc định
78
+ await new Promise<void>((resolve) => {
79
+ chrome.storage.sync.remove(FIREBASE_CONFIG_KEY, () => resolve());
80
+ });
81
+ } catch (e) {
82
+ throw e;
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,53 @@
1
+ const { join } = require('path');
2
+ const CopyWebpackPlugin = require('copy-webpack-plugin');
3
+
4
+ module.exports = {
5
+ mode: 'development',
6
+ devtool: 'inline-source-map',
7
+ entry: {
8
+ background: join(__dirname, 'src/background.ts'),
9
+ controller: join(__dirname, 'src/controller.ts'),
10
+ sidepanel: join(__dirname, 'src/sidepanel.ts'),
11
+ },
12
+ module: {
13
+ rules: [
14
+ {
15
+ test: /\.ts?$/,
16
+ use: 'ts-loader',
17
+ exclude: /node_modules/,
18
+ },
19
+ ],
20
+ },
21
+ output: {
22
+ path: join(__dirname, 'dist'),
23
+ filename: '[name].js'
24
+ },
25
+ plugins: [
26
+ new CopyWebpackPlugin({
27
+ patterns: [
28
+ {
29
+ from: join(__dirname, 'manifest.json'),
30
+ to: join(__dirname, 'dist')
31
+ },
32
+ {
33
+ from: join(__dirname, 'rules.json'),
34
+ to: join(__dirname, 'dist')
35
+ },
36
+ {
37
+ from: join(__dirname, 'src/sidepanel.html'),
38
+ to: join(__dirname, 'dist')
39
+ },
40
+ {
41
+ from: join(__dirname, 'src/sidepanel.css'),
42
+ to: join(__dirname, 'dist')
43
+ },
44
+ {
45
+ from: join(__dirname, 'assets'),
46
+ to: join(__dirname, 'dist/assets')
47
+ }
48
+ ]
49
+ })],
50
+ resolve: {
51
+ extensions: ['.ts', '.js']
52
+ }
53
+ };
@@ -0,0 +1,54 @@
1
+ const { join } = require('path');
2
+ const { optimize } = require('webpack');
3
+ const CopyWebpackPlugin = require('copy-webpack-plugin');
4
+
5
+ module.exports = {
6
+ mode: 'production',
7
+ entry: {
8
+ background: join(__dirname, 'src/background.ts'),
9
+ controller: join(__dirname, 'src/controller.ts'),
10
+ sidepanel: join(__dirname, 'src/sidepanel.ts'),
11
+ },
12
+ module: {
13
+ rules: [
14
+ {
15
+ test: /\.ts?$/,
16
+ use: 'ts-loader',
17
+ exclude: /node_modules/,
18
+ },
19
+ ],
20
+ },
21
+ output: {
22
+ path: join(__dirname, 'dist'),
23
+ filename: '[name].js'
24
+ },
25
+ plugins: [
26
+ new optimize.AggressiveMergingPlugin(),
27
+ new CopyWebpackPlugin({
28
+ patterns: [
29
+ {
30
+ from: join(__dirname, 'manifest.json'),
31
+ to: join(__dirname, 'dist')
32
+ },
33
+ {
34
+ from: join(__dirname, 'rules.json'),
35
+ to: join(__dirname, 'dist')
36
+ },
37
+ {
38
+ from: join(__dirname, 'src/sidepanel.html'),
39
+ to: join(__dirname, 'dist')
40
+ },
41
+ {
42
+ from: join(__dirname, 'src/sidepanel.css'),
43
+ to: join(__dirname, 'dist')
44
+ },
45
+ {
46
+ from: join(__dirname, 'assets'),
47
+ to: join(__dirname, 'dist/assets')
48
+ }
49
+ ]
50
+ })],
51
+ resolve: {
52
+ extensions: ['.ts', '.js']
53
+ }
54
+ };
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "vg-coder",
3
+ "version": "1.0.0",
4
+ "author": "VetGo",
5
+ "description": "Vg Coder",
6
+ "scripts": {
7
+ "clean": "rimraf chrome/dist",
8
+ "build": "npm run clean && webpack --config chrome/webpack.config.js",
9
+ "build:prod": "npm run clean && webpack --config chrome/webpack.config.prod.js && npm run pack",
10
+ "pack": "cd chrome/dist && bestzip ../../vg-coder.zip *"
11
+ },
12
+ "dependencies": {
13
+ "firebase": "^9.17.2",
14
+ "js-sha256": "^0.9.0",
15
+ "lodash": "^4.17.21",
16
+ "rxjs": "~7.8.0",
17
+ "tslib": "^2.4.1",
18
+ "uuid": "^9.0.0"
19
+ },
20
+ "devDependencies": {
21
+ "@types/chrome": "^0.0.209",
22
+ "bestzip": "^2.2.1",
23
+ "copy-webpack-plugin": "^11.0.0",
24
+ "rimraf": "^4.1.1",
25
+ "ts-loader": "^9.4.2",
26
+ "typescript": "~4.9.5",
27
+ "webpack": "^5.75.0",
28
+ "webpack-cli": "^5.0.1"
29
+ }
30
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": "./",
4
+ "outDir": "./dist/out-tsc",
5
+ "sourceMap": true,
6
+ "declaration": false,
7
+ "moduleResolution": "node",
8
+ "emitDecoratorMetadata": true,
9
+ "experimentalDecorators": true,
10
+ "target": "es6",
11
+ "typeRoots": [
12
+ "node_modules/@types"
13
+ ],
14
+ "lib": [
15
+ "es2018",
16
+ "dom"
17
+ ]
18
+ },
19
+ "include": [
20
+ "chrome/src/**/*",
21
+ "chrome/environments/**/*"
22
+ ],
23
+ "exclude": [
24
+ "node_modules",
25
+ "angular"
26
+ ]
27
+ }
Binary file
@@ -1,118 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- /**
19
- * @license
20
- * Copyright 2018 Google LLC
21
- *
22
- * Licensed under the Apache License, Version 2.0 (the "License");
23
- * you may not use this file except in compliance with the License.
24
- * You may obtain a copy of the License at
25
- *
26
- * http://www.apache.org/licenses/LICENSE-2.0
27
- *
28
- * Unless required by applicable law or agreed to in writing, software
29
- * distributed under the License is distributed on an "AS IS" BASIS,
30
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31
- * See the License for the specific language governing permissions and
32
- * limitations under the License.
33
- */
34
-
35
- /**
36
- * @license
37
- * Copyright 2019 Google LLC
38
- *
39
- * Licensed under the Apache License, Version 2.0 (the "License");
40
- * you may not use this file except in compliance with the License.
41
- * You may obtain a copy of the License at
42
- *
43
- * http://www.apache.org/licenses/LICENSE-2.0
44
- *
45
- * Unless required by applicable law or agreed to in writing, software
46
- * distributed under the License is distributed on an "AS IS" BASIS,
47
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
- * See the License for the specific language governing permissions and
49
- * limitations under the License.
50
- */
51
-
52
- /**
53
- * @license
54
- * Copyright 2020 Google LLC
55
- *
56
- * Licensed under the Apache License, Version 2.0 (the "License");
57
- * you may not use this file except in compliance with the License.
58
- * You may obtain a copy of the License at
59
- *
60
- * http://www.apache.org/licenses/LICENSE-2.0
61
- *
62
- * Unless required by applicable law or agreed to in writing, software
63
- * distributed under the License is distributed on an "AS IS" BASIS,
64
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
65
- * See the License for the specific language governing permissions and
66
- * limitations under the License.
67
- */
68
-
69
- /**
70
- * @license
71
- * Copyright 2021 Google LLC
72
- *
73
- * Licensed under the Apache License, Version 2.0 (the "License");
74
- * you may not use this file except in compliance with the License.
75
- * You may obtain a copy of the License at
76
- *
77
- * http://www.apache.org/licenses/LICENSE-2.0
78
- *
79
- * Unless required by applicable law or agreed to in writing, software
80
- * distributed under the License is distributed on an "AS IS" BASIS,
81
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
82
- * See the License for the specific language governing permissions and
83
- * limitations under the License.
84
- */
85
-
86
- /**
87
- * @license
88
- * Copyright 2022 Google LLC
89
- *
90
- * Licensed under the Apache License, Version 2.0 (the "License");
91
- * you may not use this file except in compliance with the License.
92
- * You may obtain a copy of the License at
93
- *
94
- * http://www.apache.org/licenses/LICENSE-2.0
95
- *
96
- * Unless required by applicable law or agreed to in writing, software
97
- * distributed under the License is distributed on an "AS IS" BASIS,
98
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
99
- * See the License for the specific language governing permissions and
100
- * limitations under the License.
101
- */
102
-
103
- /**
104
- * @license
105
- * Copyright 2023 Google LLC
106
- *
107
- * Licensed under the Apache License, Version 2.0 (the "License");
108
- * you may not use this file except in compliance with the License.
109
- * You may obtain a copy of the License at
110
- *
111
- * http://www.apache.org/licenses/LICENSE-2.0
112
- *
113
- * Unless required by applicable law or agreed to in writing, software
114
- * distributed under the License is distributed on an "AS IS" BASIS,
115
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
116
- * See the License for the specific language governing permissions and
117
- * limitations under the License.
118
- */
@@ -1 +0,0 @@
1
- (()=>{"use strict";const e={apiKey:"AIzaSyDrpNMso-DXeN7c4vwbpV0idpxnV2vtXhQ",authDomain:"vetgo-chrome.firebaseapp.com",databaseURL:"https://vetgo-chrome-default-rtdb.asia-southeast1.firebasedatabase.app",projectId:"vetgo-chrome",storageBucket:"vetgo-chrome.appspot.com",messagingSenderId:"211178224097",appId:"1:211178224097:web:f73bf5a81c2f4c32fc7aa0"};var t=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(c,s)}a((r=r.apply(e,t||[])).next())})};const n="environmentName",r="firebaseConfig",o="VGCODER";class i{static getEnvironmentName(){return t(this,void 0,void 0,function*(){return new Promise(e=>{chrome.storage.sync.get([n],t=>{const r=t[n]||o;e(r)})})})}static setEnvironmentName(e){return t(this,void 0,void 0,function*(){return new Promise((t,r)=>{e&&""!==e.trim()?chrome.storage.sync.set({[n]:e.trim()},()=>{chrome.runtime.lastError?r(chrome.runtime.lastError):t()}):r(new Error("Environment name cannot be empty"))})})}static getFirebaseConfig(){return t(this,void 0,void 0,function*(){return new Promise(t=>{chrome.storage.sync.get([r],n=>{const o=n[r];o&&Object.keys(o).length>0?t(o):t(e)})})})}static setFirebaseConfig(e){return t(this,void 0,void 0,function*(){return new Promise((t,n)=>{chrome.storage.sync.set({[r]:e},()=>{chrome.runtime.lastError?n(chrome.runtime.lastError):t()})})})}static resetToDefault(){return t(this,void 0,void 0,function*(){try{yield this.setEnvironmentName(o),yield new Promise(e=>{chrome.storage.sync.remove(r,()=>e())})}catch(e){throw e}})}}var c=function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function c(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(c,s)}a((r=r.apply(e,t||[])).next())})};const s=document.getElementById("configForm"),a=document.getElementById("environmentName"),u=document.getElementById("firebaseConfig"),m=document.getElementById("resetBtn"),h=document.getElementById("message"),f=document.getElementById("currentEnv");function d(e,t){h.textContent=e,h.className=`message ${t}`,setTimeout(()=>{h.className="message"},3e3)}function g(){return c(this,void 0,void 0,function*(){try{const t=yield i.getEnvironmentName();f.textContent=t,a.value=t;const n=yield i.getFirebaseConfig();JSON.stringify(n)===JSON.stringify(e)?(u.value="",u.placeholder=`Đang sử dụng mặc định:\n${JSON.stringify(e,null,2)}`):u.value=JSON.stringify(n,null,2)}catch(e){console.error("Error loading config:",e),f.textContent="Lỗi khi tải cấu hình",d("Không thể tải cấu hình hiện tại","error")}})}s.addEventListener("submit",function(e){return c(this,void 0,void 0,function*(){e.preventDefault();const t=a.value.trim(),n=u.value.trim();if(t)try{if(yield i.setEnvironmentName(t),f.textContent=t,n)try{const e=JSON.parse(n);if(!e.apiKey||!e.databaseURL)throw new Error("Config thiếu apiKey hoặc databaseURL");yield i.setFirebaseConfig(e)}catch(e){return void d("❌ JSON Firebase Config không hợp lệ: "+e.message,"error")}else yield new Promise(e=>{chrome.storage.sync.remove("firebaseConfig",()=>e())});d("✅ Lưu cấu hình thành công!","success"),g()}catch(e){console.error("Error saving settings:",e),d("❌ Lỗi khi lưu cấu hình: "+e.message,"error")}else d("Vui lòng nhập tên môi trường","error")})}),m.addEventListener("click",function(){return c(this,void 0,void 0,function*(){if(confirm("Bạn có chắc muốn đặt lại tất cả về mặc định?"))try{yield i.resetToDefault(),yield g(),d("✅ Đã đặt lại về cấu hình mặc định!","success")}catch(e){console.error("Error resetting environment:",e),d("❌ Lỗi khi đặt lại cấu hình","error")}})}),g()})();
Binary file
Binary file
package/vg-coder.zip DELETED
Binary file