I am developing a chrome extension for my company. In this chrome F.A.Q., it is said that: "However, for complex, dynamic request blocking is still supported."enterprise (or education) use cases"
Unfortunaly, it seems to be false because despite trying to publish to a private usage (company only), I get this error message: "You can no longer publish new Manifest V2 extensions. Try converting your extension to Manifest V3"
This is a problem because my chrome extension don't work with the limitations of chrome manifest V3, this is why I had to switch back to V2. The usecase is very simple, yet I couldn't achieve it. It simply consists in injecting in outgoing requests a new random
W3C traceparent header which is a common thing to do (this basically enables us to debug our backend). Because rules must now be set with static values, I can't set a new random guid on every request. I tried changing the guid on every request with
updateDynamicRules however it does not seems to handle well requests being concurrent.
It is possible to allow V2 extensions for enterprise usage or -even better- help me cover this basic usecase with manifest V3 ?
Thanks in advance
Here is the manifest V3 code attempt if you are interested:
function updateRules() {
// Generate random trace parent
const traceId = genRanHex(32);
const spanId = genRanHex(16);
// Rule that add W3C trace headers
const rules = [{
id: 123,
priority: 1,
action: {
type: 'modifyHeaders',
requestHeaders: [
{
operation: 'set',
header: 'traceparent',
value: `00-${traceId}-${spanId}-01`,
}
]
},
condition: {
"resourceTypes": ["main_frame", "sub_frame", "xmlhttprequest"]
}
}];
// Update the rules
let premise = chrome.declarativeNetRequest.updateDynamicRules({
"addRules": rules,
"removeRuleIds": [123] // Removing previous rule
});
return premise.then(() => {
return traceId;
});
}
// Listen for outgoing requests
chrome.webRequest.onBeforeRequest.addListener((details) => {
let premise = updateRules();
return premise.then((traceId) => {
console.log(`> Outgoing request to: ${url.pathname}, with trace id: ${traceId}`);
},
{
urls: [
]
});