BrowserSetting.get()
method gets the current value of the browser setting, and an enumeration indicating how the setting's value is currently controlled.
This is an asynchronous function that returns a
Promise
.
var getting = setting.get(
details
// object
)
details
An empty object.
A
Promise
that will be fulfilled with an object with the following properties:
value
The value of the setting. The type of this property is determined by the particular setting.
levelOfControl
string
. This represents the way the setting is currently controlled. You can use it to check whether you can modify the setting. See
BrowserSetting.set()
for details. Its value may be any of the following:
"not_controllable"
|
Extensions are not allowed to modify this setting. |
"controlled_by_other_extensions"
|
Another extension that was installed after this one has modified this 设置。 |
"controllable_by_this_extension"
|
This extension is allowed to modify the setting. |
"controlled_by_this_extension"
|
This extension has already modified the setting. |
Log the value and level of control for the
networkPredictionEnabled
特性为
privacy.network
object, for private browsing windows. Note that this requires the "privacy" browser permission.
var getting = browser.privacy.network.networkPredictionEnabled.get({});
getting.then((got) => {
console.log(`Value: ${got.value}`);
console.log(`Control: ${got.levelOfControl}`);
});
注意:
This API is based on Chromium's
chrome.types
API。
Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.
最后修改: , 由 MDN 贡献者