Skip to content

Commit

Permalink
extension: Don't add dynamic rules where responseHeaders rules ignored
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhjacobs committed Jun 21, 2024
1 parent 63b84b8 commit c57f478
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion web/packages/extension/src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ async function contentScriptRegistered() {
}

async function enable() {
if (utils.declarativeNetRequest) {
// Unlike other browsers, Chrome registers rules with an unsupported condition.
// Therefore, check that Chrome is a version that supports the responseHeaders condition,
// so the browser in use throws an exception or supports the responseHeaders condition.
// The alternative check here is to use feature detection to detect support for something
// that strictly greater Chrome versions support, but no such features exist yet.
const chrome127OrLess = /Chrome\/([0-9]|1[0-9]|1[0-1][0-9]|12[0-7])\./.test(
navigator.userAgent,
);
if (utils.declarativeNetRequest && !chrome127OrLess) {
const playerPage = utils.runtime.getURL("/player.html");
const rules = [
{
Expand Down Expand Up @@ -55,6 +63,7 @@ async function enable() {
values: [
"application/octet-stream",
"application/binary-stream",
// TODO: Add "" after https://crrev.com/c/5634852
],
},
],
Expand Down

0 comments on commit c57f478

Please sign in to comment.