cube icon indicating copy to clipboard operation
cube copied to clipboard

May you please migrate it to manifest version 3?

Open crysosancher opened this issue 3 years ago • 2 comments

crysosancher avatar Feb 14 '22 13:02 crysosancher

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 avatar Jan 02 '24 06:01 picatz

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

picatz avatar Jan 02 '24 06:01 picatz