You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: microsoft-edge/extensions-chromium/developer-guide/devtools-extension.md
+27-23Lines changed: 27 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,14 @@ ms.date: 11/12/2024
10
10
---
11
11
# Create a DevTools extension, adding a custom tool tab and panel
12
12
13
-
Part 1: Sample - This article shows how to install and run the provided sample of a DevTools extension, which adds a **Sample Panel**tool tab in DevTools within Microsoft Edge. The sample is a working DevTools extension that creates its own panel, and interacts with the DevTools APIs.
13
+
This article provides a sample and code walkthrough for a Microsoft Edge extension that adds a tool tab and panel in DevTools.
14
14
15
-
Part 2: Tutorial - This article then shows how you can optionally create that sample from scratch, and explains each step of developing the sample, and how the added code works. This tutorial shows how to build your own DevTools extension from scratch. It's a good way to experience everything that's needed for typical development.
15
+
This article first shows how to install and run the provided DevTools extension sample, which adds a **Sample Panel** tool tab in DevTools within Microsoft Edge. The sample is a working DevTools extension that creates its own panel, and interacts with the DevTools APIs.
16
+
17
+
This article then presents a tutorial that shows how you can optionally create that sample from scratch, and explains each step of developing the sample, and how the added code works. These tutorial steps are a good way to experience everything that's needed for typical development.
18
+
19
+
See also:
20
+
*[Overview of DevTools](../../devtools-guide-chromium/overview.md)
@@ -54,24 +59,22 @@ To download, install, run, and test the provided, finished DevTools extension sa
54
59
55
60
A message is displayed in the extension panel: **You clicked on position (199, 509) in the inspected page**:
56
61
57
-

62
+

58
63
59
-
1.Open the **Console** tool. A message appears in the **Console** tool: **Received response > _{xPosition: 199, yPosition: 509}_**:
64
+
1.Select the **Console** tool.
60
65
61
-

62
-
63
-
You downloaded, installed, ran, and tested the provided, finished DevTools extension sample. In the next steps, you create the same sample by starting from an empty directory. The following sections explain how the code works.
66
+
A message appears in the **Console** tool: **Received response > _{xPosition: 199, yPosition: 509}_**:
64
67
68
+

* If not done already, install a code editor such as [Visual Studio Code](https://code.visualstudio.com/), to follow the tutorial steps below to manually re-create the above sample DevTools extension.
70
+
You downloaded, installed, ran, and tested the provided, finished DevTools extension sample. In the next steps, you create the same sample by starting from an empty directory. The following sections explain how the code works.
## Step 1: Create, install, and run a basic Microsoft Edge extension
74
75
76
+
If you want to create the files for each major step below, install a code editor such as [Visual Studio Code](https://code.visualstudio.com/), to follow the tutorial steps below to manually re-create the above sample DevTools extension. You can read the code walkthrough below, presented as four major steps or phases.
77
+
75
78
A basic extension for Microsoft Edge consists of two files, as shown in [Step 1 code](https://github.com/MicrosoftEdge/Demos/tree/main/devtools-extension/sample%201):
76
79
77
80
* A manifest file, containing key/value pairs. The top-level keys are called _members_. In this case, the file is named `manifest.json`:
@@ -236,7 +239,7 @@ To test your changes in Microsoft Edge, reload your extension from the `edge://e
## Step 3: Call extension APIs from a DevTools extension
242
+
## Step 3: Display memory information by calling extension APIs
240
243
241
244
In this step, you will use extension APIs to display memory information in your DevTools panel. To do this, we will need to update the `permissions` in the manifest file, the panel interface, and the devtools script. The source code for this step can be found in [Step 3 code](https://github.com/MicrosoftEdge/Demos/tree/main/devtools-extension/sample%203), or write it yourself by following the instructions below.
## Step 4: Interact between the webpage and DevTools
328
331
329
332
In this step of the tutorial, you will add code that interacts with the inspected webpage. That code will:
330
333
331
334
1. Listen to click events that happen on the webpage and log them into the DevTools **Console** tool.
332
-
1.Show the mouse click position in the DevTools extension panel.
333
-
1.Show a greeting alert inthe inspected page when user clicks a button in the DevTools extension panel.
335
+
1.Display the mouse click position in the DevTools extension panel.
336
+
1.When the user clicks a button in the DevTools extension panel, display a greeting alert in the inspected webpage.
334
337
335
338
You can copy the files that are the end result ofthis step from [Step 4 code](https://github.com/MicrosoftEdge/Demos/tree/main/devtools-extension/sample%204), or create the files yourself by following the instructions below.
336
339
@@ -498,21 +501,22 @@ To test the new `sayHello` button:
498
501
499
502
1. Click the **OK** button to close the alert.
500
503
501
-
See also:
502
-
* [Content scripts](https://developer.chrome.com/docs/extensions/mv3/content_scripts/) in the Chrome Extensions docs.
504
+
1. Click anywhere in the inspected page.
503
505
506
+
A message is displayed in the extension panel:**You clicked on position (199, 509) in the inspected page**:
504
507
505
-
To test the `youClickedOn` label:
508
+

506
509
507
-
1.Click anywhere inthe inspected page.
510
+
1.Select the **Console** tool.
508
511
509
-
A message is displayed in the extension panel:**You clicked on position (199, 509) in the inspected page**:
512
+
A message appears in the **Console** tool:**Received response > _{xPosition:199, yPosition:509}_**:
510
513
511
-

514
+

512
515
513
-
1. Open the **Console**tool. A message appears in the **Console**tool:**Received response > _{xPosition:199, yPosition:509}_**:
516
+
This completes the tutorial and code walkthrough for creating a DevTools extension that adds a tool tab and panel in DevTools in Microsoft Edge.
514
517
515
-

518
+
See also:
519
+
* [Content scripts](https://developer.chrome.com/docs/extensions/mv3/content_scripts/) in the Chrome Extensions docs.
0 commit comments