Use BrowserSetting.set() to change the browser setting to a new value.
There are some rules that can restrict when extensions are able to change settings:
This means that if extension X tries to change a setting:
An extension can find out which of these scenarios applies by examining the "levelOfControl" property returned from a call to BrowserSetting.get().
The BrowserSetting.set() method returns a Promise that resolves to a boolean: if an attempt to change a setting actually results in the setting being changed (scenarios 2 and 3 above) the boolean is true: otherwise it is false.
var setting = setting.set( details // object )
detailsvalueany. The value you want to change the setting to. Its type depends on the particular setting.A Promise that will be fulfilled with a boolean: true if the setting was modified, false otherwise (for example, because the extension did not control the setting).
Modify the hyperlinkAuditingEnabled setting (this requires the "privacy" permission):
function onSet(result) { if (result) { console.log("Value was updated"); } else { console.log("Value was not updated"); } } browser.browserAction.onClicked.addListener(() => { var setting = browser.privacy.websites.hyperlinkAuditingEnabled.set({ value: false }); setting.then(onSet); });
Note:
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.
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/types/BrowserSetting/set