什么是与Firefox插件进行通信的最佳方式 [英] What's the best way to communicate with a Firefox addon
问题描述
我也想过也许我可以使用剪贴板,但我不想覆盖任何现有的文本,自定义剪贴板类型似乎不被支持。 / p>
我不想诉诸写一个文件来做简单的IPC ...所以在我做之前...有没有更好的选择,如此简单。
谢谢 解决方案
最好的方法,但我认为使用 MozRepl 将帮助你。
MozRepl将使您能够通过telnet与firefox进行交互。
%telnet localhost 4242
Trying 127.0 .0.1 ...
连接到本地主机。
转义字符是'^]'。
欢迎来到MozRepl。
repl> content.location.href
repl>
安装MozRepl后,您可以使用这个小小的ruby脚本获取当前操作选项卡的url。 / p>
require'net / telnet'
$ b $ = Net :: Telnet.new('Port'=> ; 4242)
t.waitfor(/ repl。*> /)
puts eval(t.cmd(content.location.href).split [0])
t。关闭
I need to be able to get the URL from the active tab in Firefox. DDE doesn't work with multiple instances so I was thinking that I could build an addon that sets a global atom or something.
I also thought that maybe I could use the clipboard, but I don't want to overwrite any existing text and custom clipboard types doesn't seem to be supported.
I don't want to resort to writing a file just to do simple IPC...so before I do it...is there a better choice for something so simple.
thanks
I don't know if its the best way, but I think using MozRepl will help you. MozRepl will make you able to interact with firefox through telnet.
% telnet localhost 4242
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Welcome to MozRepl.
repl> content.location.href
"http://stackoverflow.com/questions/8525428/whats-the-best-way-to-communicate-with-a-firefox-addon"
repl>
After installing MozRepl, You can use this little ruby script to get the url of currently opend tab.
require 'net/telnet'
t = Net::Telnet.new('Port' => 4242)
t.waitfor(/repl.*>/)
puts eval(t.cmd("content.location.href").split[0])
t.close
这篇关于什么是与Firefox插件进行通信的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!