Skip to content

Commit e467598

Browse files
Release build 4.41.0 [ci release]
1 parent 254b23c commit e467598

File tree

5 files changed

+653
-10
lines changed

5 files changed

+653
-10
lines changed

Sources/ContentScopeScripts/dist/contentScope.js

Lines changed: 125 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,15 @@
23502350
const settings = this.getFeatureSettingEnabled("permissions");
23512351
this.permissionsFix(settings);
23522352
}
2353+
if (this.getFeatureSettingEnabled("cleanIframeValue")) {
2354+
this.cleanIframeValue();
2355+
}
2356+
if (this.getFeatureSettingEnabled("mediaSession")) {
2357+
this.mediaSessionFix();
2358+
}
2359+
if (this.getFeatureSettingEnabled("presentation")) {
2360+
this.presentationFix();
2361+
}
23532362
}
23542363
/**
23552364
* Notification fix for adding missing API for Android WebView.
@@ -2372,6 +2381,42 @@
23722381
enumerable: false
23732382
});
23742383
}
2384+
cleanIframeValue() {
2385+
function cleanValueData(val) {
2386+
const clone = Object.assign({}, val);
2387+
const deleteKeys = ["iframeProto", "iframeData", "remap"];
2388+
for (const key of deleteKeys) {
2389+
if (key in clone) {
2390+
delete clone[key];
2391+
}
2392+
}
2393+
val.iframeData = clone;
2394+
return val;
2395+
}
2396+
window.XMLHttpRequest.prototype.send = new Proxy(window.XMLHttpRequest.prototype.send, {
2397+
apply(target, thisArg, args) {
2398+
const body = args[0];
2399+
const cleanKey = "bi_wvdp";
2400+
if (body && typeof body === "string" && body.includes(cleanKey)) {
2401+
const parts = body.split("&").map((part) => {
2402+
return part.split("=");
2403+
});
2404+
if (parts.length > 0) {
2405+
parts.forEach((part) => {
2406+
if (part[0] === cleanKey) {
2407+
const val = JSON.parse(decodeURIComponent(part[1]));
2408+
part[1] = encodeURIComponent(JSON.stringify(cleanValueData(val)));
2409+
}
2410+
});
2411+
args[0] = parts.map((part) => {
2412+
return part.join("=");
2413+
}).join("&");
2414+
}
2415+
}
2416+
return Reflect.apply(target, thisArg, args);
2417+
}
2418+
});
2419+
}
23752420
/**
23762421
* Adds missing permissions API for Android WebView.
23772422
*/
@@ -2396,7 +2441,7 @@
23962441
"midi"
23972442
];
23982443
const validPermissionNames = settings.validPermissionNames || defaultValidPermissionNames;
2399-
permissions.query = (query) => {
2444+
permissions.query = new Proxy((query) => {
24002445
this.addDebugFlag();
24012446
if (!query) {
24022447
throw new TypeError("Failed to execute 'query' on 'Permissions': 1 argument required, but only 0 present.");
@@ -2408,7 +2453,11 @@
24082453
throw new TypeError("Failed to execute 'query' on 'Permissions': Failed to read the 'name' property from 'PermissionDescriptor': The provided value 's' is not a valid enum value of type PermissionName.");
24092454
}
24102455
return Promise.resolve(new PermissionStatus(query.name, "denied"));
2411-
};
2456+
}, {
2457+
get(target, name) {
2458+
return Reflect.get(target, name);
2459+
}
2460+
});
24122461
window.navigator.permissions = permissions;
24132462
}
24142463
/**
@@ -2483,6 +2532,80 @@
24832532
} catch {
24842533
}
24852534
}
2535+
mediaSessionFix() {
2536+
try {
2537+
if (window.navigator.mediaSession) {
2538+
return;
2539+
}
2540+
this.defineProperty(window.navigator, "mediaSession", {
2541+
value: {},
2542+
writable: true,
2543+
configurable: true,
2544+
enumerable: true
2545+
});
2546+
this.defineProperty(window.navigator.mediaSession, "metadata", {
2547+
value: null,
2548+
writable: true,
2549+
configurable: false,
2550+
enumerable: false
2551+
});
2552+
this.defineProperty(window.navigator.mediaSession, "playbackState", {
2553+
value: "none",
2554+
writable: true,
2555+
configurable: false,
2556+
enumerable: false
2557+
});
2558+
this.defineProperty(window.navigator.mediaSession, "setActionHandler", {
2559+
value: () => {
2560+
},
2561+
configurable: true,
2562+
enumerable: true
2563+
});
2564+
this.defineProperty(window.navigator.mediaSession, "setCameraActive", {
2565+
value: () => {
2566+
},
2567+
configurable: true,
2568+
enumerable: true
2569+
});
2570+
this.defineProperty(window.navigator.mediaSession, "setMicrophoneActive", {
2571+
value: () => {
2572+
},
2573+
configurable: true,
2574+
enumerable: true
2575+
});
2576+
this.defineProperty(window.navigator.mediaSession, "setPositionState", {
2577+
value: () => {
2578+
},
2579+
configurable: true,
2580+
enumerable: true
2581+
});
2582+
} catch {
2583+
}
2584+
}
2585+
presentationFix() {
2586+
try {
2587+
if (window.navigator.presentation) {
2588+
return;
2589+
}
2590+
this.defineProperty(window.navigator, "presentation", {
2591+
value: {},
2592+
writable: true,
2593+
configurable: true,
2594+
enumerable: true
2595+
});
2596+
this.defineProperty(window.navigator.presentation, "defaultRequest", {
2597+
value: null,
2598+
configurable: true,
2599+
enumerable: true
2600+
});
2601+
this.defineProperty(window.navigator.presentation, "receiver", {
2602+
value: null,
2603+
configurable: true,
2604+
enumerable: true
2605+
});
2606+
} catch {
2607+
}
2608+
}
24862609
/**
24872610
* Support for proxying `window.webkit.messageHandlers`
24882611
*/

build/android/contentScope.js

Lines changed: 132 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7467,6 +7467,17 @@
74677467
const settings = this.getFeatureSettingEnabled('permissions');
74687468
this.permissionsFix(settings);
74697469
}
7470+
if (this.getFeatureSettingEnabled('cleanIframeValue')) {
7471+
this.cleanIframeValue();
7472+
}
7473+
7474+
if (this.getFeatureSettingEnabled('mediaSession')) {
7475+
this.mediaSessionFix();
7476+
}
7477+
7478+
if (this.getFeatureSettingEnabled('presentation')) {
7479+
this.presentationFix();
7480+
}
74707481
}
74717482

74727483
/**
@@ -7494,6 +7505,40 @@
74947505
});
74957506
}
74967507

7508+
cleanIframeValue () {
7509+
function cleanValueData (val) {
7510+
const clone = Object.assign({}, val);
7511+
const deleteKeys = ['iframeProto', 'iframeData', 'remap'];
7512+
for (const key of deleteKeys) {
7513+
if (key in clone) {
7514+
delete clone[key];
7515+
}
7516+
}
7517+
val.iframeData = clone;
7518+
return val
7519+
}
7520+
7521+
window.XMLHttpRequest.prototype.send = new Proxy(window.XMLHttpRequest.prototype.send, {
7522+
apply (target, thisArg, args) {
7523+
const body = args[0];
7524+
const cleanKey = 'bi_wvdp';
7525+
if (body && typeof body === 'string' && body.includes(cleanKey)) {
7526+
const parts = body.split('&').map((part) => { return part.split('=') });
7527+
if (parts.length > 0) {
7528+
parts.forEach((part) => {
7529+
if (part[0] === cleanKey) {
7530+
const val = JSON.parse(decodeURIComponent(part[1]));
7531+
part[1] = encodeURIComponent(JSON.stringify(cleanValueData(val)));
7532+
}
7533+
});
7534+
args[0] = parts.map((part) => { return part.join('=') }).join('&');
7535+
}
7536+
}
7537+
return Reflect.apply(target, thisArg, args)
7538+
}
7539+
});
7540+
}
7541+
74977542
/**
74987543
* Adds missing permissions API for Android WebView.
74997544
*/
@@ -7519,7 +7564,7 @@
75197564
'midi'
75207565
];
75217566
const validPermissionNames = settings.validPermissionNames || defaultValidPermissionNames;
7522-
permissions.query = (query) => {
7567+
permissions.query = new Proxy((query) => {
75237568
this.addDebugFlag();
75247569
if (!query) {
75257570
throw new TypeError("Failed to execute 'query' on 'Permissions': 1 argument required, but only 0 present.")
@@ -7531,7 +7576,11 @@
75317576
throw new TypeError("Failed to execute 'query' on 'Permissions': Failed to read the 'name' property from 'PermissionDescriptor': The provided value 's' is not a valid enum value of type PermissionName.")
75327577
}
75337578
return Promise.resolve(new PermissionStatus(query.name, 'denied'))
7534-
};
7579+
}, {
7580+
get (target, name) {
7581+
return Reflect.get(target, name)
7582+
}
7583+
});
75357584
// Expose the API
75367585
// @ts-expect-error window.navigator isn't assignable
75377586
window.navigator.permissions = permissions;
@@ -7619,6 +7668,87 @@
76197668
}
76207669
}
76217670

7671+
mediaSessionFix () {
7672+
try {
7673+
if (window.navigator.mediaSession) {
7674+
return
7675+
}
7676+
7677+
this.defineProperty(window.navigator, 'mediaSession', {
7678+
value: {
7679+
},
7680+
writable: true,
7681+
configurable: true,
7682+
enumerable: true
7683+
});
7684+
this.defineProperty(window.navigator.mediaSession, 'metadata', {
7685+
value: null,
7686+
writable: true,
7687+
configurable: false,
7688+
enumerable: false
7689+
});
7690+
this.defineProperty(window.navigator.mediaSession, 'playbackState', {
7691+
value: 'none',
7692+
writable: true,
7693+
configurable: false,
7694+
enumerable: false
7695+
});
7696+
this.defineProperty(window.navigator.mediaSession, 'setActionHandler', {
7697+
value: () => {},
7698+
configurable: true,
7699+
enumerable: true
7700+
});
7701+
this.defineProperty(window.navigator.mediaSession, 'setCameraActive', {
7702+
value: () => {},
7703+
configurable: true,
7704+
enumerable: true
7705+
});
7706+
this.defineProperty(window.navigator.mediaSession, 'setMicrophoneActive', {
7707+
value: () => {},
7708+
configurable: true,
7709+
enumerable: true
7710+
});
7711+
this.defineProperty(window.navigator.mediaSession, 'setPositionState', {
7712+
value: () => {},
7713+
configurable: true,
7714+
enumerable: true
7715+
});
7716+
} catch {
7717+
// Ignore exceptions that could be caused by conflicting with other extensions
7718+
}
7719+
}
7720+
7721+
presentationFix () {
7722+
try {
7723+
// @ts-expect-error due to: Property 'presentation' does not exist on type 'Navigator'
7724+
if (window.navigator.presentation) {
7725+
return
7726+
}
7727+
7728+
this.defineProperty(window.navigator, 'presentation', {
7729+
value: {
7730+
},
7731+
writable: true,
7732+
configurable: true,
7733+
enumerable: true
7734+
});
7735+
// @ts-expect-error due to: Property 'presentation' does not exist on type 'Navigator'
7736+
this.defineProperty(window.navigator.presentation, 'defaultRequest', {
7737+
value: null,
7738+
configurable: true,
7739+
enumerable: true
7740+
});
7741+
// @ts-expect-error due to: Property 'presentation' does not exist on type 'Navigator'
7742+
this.defineProperty(window.navigator.presentation, 'receiver', {
7743+
value: null,
7744+
configurable: true,
7745+
enumerable: true
7746+
});
7747+
} catch {
7748+
// Ignore exceptions that could be caused by conflicting with other extensions
7749+
}
7750+
}
7751+
76227752
/**
76237753
* Support for proxying `window.webkit.messageHandlers`
76247754
*/

0 commit comments

Comments
 (0)