未使用异步但仍在获取:未经检查的runtime.lastError:无法建立连接。接收端不存在

时间:2019-04-24 03:37:04

标签: javascript google-chrome-extension

我写了这个chrome扩展名:

content.js

// A function to use as callback
function doStuffWithDom(domContent) {
    console.log('I received the following DOM content:\n' + domContent);
}

// When the browser-action button is clicked...
chrome.browserAction.onClicked.addListener(function (tab) {
    // ...check the URL of the active tab against our pattern and...
        // ...if it matches, send a message specifying a callback too
        if(tab.url && tab.url.indexOf('git') > -1){
            chrome.tabs.sendMessage(tab.id, {text: 'report_back'}, doStuffWithDom);   
        }

});

background.js

{
  "manifest_version": 2,
  "name": "FetchCSV",
  "version": "1.0.0",
  "description": "Fetches the CSV from issues from github",
  "browser_action": {
    "default_logo": "logo.png"
  },
  "content_scripts": [{
    "matches": ["*://*/*"],
    "js": ["content.js"]
  }],
  "permissions": [
    "tabs",
    "activeTab",
    "*://*/*"
  ],
  "background": {
    "scripts": [
      "background.js"
    ],
    "persistent": false
  }
}

manifest.json

doStuffWithDom

我正在尝试在chrome中打开当前页面的全部内容。但是它返回foreach($sql_query as $row) { $desc = array_map('trim', explode(',', $row['OlineDesc'])); $qty = array_map('trim', explode(',', $row['OlineQty'])); $order_info = array_combine($desc, $qty); $data[] = array ( 'start' => $row['OrderDate'], 'order_id' => $row['OrderID'], 'desc_qty' => $order_info ); } 总是返回undefined并返回异常“ Unchecked runtime.lastError:无法建立连接。接收端不存在。 “。我想返回完整的dom结构并将其保存在光盘中。

我想念什么吗?

0 个答案:

没有答案