I am building a "Procrastination blocker" chrome extension that blocks social media sites and using the declarativeNetRequest API rulesets. I have a popup UI for my extension that has a toggle switch.
Is there a way to disable the rules when the toggle switch is turned off by the user and the rules are again enabled when the toggle switch is turned on?
By default the ruleset are enabled inside manifest.json by setting the "enabled" flag to "true" inside the "rule_resources".
Manifest.json
{
"name": "Procastination Blocker",
"version": "0.1",
"permissions": ["tabs","activeTab","declarativeNetRequest"],
"declarative_net_request": {
"rule_resources": [
{
"id": "blockLIST",
"enabled": true,
"path": "my.json"
}
]
},
"content_scripts": [
{
"js": ["content.js"],
"run_at": "document_idle",
"matches": ["<all_urls>"]
}
],
"action": {
"default_popup": "Popup.html",
"default_title": "Procrastination Blocker"
},
"manifest_version": 3
}