Julien Jean
unread,Oct 3, 2022, 9:41:13 AM10/3/22Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Chromium Extensions
Hello there,
I'm currently working on a browser extension which sets a custom header with a unique value on every request when it is targeting a given server. With the new DeclarativeNetRequest API, this is not possible anymore, as it seems that we can only define static values.
As we really need a unique value for every request matching the rule, we cannot simply define a custom rule, and removing it everytime that the rule matched. We would miss some requests.
How can I manage such a thing ? Would it be possible to define a custom header value by calling a function referenced when we define a new rule ?
Something like
```javascript
chrome.DeclarativeNetRequest.updateDynamicRules({
addRules: [
{
action: {
type: 'MODIFY_HEADERS',
requestHeaders: [
{
header: 'X-Foo-Bar',
value: () => `${new Date().getTime()}`,
operation: 'SET',
}
]
}
}
}, () => {...})
```
As you can see, the value could receive a function that would be called everytime the rule matches. Here, every request matching the rule would have a X-Foo-Bar header with the current timestamp as value.
Is that is not feasible nor planned in the roadmap, is there any workaround ?
Thanks !