Apply ruff lint and rename cryptic identifiers to readable names
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
// Make Teams see Edge instead of Opera: rewrite UA + client-hint request headers.
|
||||
// Edge UA built from the browser's own UA: the Opera OPR/ token is removed and an Edg/ token is added.
|
||||
const ua = navigator.userAgent;
|
||||
const userAgent = navigator.userAgent;
|
||||
// Chrome major version taken from the UA; falls back to 130 if the UA has no Chrome token.
|
||||
const v = (ua.match(/Chrome\/(\d+)/) || [])[1] || "130";
|
||||
const edgeUA = ua.replace(/ OPR\/[\d.]+/, "") + ` Edg/${v}.0.0.0`;
|
||||
const chromeMajor = (userAgent.match(/Chrome\/(\d+)/) || [])[1] || "130";
|
||||
const edgeUA = userAgent.replace(/ OPR\/[\d.]+/, "") + ` Edg/${chromeMajor}.0.0.0`;
|
||||
// Sec-CH-UA brand list matching the Edge UA; "Not_A Brand" is a GREASE placeholder brand.
|
||||
const brands = `"Microsoft Edge";v="${v}", "Chromium";v="${v}", "Not_A Brand";v="24"`;
|
||||
const brands = `"Microsoft Edge";v="${chromeMajor}", "Chromium";v="${chromeMajor}", "Not_A Brand";v="24"`;
|
||||
// Helper: builds one declarativeNetRequest header operation.
|
||||
const set = (header, value) => ({ header, operation: "set", value });
|
||||
const headerSet = (header, value) => ({ header, operation: "set", value });
|
||||
|
||||
// Dynamic rules persist across service-worker restarts, so id 1 is replaced on every start.
|
||||
chrome.declarativeNetRequest.updateDynamicRules({
|
||||
@@ -19,7 +19,7 @@ chrome.declarativeNetRequest.updateDynamicRules({
|
||||
// Rewrite the outgoing request headers.
|
||||
action: {
|
||||
type: "modifyHeaders",
|
||||
requestHeaders: [set("User-Agent", edgeUA), set("Sec-CH-UA", brands)],
|
||||
requestHeaders: [headerSet("User-Agent", edgeUA), headerSet("Sec-CH-UA", brands)],
|
||||
},
|
||||
condition: {
|
||||
// Only Teams hosts: teams.microsoft.com and teams.cloud.microsoft.
|
||||
|
||||
Reference in New Issue
Block a user