I am writing a program where I need to make a button to enable and disable the browser extensions from application only. Need your help in that.
I am able to get the list of extensions from the browsers manifest. Json file but I am not aware how to enable and disable those extensions.
CodePudding user response:
I'm afraid you are not able to enable/disable extensions using Java. Extensions are part of user preferences and browser UI so you can't disable them via a button in the application. If you need to disable any extension, you can create an extension to disable another extension.
Update: After some investigations, I've figured out how third-party applications disable browser extensions. Take CCleaner as an example. If you need to disable/enable an extension, you need to close the browser first. That is because CCleaner simply overwrites the Preference
file in your profile folder and adds/deletes "disable_reasons": 1
, which turns off/on the extension. You can manually do the same, but it only works with the browser closed. If that is what you want, you've got it.
Example
Extension turned off:
"settings": {
"TargetExtensionID": {
"disable_reasons": 1
}
Extension turned on:
"settings": {
"TargetExtensionID": {
}