Kommunikation zwischen ContentScript.js und Chrome Extension

Ich möchte einfach die aktuelle Tab-URL an meine Nebenstelle senden:

Folgendes ist mein manifest.json

<code>{
 "name": "DocUrlExtention",
 "version": "1.0",
 "manifest_version": 2,
 "description": "The first extension that I made.",
 "browser_action": {
 "default_icon": "icon.png",
 "default_popup": "popup.html"
},
 "content_scripts": [
 {
  "matches": ["http://*/*"],
  "js": ["contentscript.js"]
 }
 ]}
</code>

Es folgt meine contentscript.js

<code>chrome.extension.sendRequest({url: window.location.href}, function(response) {
   console.log(response.farewell);
});
</code>

Es folgt meine popup.html

<code><!doctype html>
<html>
<head>
<title>Getting Started Extension's Popup</title>

<script>
    chrome.extension.onRequest.addListener(
      function(request, sender, sendResponse) {
        console.log(sender.tab ?
                    "from a content script:" + sender.tab.url :
                    "from the extension");
      });
</script>

<!-- JavaScript and HTML must be in separate files for security. -->
<!--<script src="popup.js"></script>-->
</head>
<body>
<div id="mydiv">Doc Id:</div>
</body>
</html>
</code>

Ich sehe nichts in der Konsole. Ich bin neu in Chrome-Erweiterungen.

Antworten auf die Frage(1)

Ihre Antwort auf die Frage