picatz/cube

May you please migrate it to manifest version 3?

crysosancher opened this issue · 2 comments

May you please migrate it to manifest version 3?
picatz commented

Looking at Chrome's developer documentation:

Note

As of Manifest V3, the webRequestBlocking permission is no longer available for most extensions. Consider declarativeNetRequest, which enables use of the declarativeNetRequest API. Aside from webRequestBlocking, the webRequest API will be unchanged and available for normal use. Policy installed extensions can continue to use webRequestBlocking.

The declarativeNetRequest API is used to block or modify network requests by specifying declarative rules. This lets extensions modify network requests without intercepting them and viewing their content, thus providing more privacy.
https://developer.chrome.com/docs/extensions/reference/api/declarativeNetRequest


It looks like the manifest.json would look something like:

{                                                                                                                 
      "manifest_version": 3,                                                                                          
      ...,                                                                                           
      "permissions": [                                                                                                
        "declarativeNetRequest",                                                                                      
        "declarativeNetRequestFeedback"                                                                               
      ],                                                                                                              
      "host_permissions": [                                                                                           
        "<all_urls>"                                                                                   
      ],                                                                                                                                                                                                                   
      ...,                                                                                                         
      "declarative_net_request": {                                                                                    
        "rule_resources": [{                                                                                          
          "id": "ruleset_1",                                                                                          
          "enabled": true,                                                                                            
          "path": "rules.json"                                                                                        
        }]                                                                                                            
      }                                                                                                               
}       

And the rules.json file would look something like:

[                                                                                                                 
      {                                                                                                               
        "id": 1,                                                                                                      
        "priority": 1,                                                                                                
        "action": { "type": "block" },                                                                                
        "condition": { "urlFilter": "example.com", "resourceTypes": ["main_frame"] }                                  
      },                                                                                                              
      {                                                                                                               
        "id": 2,                                                                                                      
        "priority": 1,                                                                                                
        "action": { "type": "block" },                                                                                
        "condition": { "urlFilter": "anotherexample.com", "resourceTypes": ["main_frame"] }                           
      }                                                                                                               
      ...                                                                                    
]  
picatz commented

There's also the concept of "dynamic rules" to consider.