-
-
diff --git a/devtools-extension/sample 4/devtools.html b/devtools-extension/sample 4/devtools.html
deleted file mode 100644
index 89c6c3d9..00000000
--- a/devtools-extension/sample 4/devtools.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/devtools-extension/sample 4/devtools.js b/devtools-extension/sample 4/devtools.js
deleted file mode 100644
index fdf129f4..00000000
--- a/devtools-extension/sample 4/devtools.js
+++ /dev/null
@@ -1,37 +0,0 @@
-let youClickedOn;
-chrome.devtools.panels.create("Sample Panel", "icon.png", "panel.html", panel => {
- // code invoked on panel creation
- panel.onShown.addListener( (extPanelWindow) => {
- let sayHello = extPanelWindow.document.querySelector('#sayHello');
- youClickedOn = extPanelWindow.document.querySelector('#youClickedOn');
- sayHello.addEventListener("click", () => {
- // show a greeting alert in the inspected page
- chrome.devtools.inspectedWindow.eval('alert("Hello from the DevTools Extension");');
- });
- });
-});
-
-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 = `You clicked on position (${request.xPosition}, ${request.yPosition}) in the inspected page.`;
- }
- sendResponse({
- xPosition: request.xPosition,
- yPosition: request.yPosition
- });
- }
-});
-
-// Create a connection to the background service worker
-const backgroundPageConnection = chrome.runtime.connect({
- name: "devtools-page"
-});
-
-// Relay the tab ID to the background service worker
-backgroundPageConnection.postMessage({
- name: 'init',
- tabId: chrome.devtools.inspectedWindow.tabId
-});
diff --git a/devtools-extension/sample 4/manifest.json b/devtools-extension/sample 4/manifest.json
deleted file mode 100644
index 18621aa6..00000000
--- a/devtools-extension/sample 4/manifest.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "name": "DevTools Sample Extension",
- "description": "A Basic DevTools Extension Interacting with the Inspected Page",
- "manifest_version": 3,
- "version": "1.0",
- "devtools_page": "devtools.html",
- "content_scripts": [{
- "matches": [
- "http://*/*",
- "https://*/*"
- ],
- "run_at": "document_idle",
- "js": [
- "content_script.js"
- ]
- }],
- "background": {
- "service_worker": "background.js"
- }
-}
diff --git a/devtools-extension/sample 4/panel.html b/devtools-extension/sample 4/panel.html
deleted file mode 100644
index 458bf128..00000000
--- a/devtools-extension/sample 4/panel.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
A Basic DevTools Extension Interacting with the Inspected Page
-
-
-
-
diff --git a/devtools-extension/sample 4/background.js b/devtools-extension/service-worker.js
similarity index 62%
rename from devtools-extension/sample 4/background.js
rename to devtools-extension/service-worker.js
index 805cc666..30833475 100644
--- a/devtools-extension/sample 4/background.js
+++ b/devtools-extension/service-worker.js
@@ -2,17 +2,17 @@ let id = null;
const connections = {};
chrome.runtime.onConnect.addListener(devToolsConnection => {
- // Assign the listener function to a variable so we can remove it later
+ // Assign the listener function to a variable, so we can remove it later.
let devToolsListener = (message, sender, sendResponse) => {
if (message.name == "init") {
id = message.tabId;
connections[id] = devToolsConnection;
- // Send a message back to DevTools
- connections[id].postMessage("Connected!");
+ // Send a message back to DevTools.
+ connections[id].postMessage("Connected!"); // todo: where can we see the message "Connected!" in DevTools?
}
};
- // Listen to messages sent from the DevTools page
+ // Listen to messages sent from the DevTools page.
devToolsConnection.onMessage.addListener(devToolsListener);
devToolsConnection.onDisconnect.addListener(() => {