-
Notifications
You must be signed in to change notification settings - Fork 2
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
5 changed files
with
196 additions
and
1 deletion.
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 wong2 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,43 @@ | ||
# ChatGPT for Baidu | ||
|
||
A browser extension to display ChatGPT response alongside Baidu (and other search engines) results, supports Chrome/Edge/Firefox | ||
|
||
## Supported Search Engines | ||
|
||
Google, Baidu, Bing, DuckDuckGo, Brave, Yahoo, Naver, Yandex, Kagi, Searx | ||
|
||
|
||
|
||
## Installation | ||
|
||
### Install to Chrome/Edge | ||
|
||
|
||
#### Local Install | ||
|
||
1. Download `chromium.zip` from [Releases](https://github.com/xaseven/chat-gpt-baidu-extension/releases). | ||
2. Unzip the file. | ||
3. In Chrome/Edge go to the extensions page (`chrome://extensions` or `edge://extensions`). | ||
4. Enable Developer Mode. | ||
5. Drag the unzipped folder anywhere on the page to import it (do not delete the folder afterwards). | ||
|
||
### Install to Firefox | ||
|
||
|
||
#### Local Install | ||
|
||
1. Download `firefox.zip` from [Releases](https://github.com/xaseven/chat-gpt-baidu-extension/releases). | ||
2. Unzip the file. | ||
3. Go to `about:debugging`, click "This Firefox" on the sidebar. | ||
4. Click "Load Temporary Add-on" button, then select any file in the unzipped folder. | ||
|
||
## Build from source | ||
|
||
1. Clone the repo | ||
2. Install dependencies with `npm` | ||
3. `npm run build` | ||
4. Load `build/chromium/` or `build/firefox/` directory to your browser | ||
|
||
## Credit | ||
|
||
This project is inspired by [ZohaibAhmed/ChatGPT-Google](https://github.com/ZohaibAhmed/ChatGPT-Google) |
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,85 @@ | ||
import archiver from 'archiver' | ||
import { sassPlugin } from 'esbuild-sass-plugin' | ||
import esbuild from 'esbuild' | ||
import fs, { promises as fsPromises } from 'fs' | ||
|
||
const outdir = 'build' | ||
|
||
async function deleteOldDir() { | ||
await fsPromises.rm(outdir, { recursive: true, force: true }) | ||
} | ||
|
||
async function runEsbuild() { | ||
await esbuild.build({ | ||
entryPoints: [ | ||
'src/content-script/index.jsx', | ||
'src/background/index.mjs', | ||
'src/popup/index.jsx', | ||
], | ||
bundle: true, | ||
outdir: outdir, | ||
treeShaking: true, | ||
minify: true, | ||
define: { | ||
'process.env.NODE_ENV': '"production"', | ||
}, | ||
jsxFactory: 'h', | ||
jsxFragment: 'Fragment', | ||
jsx: 'automatic', | ||
plugins: [sassPlugin()], | ||
}) | ||
} | ||
|
||
async function zipFolder(dir) { | ||
const output = fs.createWriteStream(`${dir}.zip`) | ||
const archive = archiver('zip', { | ||
zlib: { level: 9 }, | ||
}) | ||
archive.pipe(output) | ||
archive.directory(dir, false) | ||
await archive.finalize() | ||
} | ||
|
||
async function copyFiles(entryPoints, targetDir) { | ||
await fsPromises.mkdir(targetDir) | ||
await Promise.all( | ||
entryPoints.map(async (entryPoint) => { | ||
await fsPromises.copyFile(entryPoint.src, `${targetDir}/${entryPoint.dst}`) | ||
}), | ||
) | ||
} | ||
|
||
async function build() { | ||
await deleteOldDir() | ||
await runEsbuild() | ||
|
||
const commonFiles = [ | ||
{ src: 'build/content-script/index.js', dst: 'content-script.js' }, | ||
{ src: 'build/content-script/index.css', dst: 'content-script.css' }, | ||
{ src: 'build/background/index.js', dst: 'background.js' }, | ||
{ src: 'build/popup/index.js', dst: 'popup.js' }, | ||
{ src: 'build/popup/index.css', dst: 'popup.css' }, | ||
{ src: 'src/popup/index.html', dst: 'popup.html' }, | ||
{ src: 'src/logo.png', dst: 'logo.png' }, | ||
] | ||
|
||
// chromium | ||
await copyFiles( | ||
[...commonFiles, { src: 'src/manifest.json', dst: 'manifest.json' }], | ||
`./${outdir}/chromium`, | ||
) | ||
|
||
await zipFolder(`./${outdir}/chromium`) | ||
|
||
// firefox | ||
await copyFiles( | ||
[...commonFiles, { src: 'src/manifest.v2.json', dst: 'manifest.json' }], | ||
`./${outdir}/firefox`, | ||
) | ||
|
||
await zipFolder(`./${outdir}/firefox`) | ||
|
||
console.log('Build success.') | ||
} | ||
|
||
build() |
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,46 @@ | ||
{ | ||
"name": "chat-gpt-google-extension", | ||
"author": "wong2", | ||
"scripts": { | ||
"build": "node build.mjs", | ||
"lint": "eslint --ext .js,.mjs,.jsx .", | ||
"lint:fix": "eslint --ext .js,.mjs,.jsx . --fix", | ||
"prepare": "husky install", | ||
"watch": "chokidar src -c 'npm run build'" | ||
}, | ||
"dependencies": { | ||
"@picocss/pico": "^1.5.6", | ||
"@primer/octicons-react": "^17.9.0", | ||
"chokidar-cli": "^3.0.0", | ||
"esbuild-sass-plugin": "^2.4.3", | ||
"eventsource-parser": "^0.0.5", | ||
"expiry-map": "^2.0.0", | ||
"github-markdown-css": "^5.1.0", | ||
"preact": "^10.11.3", | ||
"prop-types": "^15.8.1", | ||
"punycode": "^2.1.1", | ||
"react": "npm:@preact/compat@^17.1.2", | ||
"react-dom": "npm:@preact/compat@^17.1.2", | ||
"react-markdown": "^8.0.4", | ||
"rehype-highlight": "^6.0.0", | ||
"uuid": "^9.0.0" | ||
}, | ||
"devDependencies": { | ||
"archiver": "^5.3.1", | ||
"esbuild": "^0.16.4", | ||
"eslint": "^8.29.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-react": "^7.31.11", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"husky": "^8.0.0", | ||
"lint-staged": "^13.1.0", | ||
"prettier": "^2.8.0", | ||
"webextension-polyfill": "^0.10.0" | ||
}, | ||
"lint-staged": { | ||
"**/*.{js,jsx,ts,tsx,mjs}": [ | ||
"npx prettier --write", | ||
"npx eslint --fix" | ||
] | ||
} | ||
} |
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