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,
})