如何在Chrome中获取/读取标志值'关于:flags

How to get/read a flag value in Chrome's about:flags?

本文关键字:关于 flags 标志 读取 Chrome 获取      更新时间:2023-11-20

如何以编程方式读取chrome://flags/#enable-chrome扩展的javascript面板?

如果你试图打开一个面板,但用户没有启用它们,它只会显示为一个弹出窗口。您可以查看支持,如下所示:

chrome.windows.create({
  url:"panel.html", type:"panel", width: 400, height: 600
  }, function(window) {
    if (window.type === "panel") {
      console.log("Panels enabled.")
    } else {
      console.log("Panels disabled.")
      chrome.tabs.create({
        url:"chrome://flags/#enable-panels"
      }, function() {
        alert("Please enable panels.")
})  }  }  })

所有标志的设置都在用户数据目录中的纯文本文件Local State中。例如:

C:'Users'FooUser'AppData'Local'Google'Chrome'User Data'Local State

然后,您可以使用XMLHttpRequest来获取该文件,如下所示:

xmlhttp.open("GET","file://C:/Users/FooUser/AppData/Local/Google/Chrome/User Data/Local State",false)
xmlhttp.send();
console.log(xmlhttp.response);

你会得到这样的东西:

{
  …
  "browser": {
    "enabled_labs_experiments": [ "disable-gpu-vsync", "extension-apis", … ],
    …
  }
  …
}