Skip to content

Commit fcfc22d

Browse files
add the code for devtools integrations
1 parent e522ea3 commit fcfc22d

File tree

8 files changed

+52
-4
lines changed

8 files changed

+52
-4
lines changed

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ Life time of extension can be seen , by looking at task managers
119119

120120
For last minute cleanup, similar to useEffect return statments , make use of below code
121121

122+
## Very great set of boilerplate
123+
124+
https://github.com/googlearchive/devtools-extension-boilerplate
125+
122126
```js
123127
chrome.runtime.onSuspend.addListener(function () {
124128
console.log("Unloading.");
@@ -129,6 +133,12 @@ chrome.runtime.onSuspend.addListener(function () {
129133
manifest is verry very important to get it right:
130134
https://developer.chrome.com/extensions/manifest
131135

136+
## Devtools:
137+
138+
https://developer.chrome.com/extensions/devtools_panels
139+
140+
Each extension panel and sidebar is displayed as a separate HTML page. All extension pages displayed in the Developer Tools window have access to all modules in chrome.devtools API, as well as to chrome.extension API. Other extension APIs are not available to the pages within Developer Tools window, but you may invoke them by sending a request to the background page of your extension, similarly to how it's done in the content scripts.
141+
132142
Video Link:
133143

134144
https://www.youtube.com/watch?v=YQnRSa8MGwM
@@ -141,5 +151,3 @@ https://www.youtube.com/watch?v=YQnRSa8MGwM
141151
"js": ["pages/suspendedpage.js"]
142152
}
143153
]
144-
145-
Manifers

contentScripts/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
let limit = 10 * 1000000000000000000; // in seconds
1+
let limit = 10000000000000000000; // in seconds
22

33
console.log("some value");
44

devtools.js

Whitespace-only changes.

devtools.css devtools/devtools.css

File renamed without changes.
File renamed without changes.

devtools/devtools.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Code to generate a devtool panel
3+
*/
4+
5+
chrome.devtools.panels.create(
6+
"Test Panel ",
7+
"images/get_started16.png",
8+
"devtools/devtools.html",
9+
function (panel) {
10+
// code invoked on panel creation
11+
12+
console.log(panel, "panel got created");
13+
}
14+
);
15+
16+
/**
17+
* [createSidebarPane description]
18+
*
19+
* @return {[type]} [return description]
20+
* Code to generate the side panel in elements tabs
21+
*/
22+
chrome.devtools.panels.elements.createSidebarPane(
23+
"Test Panel SideBar",
24+
function (sidebar) {
25+
sidebar.setPage("devtools/sidebar.html");
26+
sidebar.setHeight("8ex");
27+
}
28+
);

devtools/sidebar.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<!-- <link rel="stylesheet" href="devtools.css" /> -->
5+
</head>
6+
<body>
7+
<div id="buttonDiv"></div>
8+
<div>
9+
<p>I am side bar</p>
10+
</div>
11+
</body>
12+
</html>

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
"content_security_policy": "object-src 'self'; child-src 'self'; default-src 'self';",
4444
"options_page": "options.html",
45-
"devtools_page": "devtools.html",
45+
"devtools_page": "devtools/devtools.html",
4646
"content_scripts": [
4747
{
4848
"matches": ["https://developer.chrome.com/*"],

0 commit comments

Comments
 (0)