"Allow to use microphone popup"(chrome latest)有什么方法可以获取"Allow"按钮点击事件?

is there any way to get the "Allow" button click event in "Allow to use microphone popup"(chrome latest)?

我想弄清楚如何获取 "Allow" 按钮和 "Cancel" 在 TLS 锁定图标附近弹出的事件,我在网上搜索但找不到任何文章关于这个 javascript ?

我正在使用 chrome speechrecognition API 有人知道吗?

我认为您无法获取按钮事件。

但是,您可以使用 Permission API

检测权限的变化

这是一个例子:

navigator.permissions.query(
    { name: 'microphone' }
).then(function(permissionStatus){
    console.log("Current state: " + permissionStatus.state)

    permissionStatus.onchange = function(){
      if (this.state == "granted") {
        console.log("Allow");
      } else if (this.state == "denied") {
        console.log("Block");
      } else if (this.state == "prompt") {
        console.log("Ask");
      }
    }
})