简体   繁体   English

没有错误,但控制台中没有 output 来自 chrome 扩展

[英]No errors , but no output in console from chrome extension

在此处输入图像描述

I'm trying to build an extension to monitor the xhr portion of the devtools network tab.我正在尝试构建一个扩展来监视 devtools 网络选项卡的 xhr 部分。 I decided to start as simple as possible with the background script below.我决定从下面的背景脚本开始尽可能简单。 I'm seeing no errors on loading the extension, but don't see any output in the console.我在加载扩展时没有看到任何错误,但在控制台中看不到任何 output。

manifest.json: manifest.json:

{
"manifest_version": 3,
"version": "1.0",
"name": "Hello World!",
"description": "Learning how to make a chrome extension!",
"icons": {
    "16": "images/puppy16.png",
    "48": "images/puppy48.png",
    "128": "images/puppy128.png"
},
"action": {
    "default_icon": "images/puppy.png",
    "default_popup": "popup.html"
},
"background": {
    "service_worker": "background.js"
},
"host_permissions": [
    "https://yahoo.com/*"
],
"permissions": [
    "webRequest"
]
}

In my background.js:在我的 background.js 中:

(function () {

    chrome.webRequest.onCompleted.addListener(
        function (details) {
            console.log('HELLO THERE!!!!', details);
        },
        { urls: ["<all_urls>"] }
    );

}());

What am I doing wrong?我究竟做错了什么?

The background-page and webpage console log to different places so you wouldn't see console.log('HELLO THERE,;!!', details);背景页面和网页控制台日志到不同的地方,所以你不会看到console.log('HELLO THERE,;!!', details); in the webpage's console.在网页的控制台中。 Refer the answer below for how to view the background-page console.有关如何查看后台页面控制台的信息,请参阅下面的答案。

Accessing console and devtools of extension's background.js 访问扩展程序 background.js 的控制台和开发工具

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM