ext: spoof Edge UA/client hints for Teams
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
// Make Teams see Edge instead of Opera: rewrite UA + client-hint request headers.
|
||||||
|
const ua = navigator.userAgent;
|
||||||
|
const v = (ua.match(/Chrome\/(\d+)/) || [])[1] || "130";
|
||||||
|
const edgeUA = ua.replace(/ OPR\/[\d.]+/, "") + ` Edg/${v}.0.0.0`;
|
||||||
|
const brands = `"Microsoft Edge";v="${v}", "Chromium";v="${v}", "Not_A Brand";v="24"`;
|
||||||
|
const set = (header, value) => ({ header, operation: "set", value });
|
||||||
|
|
||||||
|
chrome.declarativeNetRequest.updateDynamicRules({
|
||||||
|
removeRuleIds: [1],
|
||||||
|
addRules: [{
|
||||||
|
id: 1,
|
||||||
|
priority: 1,
|
||||||
|
action: {
|
||||||
|
type: "modifyHeaders",
|
||||||
|
requestHeaders: [set("User-Agent", edgeUA), set("Sec-CH-UA", brands)],
|
||||||
|
},
|
||||||
|
condition: {
|
||||||
|
regexFilter: "^https://teams\\.(cloud\\.)?microsoft(\\.com)?/",
|
||||||
|
resourceTypes: ["main_frame", "sub_frame", "xmlhttprequest", "script", "stylesheet", "image", "font", "websocket", "other"],
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
});
|
||||||
@@ -3,8 +3,12 @@
|
|||||||
"name": "Teams Whisper Recorder",
|
"name": "Teams Whisper Recorder",
|
||||||
"version": "1.1",
|
"version": "1.1",
|
||||||
"description": "Record Teams tab audio+video (+mic) and transcribe with local whisper server",
|
"description": "Record Teams tab audio+video (+mic) and transcribe with local whisper server",
|
||||||
"permissions": ["tabCapture", "offscreen", "activeTab", "tabs"],
|
"permissions": ["tabCapture", "offscreen", "activeTab", "tabs", "declarativeNetRequest"],
|
||||||
"host_permissions": ["http://127.0.0.1:18765/*"],
|
"host_permissions": ["http://127.0.0.1:18765/*", "https://teams.cloud.microsoft/*", "https://teams.microsoft.com/*"],
|
||||||
"content_scripts": [{ "matches": ["https://teams.cloud.microsoft/*", "https://teams.microsoft.com/*"], "js": ["teams.js"], "run_at": "document_idle" }],
|
"background": { "service_worker": "background.js" },
|
||||||
|
"content_scripts": [
|
||||||
|
{ "matches": ["https://teams.cloud.microsoft/*", "https://teams.microsoft.com/*"], "js": ["spoof.js"], "run_at": "document_start", "world": "MAIN", "all_frames": true },
|
||||||
|
{ "matches": ["https://teams.cloud.microsoft/*", "https://teams.microsoft.com/*"], "js": ["teams.js"], "run_at": "document_idle" }
|
||||||
|
],
|
||||||
"action": { "default_popup": "popup.html" }
|
"action": { "default_popup": "popup.html" }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
// MAIN world, document_start: navigator.* reports Edge instead of Opera.
|
||||||
|
(() => {
|
||||||
|
const ua = navigator.userAgent;
|
||||||
|
if (!/OPR\//.test(ua)) return;
|
||||||
|
const v = (ua.match(/Chrome\/(\d+)/) || [])[1] || "130";
|
||||||
|
const edgeUA = ua.replace(/ OPR\/[\d.]+/, "") + ` Edg/${v}.0.0.0`;
|
||||||
|
const fix = (b) => b.map((x) => (/opera/i.test(x.brand) ? { brand: "Microsoft Edge", version: x.version } : x));
|
||||||
|
const def = (o, k, g) => Object.defineProperty(o, k, { get: g, configurable: true });
|
||||||
|
def(Navigator.prototype, "userAgent", () => edgeUA);
|
||||||
|
def(Navigator.prototype, "appVersion", () => edgeUA.replace(/^Mozilla\//, ""));
|
||||||
|
const d = navigator.userAgentData;
|
||||||
|
if (!d) return;
|
||||||
|
const brands = fix(d.brands);
|
||||||
|
const hev = d.getHighEntropyValues.bind(d);
|
||||||
|
const patched = {
|
||||||
|
brands,
|
||||||
|
mobile: d.mobile,
|
||||||
|
platform: d.platform,
|
||||||
|
getHighEntropyValues: async (h) => {
|
||||||
|
const r = await hev(h);
|
||||||
|
if (r.brands) r.brands = fix(r.brands);
|
||||||
|
if (r.fullVersionList) r.fullVersionList = fix(r.fullVersionList);
|
||||||
|
return r;
|
||||||
|
},
|
||||||
|
toJSON: () => ({ brands, mobile: d.mobile, platform: d.platform }),
|
||||||
|
};
|
||||||
|
def(Navigator.prototype, "userAgentData", () => patched);
|
||||||
|
})();
|
||||||
Reference in New Issue
Block a user