简体   繁体   English

有没有办法在 firefox 分机和 node.js 程序之间发送数据?

[英]Is there a way to send data between a firefox extension and a node.js program?

My goal here is to make a discord rich presence program using node.js. I want to make a firefox extension to send the data to a node.js program.我的目标是使用 node.js 制作一个 discord 丰富的存在程序。我想制作一个 firefox 扩展以将数据发送到 node.js 程序。 I have found people trying to do a similar thing ( here ), but I havent found anyone trying to do the same thing as me.我发现有人试图做类似的事情( 这里),但我还没有发现有人试图和我做同样的事情。 I'm not very good at plain JavaScript, only node.js thanks to its libraries, and I wanted to know what code I'd need for the node.js application, as well as the firefox extension.由于它的库,我不太擅长普通的 JavaScript,只擅长 node.js,我想知道 node.js 应用程序以及 firefox 扩展需要哪些代码。 I have searched quite a bit, but to no avail.我已经搜索了很多,但无济于事。

I finally figured out how to pull this off, and I want to share my findings with everyone.我终于想出了如何解决这个问题,我想与大家分享我的发现。 You need to install json-server from npm, create a json file and then launch it using:您需要从 npm 安装 json-server,创建一个 json 文件,然后使用以下命令启动它:

json-server --watch lib.json --port 0420

After that, you can make the extension do PUT requests to set data, and then you can get the program to read the new data, set discord to watch the local programs title, and then use that!之后可以让扩展做PUT请求设置数据,然后就可以让程序读取新的数据,设置discord观看本地节目标题,然后就可以使用了!

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

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