|
1 | | -# React Content Script |
| 1 | +# React TypeScript Chrome Extension |
2 | 2 |
|
3 | | -<img width="895" alt="Screen Shot 2022-06-18 at 10 04 04 AM" src="https://user-images.githubusercontent.com/16216104/174416528-6e5ad272-5faa-41d4-a717-c210ed4924b0.png"> |
| 3 | +This repository includes examples of how to set up a Chrome Extension with React and TypeScript. |
| 4 | + |
| 5 | +This project uses [Vite](https://vitejs.dev/) and [crxjs](https://crxjs.dev/vite-plugin) to build the extension. |
| 6 | + |
| 7 | +## Setup |
| 8 | + |
| 9 | +### Clone repository |
| 10 | +```sh |
| 11 | +git clone git@github.com:yosevu/react-content-script.git |
| 12 | +``` |
| 13 | + |
| 14 | +### Install dependencies |
| 15 | + |
| 16 | +```sh |
| 17 | +yarn |
| 18 | +``` |
| 19 | + |
| 20 | +### Build extension |
| 21 | + |
| 22 | +``` |
| 23 | +yarn build |
| 24 | +``` |
4 | 25 |
|
5 | | -How to inject [React](https://reactjs.org/) app into a Chrome Extension [Content Script](https://developer.chrome.com/docs/extensions/mv3/content_scripts/). |
| 26 | +### Load extension |
6 | 27 |
|
7 | | -1. `git clone git@github.com:yosevu/react-content-script.git` |
8 | | -1. `yarn build` |
9 | 28 | 1. Navigate to [chrome://extensions/](chrome://extensions/) |
10 | | -1. Click the "Developer mode" toggle switch in the top right of the window |
| 29 | +1. Turn on the "Developer mode" toggle switch in the top right of the window |
11 | 30 | 1. Click the "Load unpacked" button in top left of the window |
12 | | -1. Go to the react-content-script directory and select the "dist" directory to load the extension |
| 31 | +1. Go to the `react-content-script` directory and select the `dist` directory to load the extension |
13 | 32 | 1. Navigate to https://blank.org/ to see the Content Script React app |
14 | | -1. Click on the "React Content Script" extensions to see the Popup React app |
| 33 | +1. Go to extensions and click "React TypeScript Chrome Extension" to see the Popup React app |
| 34 | + |
| 35 | +## [Popup](https://developer.chrome.com/docs/extensions/mv3/user_interface/#popup) |
| 36 | + |
| 37 | +The popup source code is at the root directory. |
| 38 | + |
| 39 | +## [Content Script](https://developer.chrome.com/docs/extensions/mv3/content_scripts/) |
| 40 | + |
| 41 | +The content script source code is in the `content-script` directory. |
| 42 | + |
| 43 | +<img width="895" alt="Screen Shot 2022-06-18 at 10 04 04 AM" src="https://user-images.githubusercontent.com/16216104/174416528-6e5ad272-5faa-41d4-a717-c210ed4924b0.png"> |
| 44 | + |
| 45 | +## Background |
| 46 | + |
| 47 | +This repository was originally part of [How to inject a React app into a Chrome Extension as a Content Script](https://medium.com/@yosevu/how-to-inject-a-react-app-into-a-chrome-extension-as-a-content-script-3a038f611067). |
0 commit comments