Convert "Create a DevTools extension" to sample-based#3616
Conversation
Update and reorganize documentation for the Custom DevTools tool sample and related getting-started content. Changes include: - Bumped ms.date to 2026-04-20 in multiple extension docs. - Reworked microsoft-edge/extensions/developer-guide/devtools-extension.md: clarified the relationship between the guide and samples, reorganized file overview (manifest, panel, devtools.html, devtools.js, background.js, content_script.js, icon.png), added sibling links to sample and code, refined wording and added TODO notes. - Simplified microsoft-edge/extensions/getting-started/index.md intro and updated date. - Updated microsoft-edge/extensions/samples/custom-devtools-tool-code.md: revised description, date, sibling markers, clarified devtools.html wording and file list entries. - Updated microsoft-edge/extensions/samples/custom-devtools-tool.md: updated date, sibling links, added GitHub repo links and rearranged 'See also' / Tools references. Overall this commit improves clarity, linking between guide/sample/code, and consistency of file descriptions.
PoliCheck Scan ReportThe following report lists PoliCheck issues in PR files. Before you merge the PR, you must fix all severity-1 and severity-2 issues. The AI Review Details column lists suggestions for either removing or replacing the terms. If you find a false positive result, mention it in a PR comment and include this text: #policheck-false-positive. This feedback helps reduce false positives in future scans. ✅ No issues foundMore information about PoliCheckInformation: PoliCheck | Severity Guidance | Term |
|
Learn Build status updates of commit bb1eee7: ✅ Validation status: passed
This comment lists only the first 25 files in the pull request. |
|
|
||
| 1. In DevTools, in the **Activity Bar**, select the **Console** () tool. | ||
|
|
||
| The message "Connected!" is displayed in the **Console** tool.<!-- todo: true? how can we view that message? --> |
There was a problem hiding this comment.
how view message?
|
|
||
| 1. Navigate to the `/Demos-main/devtools-extension/` folder, such as `C:\Users\localAccount\GitHub\Demos-main\devtools-extension\`, and then click the **Select Folder** button.<!-- actually used forked cloned /Demos/ dir, a working branch, which has latest version of sample --> | ||
|
|
||
| A dialog opens, asking whether to open the repo in the parent folder.<!-- todo: does the dialog open even if when working from the downloaded zip? doesn't this dialog only appear when working off of the cloned repo? --> |
There was a problem hiding this comment.
does the dialog open even if when working from the downloaded zip?
doesn't this dialog only appear when working off of the cloned repo?
There was a problem hiding this comment.
probably not wwhen .zipdl'd.
| | `devtools.html` | A non-rendered HTML file that's run when DevTools is opened, to load the extension's JavaScript files. | | ||
| | `devtools.js` | Main logic for the custom DevTools page. | | ||
| | `service-worker.js` | A service worker that sets up event listeners for communications between the inspected page and DevTools. | | ||
| | `content_script.js` | Code which the extension injects in the inspected webpage. Prints a message<!-- todo: what message? --> to the console when the script is injected in the page. Adds a click event listener to the page that will send a message with mouse-click position in the inspected page. | |
There was a problem hiding this comment.
Nothing happens WHEN the script is injected.
when page is clicked, the message appears in console: "Received response"
response => { console.log("Received response", response); }
and also in custom tool, the coordinates of click are printed.
|
|
||
| 1. Click the **Say Hello to The Inspected Page!** button. | ||
| This file does the following: | ||
| * Prints a message<!-- todo: what message? --> to the DevTools **Console** when the page is clicked. |
There was a problem hiding this comment.
Prints what message?
There was a problem hiding this comment.
| | `devtools.html` | A non-rendered HTML file that's run when DevTools is opened, to load the extension's JavaScript files. | | ||
| | `devtools.js` | Main logic for the custom DevTools page. | | ||
| | `service-worker.js` | A service worker that sets up event listeners for communications between the inspected page and DevTools. | | ||
| | `content_script.js` | Code which the extension injects in the inspected webpage. Prints a message<!-- todo: what message? --> to the console when the script is injected in the page. Adds a click event listener to the page that will send a message with mouse-click position in the inspected page. | |
There was a problem hiding this comment.
| | `content_script.js` | Code which the extension injects in the inspected webpage. Prints a message<!-- todo: what message? --> to the console when the script is injected in the page. Adds a click event listener to the page that will send a message with mouse-click position in the inspected page. | | |
| | `content_script.js` | Code which the extension injects in the inspected webpage. Adds a click event listener to the page that will send a message with the mouse-click position in the inspected page. Sends a message to ... | |
sends a message, and devtools.js is listenging for that message as foolows:
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
// Messages from content scripts should have sender.tab set.
if (sender.tab && request.click == true) {
console.log('I am here!');
if (youClickedOn) {
youClickedOn.innerHTML = `(${request.xPosition}, ${request.yPosition})`;
}
sendResponse({
xPosition: request.xPosition,
yPosition: request.yPosition
});
}
});

Related PRs:
Overview of PR:
Rendered articles for review:
1a. Get started developing an extension
/extensions/getting-started/index.mdarchitecture.md.1b. Extension concepts and architecture
/extensions/getting-started/architecture.mdindex.md.2a. Samples for Microsoft Edge extensions > MicrosoftEdge/Demos repo
/extensions/samples.md3a. Develop an extension for the Microsoft Edge sidebar
/extensions/developer-guide/sidebar.md4a. Add a custom tool in Microsoft Edge DevTools
/extensions/developer-guide/devtools-extension.md4b. Sample: Custom DevTools tool
/extensions/developer-guide/devtools-extension-sample.mdIncidental:
5a. Many files
TOC
/toc.ymlOverview of Microsoft Edge extensions
/extensions/index.mdSites for extensions for various browsers
to:
Creating an extension for various browsers
AB#55086309