0

How to block a request if the referer header is not equal to the domain from which the request is made? This needs to be done for extensions with Manifest version 3, using declarativeNetRequest.

const rules = blacklist.map((url, i) => {
            return {
              id: i + 1,
              priority: 1,
              action: {
                type: 'block',
              },
              condition: {
                urlFilter: url,
                excludedInitiatorDomains: [url],
                resourceTypes: ['script'],
              },
            }
          })

          chrome.declarativeNetRequest.updateDynamicRules({
            removeRuleIds: rules.map(item => item.id),
            addRules: rules,
          })
TutusT
  • 1
  • 1
  • There's no way to do it in declarativeNetRequest currently. You'll have to use ManifestV2 or install the extension via policies to enable it to use webRequestBlocking. – wOxxOm May 23 '23 at 05:24

0 Answers0