Ubuntu 上的本机消息传递清单文件位置

问题描述

我正在开发一个将运行 python 代码背景的扩展。我成功地在 Windows 上安装了这个例子,下面给出了链接

https://github.com/ortoniKC/chrome-native-message

但我想在 Ubuntu 20.04 上做同样的事情,而不是运行 python 代码背景。

我用 .sh 文件更改了 .bat 文件代码是;

python3 main_gui.py

main_gui 文件与 .sh 文件位于同一位置。

并在 /home/myname/.config/google-chrome/NativeMessagingHosts 位置设置 com.my.host.json 文件

扩展程序与 popup.html 一起使用,单击按钮后没有任何反应。甚至没有错误。 我一直试图运行这两天,没有任何改变。我相信我遗漏了一些东西,但我看不到它。

这是我的代码

popup.js

let tikla = document.getElementById("python")

var port = null;

tikla.addEventListener('click',() => {
   
    port = chrome.runtime.connectNative("_com.kenan_.py")
   
    ondisconnect();
    
})

function ondisconnect() {
    
    port.ondisconnect.addListener(function () {
        if (chrome.runtime.lastError) {
            console.log(chrome.runtime.lastError);
        }
    });
}

manifest.json

{
    "name": "IMFILTER","version": "1.0","description": "Filter Image","manifest_version": 2,"permissions": [
        "nativeMessaging"
    ],"browser_action": {
        "default_popup": "popup.html"
    },"icons": {
        "128": "logo.png"
    }
}

_com.kenan.py_.json

{
    "name": "_com.kenan.py_","description": "Run Python Code","path": "/home/kenan/Desktop/imfilter/native-apps/sp.sh","type": "stdio","allowed_origins": [
        "chrome-extension://phjmjhocnahihnelemjoflkdokfljech/"
    ]
}

sp.sh

#!/bin/bash
python klasor.py

_com.kenan.py_json 文件的位置是 /home/kenan/.config/google-chrome/NativeMessagingHosts/

我认为问题在于 _com.kenan.py_json 文件的位置或激活了连接 NativeMessagingHosts 但我找不到出路。

我会感谢任何建议。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)