我想创建允许添加到youtube页面按钮“在vlc中播放剪辑”的firefox插件,因为我想在单独的窗口中添加剪辑
现在我有添加按钮的代码
const resource_url = window.location.href
target_div = document.getElementById("meta-contents").childNodes[0].childNodes[0].childNodes[1]
const newButton = document.createElement("button")
newButton.innerHTML = "Play on vlc"
target_div.insertBefore(newButton, target_div.childNodes[1])
和用于调用bash命令的代码:
child_process.spawn('/bin/sh', ['vlc', 'http://' + resource_url])
所以我知道如何在firefox中执行命令行程序,但是
如何将此代码设置为在HTML按钮单击时调用的代码?