0

这是我的文件:

清单.json

{
    "manifest_version": 2,
    "name": "Open Cyberduck",
    "description": "This extension will open apps",
    "version": "1.0",
    "browser_action": {
        "default_icon": "icon.png",
        "default_popup": "popup.html"
    },  
    "permissions": [
        "activeTab",
        "nativeMessaging"
    ]
}

popup.html

<html>
    <body>
        <button id="mybutton">click me</button>
        <script src="popup.js"></script>
    </body>
</html>

popup.js

var button = document.getElementById("mybutton");
button.addEventListener("click", function() {
    var port = chrome.runtime.connectNative('foobar');
    console.log(port);
}, false);

fzManifest.json(主机清单)

{
    "name": "foobar",
    "description": "My Application",
    "path": "C:\\Program Files\\Cyberduck\\Cyberduck.exe",
    "type": "stdio",
    "allowed_origins": [
        "chrome-extension://ofaogbmpoachbgnfadnlefjkpnogjkpl/"
    ]
}

对于注册表,我运行了这个命令: REG ADD "HKCU\Software\Google\Chrome\NativeMessagingHosts\foobar" /ve /t REG_SZ /d "D:\tests\amgen\plugin\fzManifest.json" /f

每次我单击扩展按钮时都会引发此错误:Unchecked runtime.lastError: Specified native messaging host not found. 堆栈跟踪:popup.html:0 (anonymous function)

我究竟做错了什么?

Cyber​​duck 是一个 FTP 客户端应用程序。

4

0 回答 0