Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

208
Visualizações
Dynamically Enable/Disable declarativeNetRequest rulesets in manifest.json

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
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda