Skip to content

Commit 745841a

Browse files
committed
Update Getting Started
1 parent 819db08 commit 745841a

7 files changed

+138
-132
lines changed

docs/en/docs/getting-started/_meta.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"label": "Create Your First Extension"
99
},
1010
{
11-
"name": "remote-extension-execution",
12-
"label": "Remote Extension Execution"
11+
"name": "run-remote-extensions",
12+
"label": "Run Remote Extensions"
1313
},
1414
{
1515
"name": "templates",

docs/en/docs/getting-started/create-your-first-extension.mdx

+36-35
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Take a common task for some developers: searching on GitHub.
88

99
**The problem:** I want to search on GitHub in the most convenient way. Imagine searching GitHub projects directly from your browser's URL bar.
1010

11-
The solution? Meet `github_search`, a tool that makes this possible.
11+
The solution? Meet github_search, a tool that makes this possible.
1212

1313
![howiwant.png](../../../../assets/getting-started/howiwant.png)
1414

1515
## The Plan
1616

17-
Our goal is to make searching GitHub projects as easy as searching on Google. To avoid irrelevant searches when the user decides to search something else, let's reserve a keyword for our extension: if the user types "gh", followed by a tab click, will activate our extension to trigger our search.
17+
Our goal is to make searching GitHub projects as easy as searching on Google. To avoid irrelevant searches when the user decides to search for something else, let's reserve a keyword for our extension: if the user types "gh," followed by a tab click, it will activate our extension to trigger the search.
1818

1919
![search.png](../../../../assets/getting-started/search.png)
2020

@@ -32,12 +32,11 @@ Let's use the Extension.js `create` command to bootstrap a minimal extension for
3232
}}
3333
/>
3434

35-
## Step 1 - Create the manifest file
35+
## Step 2 - Create the manifest file
3636

3737
<div style={{ position: "relative", paddingBottom: "62.5%", height: 0 }}>
3838
<iframe
3939
src="https://www.loom.com/embed/1193dc69f7b74a56a5f5d9e0324c255d?sid=99132929-4c05-40e7-b804-3f242daf95ea"
40-
frameBorder="0"
4140
allowFullScreen
4241
style={{
4342
position: "absolute",
@@ -49,38 +48,38 @@ Let's use the Extension.js `create` command to bootstrap a minimal extension for
4948
></iframe>
5049
</div>
5150

52-
> Step 1 Demo
51+
> Step 2 Demo
5352
54-
Every extension starts with a manifest file. It tells the browser information about the extension's metadata, permissions, and files that the extension needs to run properly. Based on the [plan above](#plan), we want a custom search shortcut "gh" that will link us to GitHub search. We are also adding a service_worker script to handle user events logic.
53+
Every extension starts with a manifest file. It tells the browser information about the extension's metadata, permissions, and files that the extension needs to run properly. Based on the [plan above](#plan), we want a custom search shortcut "gh" that will link us to GitHub search. We are also adding a service worker script to handle user events logic.
5554

56-
```jsx
55+
```json
5756
{
5857
"manifest_version": 3,
5958
"name": "GitHub Search",
6059
"version": "1.0",
61-
"omnibox": {"keyword" : "gh"},
60+
"omnibox": { "keyword": "gh" },
6261
"background": {
6362
"service_worker": "service_worker.js"
6463
}
6564
}
6665
```
6766

68-
- `omnibox.keyword` when the keyword `gh` is set, an event will be fired.
69-
- `background.service_worker` will listen to the event that we just fired.
67+
- `omnibox.keyword`: When the keyword `gh` is set, an event will be fired.
68+
- `background.service_worker`: Will listen to the event that we just fired.
7069

71-
## Step 2 - Create the Background Service Worker
70+
## Step 3 - Create the Background Service Worker
7271

73-
In the context of a browser extension, the background service worker is where the extension can set listeners for all sorts of browser events.
72+
In the context of a browser extension, the background service worker is where the extension can set listeners for various browser events.
7473

7574
In our case, we need to add a script that listens to input events in the omnibox, so once the user types what they want to search, GitHub can return the correct data.
7675

7776
Let's create a `service_worker.js` file for this purpose:
7877

7978
```js
80-
// When the user has accepted what is typed into the omnibox.
79+
When the user has accepted what is typed into the omnibox.
8180
chrome.omnibox.onInputEntered.addListener((text) => {
82-
// Convert any special character (spaces, &, ?, etc)
83-
// into a valid character for the URL format.
81+
Convert any special character (spaces, &, ?, etc)
82+
into a valid character for the URL format.
8483
const encodedSearchText = encodeURIComponent(text);
8584
const url = `https://github.com/search?q=${encodedSearchText}&type=issues`;
8685

@@ -90,13 +89,12 @@ chrome.omnibox.onInputEntered.addListener((text) => {
9089
9190
The script above will open a new tab with GitHub search results whenever you enter something after "gh" in the URL bar.
9291
93-
## Step 3 - Load Your Extension
92+
## Step 4 - Load Your Extension
9493
9594
If you take a look at your `package.json` file now, it looks more or less like this:
9695
9796
```json
9897
{
99-
// ...your extension metadata
10098
"scripts": {
10199
"dev": "extension@latest dev",
102100
"start": "extension start",
@@ -110,16 +108,19 @@ If you take a look at your `package.json` file now, it looks more or less like t
110108
111109
These scripts are the main scripts used by Extension.js for development mode. To preview your extension, let's run it for the first time.
112110
113-
```
114-
npm run dev
115-
```
111+
<PackageManagerTabs
112+
command={{
113+
npm: "npm run dev",
114+
pnpm: "pnpm run dev",
115+
yarn: "yarn run dev",
116+
}}
117+
/>
116118
117119
If all goes well, you should see a screen like the following:
118120
119121
<div style={{ position: "relative", paddingBottom: "62.5%", height: 0 }}>
120122
<iframe
121123
src="https://www.loom.com/embed/777544977a32444ba6de4ff23bdaccbc?sid=360eb1b1-af3a-480b-9e71-41a7fb01ca6e"
122-
frameBorder="0"
123124
allowFullScreen
124125
style={{
125126
position: "absolute",
@@ -133,18 +134,18 @@ If all goes well, you should see a screen like the following:
133134
134135
That's it! You created your first browser extension that searches on GitHub!
135136
136-
## Step 4 - Making It Better
137+
## Step 5 - Making It Better
137138
138-
To make our search results even better, let's add search suggestions directly in the URL bar by listening to input changes in the omnibox.
139+
To improve our search results, let's add search suggestions directly in the URL bar by listening to input changes in the omnibox.
139140
140-
Update the `service_worker.js` file to start fetching suggestions from GitHub and display them as you type.
141+
Update the `service_worker.js` file to fetch suggestions from GitHub and display them as you type.
141142
142143
```js
143-
// service_worker.js
144+
service_worker.js
144145

145-
// Create a debounce function to avoid excessive
146-
// calls to the GitHub API while the user is still
147-
// typing the search query.
146+
Create a debounce function to avoid excessive
147+
calls to the GitHub API while the user is still
148+
typing the search query.
148149
function debounce(fn, delay) {
149150
let timeoutID;
150151
return function (...args) {
@@ -153,7 +154,7 @@ function debounce(fn, delay) {
153154
};
154155
}
155156

156-
// When the user has changed what is typed into the omnibox.
157+
When the user has changed what is typed into the omnibox.
157158
chrome.omnibox.onInputChanged.addListener(
158159
debounce(async (text, suggest) => {
159160
const response = await fetch(
@@ -169,18 +170,18 @@ chrome.omnibox.onInputChanged.addListener(
169170
}, 250),
170171
);
171172

172-
// When the user has accepted what is typed into the omnibox.
173+
When the user has accepted what is typed into the omnibox.
173174
chrome.omnibox.onInputEntered.addListener((text) => {
174-
// Convert any special character (spaces, &, ?, etc)
175-
// into a valid character for the URL format.
175+
Convert any special character (spaces, &, ?, etc)
176+
into a valid character for the URL format.
176177
const encodedSearchText = encodeURIComponent(text);
177178
const url = `https://github.com/search?q=${encodedSearchText}&type=issues`;
178179

179180
chrome.tabs.create({ url });
180181
});
181182
```
182183
183-
Adding this code will let you see live search suggestions from GitHub right in your URL bar, making the search experience almost instant. Here is how it looks like when I type "undefined is not a function":
184+
Adding this code will let you see live search suggestions from GitHub right in your URL bar, making the search experience even smoother.
184185
185186
![Updated result](./../../../../assets/getting-started/updated-result.png)
186187
@@ -192,5 +193,5 @@ Congratulations! You've built a GitHub search extension. Experiment with it, imp
192193
193194
## Next Steps
194195
195-
- Learn how to load locally remotely hosted extensions in [Remote Extension Execution](../getting-started/remote-extension-execution).
196-
- Create an extension using one of `Extension` [Templates](../getting-started/templates).
196+
- Learn how to load remotely hosted extensions in [Remote Extension Execution](../getting-started/remote-extension-execution).
197+
- Create an extension using one of Extension.js [Templates](../getting-started/templates).

docs/en/docs/getting-started/get-started-immediately.mdx

+39-30
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { PackageManagerTabs } from "@theme";
22

33
# 🔥 Get Started Immediately
44

5-
Welcome to the fast track of browser extension@latest development with `Extension`! Whether you're looking to prototype quickly or delve into full-scale development, you've made the right choice. Let's get your development environment set up and running in no time.
5+
Welcome to the fast track for developing cross-browser extensions with Extension.js. Whether youre quickly prototyping or working on full-scale development, this guide will help you get started right away.
66

77
## Kickstart Any Sample from Chrome Extension Samples
88

9-
Dive right into development by starting with a sample from the Chrome Extension Samples repository. It's a great way to get acquainted with best practices and save time:
9+
Start development by using a sample from the Chrome Extension Samples repository. It's a great way to learn best practices and save time.
1010

1111
1. Open your terminal.
12-
2. Navigate to the directory where you want your project.
13-
3. Run the command:
12+
2. Navigate to the directory where you want to create your project.
13+
3. Run the following command:
1414

1515
<PackageManagerTabs
1616
command={{
@@ -20,14 +20,13 @@ Dive right into development by starting with a sample from the Chrome Extension
2020
}}
2121
/>
2222

23-
**Note:** Replace `<sample-name>` with the name of the sample you wish to use from [Chrome Extension Samples](https://github.com/GoogleChrome/chrome-extensions-samples).
23+
**Note:** Replace `<sample-name>` with the sample you want to use from [Chrome Extension Samples](https://github.com/GoogleChrome/chrome-extensions-samples).
2424

25-
See the example below where we request the sample [page-redder](https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/functional-samples/sample.page-redder) from [Google Chrome Extension Samples](https://github.com/GoogleChrome/chrome-extensions-samples).
25+
See the example below, where we request the [page-redder sample](https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/functional-samples/sample.page-redder) from [Google Chrome Extension Samples](https://github.com/GoogleChrome/chrome-extensions-samples).
2626

2727
<div style={{ position: "relative", paddingBottom: "62.5%", height: 0 }}>
2828
<iframe
2929
src="https://www.loom.com/embed/34fc48f3f7954bfa990e767c6a7172f0?sid=346f6a11-58d6-48a4-8935-aac8119d765d"
30-
frameBorder="0"
3130
allowFullScreen
3231
style={{
3332
position: "absolute",
@@ -39,24 +38,29 @@ See the example below where we request the sample [page-redder](https://github.c
3938
></iframe>
4039
</div>
4140

42-
## Use `Microsoft Edge` to Kickstart Any Sample
41+
## Use Microsoft Edge to Kickstart Any Sample
4342

44-
`Extension` supports a variety of browsers, including Microsoft Edge. To start an Edge-compatible extension, simply:
43+
Extension.js supports a variety of browsers, including Microsoft Edge. To start an Edge-compatible extension, follow these steps:
4544

4645
1. Open your terminal.
47-
2. Navigate to your desired project directory.
48-
3. Execute:
49-
```bash
50-
npx extension@latest dev <sample-name> --browser=edge
51-
```
52-
Tailor your command by replacing `<sample-name>` with the specific sample you're interested in.
46+
2. Navigate to the directory where you want to create your project.
47+
3. Run this command:
5348

54-
> See the example below where we request the sample [magic8ball](https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/api-samples/topSites/magic8ball) from from [Google Chrome Extension Samples](https://github.com/GoogleChrome/chrome-extensions-samples) using Edge as the runtime browser.
49+
<PackageManagerTabs
50+
command={{
51+
npm: "npx extension@latest dev <sample-name> --browser=edge",
52+
pnpm: "pnpx extension@latest dev <sample-name> --browser=edge",
53+
yarn: "yarn dlx extension <sample-name> --browser=edge",
54+
}}
55+
/>
56+
57+
Replace `<sample-name>` with the sample you want to use.
58+
59+
> In the example below, we request the [magic8ball sample](https://github.com/GoogleChrome/chrome-extensions-samples/tree/main/api-samples/topSites/magic8ball) from [Google Chrome Extension Samples](https://github.com/GoogleChrome/chrome-extensions-samples) using Edge as the target browser.
5560
5661
<div style={{ position: "relative", paddingBottom: "62.5%", height: 0 }}>
5762
<iframe
5863
src="https://www.loom.com/embed/284d706379a84adabfdde6bd341b8d24?sid=24a4a6d5-5b30-4920-8a47-004540183aed"
59-
frameBorder="0"
6064
allowFullScreen
6165
style={{
6266
position: "absolute",
@@ -70,21 +74,26 @@ See the example below where we request the sample [page-redder](https://github.c
7074

7175
## Run Mozilla Add-Ons Using Edge
7276

73-
Bridge the gap between Firefox and Edge by running Mozilla Add-Ons using Edge:
77+
You can also adapt Mozilla Add-Ons to run on Edge:
7478

7579
1. Navigate to your project directory.
76-
2. Use the command:
77-
```bash
78-
npx extension@latest dev <addon-name> --browser=edge --polyfill=true
79-
```
80-
This will fetch a Mozilla Add-On and adapt it for Edge.
80+
2. Run this command:
81+
82+
<PackageManagerTabs
83+
command={{
84+
npm: "npx extension@latest dev <addon-name> --browser=edge --polyfill=true",
85+
pnpm: "pnpx extension@latest dev <addon-name> --browser=edge --polyfill=true",
86+
yarn: "yarn dlx extension <addon-name> --browser=edge --polyfill=true",
87+
}}
88+
/>
89+
90+
This will fetch a Mozilla Add-On and adapt it for Edge.
8191

82-
> See the example below where we request the sample [Apply CSS](https://github.com/mdn/webextensions-examples/tree/main/apply-css) from [MDN WebExtensions Examples](https://github.com/mdn/webextensions-examples) using Edge as the runtime browser.
92+
> Below is an example of fetching the [Apply CSS sample](https://github.com/mdn/webextensions-examples/tree/main/apply-css) from [MDN WebExtensions Examples](https://github.com/mdn/webextensions-examples) and running it on Edge.
8393
8494
<div style={{ position: "relative", paddingBottom: "62.5%", height: 0 }}>
8595
<iframe
8696
src="https://www.loom.com/embed/6eb724aad822413fb4fe9f52afec5576?sid=e2aa47a4-71d4-4ff1-887a-dcf8031ea917"
87-
frameBorder="0"
8897
allowFullScreen
8998
style={{
9099
position: "absolute",
@@ -96,13 +105,13 @@ Bridge the gap between Firefox and Edge by running Mozilla Add-Ons using Edge:
96105
></iframe>
97106
</div>
98107

99-
## Some Tips To Help You Get Started
108+
## Tips to Get Started
100109

101-
- To use TypeScript, add a `tsconfig.json` file to the root of your extension.
102-
- To use React, just ensure you have it as a dependency in your `package.json`.
103-
- Any `tsconfig.json` with React support makes your project React/TypeScript ready.
110+
- To use TypeScript, add a `tsconfig.json` file to the root of your project.
111+
- To use React, add React as a dependency in your `package.json`.
112+
- Any `tsconfig.json` with React support will make your project ready for React and TypeScript.
104113
- If you need to handle assets not declared in the manifest, learn more about [Special Folders](#).
105114

106115
## Next Steps
107116

108-
Start exploring the world of browser extension@latest development with `Extension` by [Create Your First Extension](#).
117+
Start exploring browser extension development with Extension.js by [creating your first extension](#).

0 commit comments

Comments
 (0)