Skip to content

Commit 630eb2c

Browse files
shakyShanegithub-actions[bot]
authored andcommitted
Release build 4.22.4 [ci release]
1 parent 63f7732 commit 630eb2c

File tree

26 files changed

+2842
-331
lines changed

26 files changed

+2842
-331
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
node_modules/
33
.swiftpm
44
.env
5+
.build/
56
build/
67
docs/
78
test-results/

Sources/ContentScopeScripts/dist/contentScope.js

Lines changed: 121 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@
356356
};
357357

358358
/**
359-
* Handles the processing of a config setting.
359+
* Processes a structured config setting and returns the value according to its type
360360
* @param {*} configSetting
361361
* @param {*} [defaultValue]
362362
* @returns
@@ -807,15 +807,16 @@
807807
'clickToLoad',
808808
'windowsPermissionUsage',
809809
'webCompat',
810-
'duckPlayer'
810+
'duckPlayer',
811+
'harmfulApis'
811812
]);
812813

813814
/** @typedef {baseFeatures[number]|otherFeatures[number]} FeatureName */
814815
/** @type {Record<string, FeatureName[]>} */
815816
const platformSupport = {
816817
apple: [
817-
...baseFeatures,
818-
'webCompat'
818+
'webCompat',
819+
...baseFeatures
819820
],
820821
'apple-isolated': [
821822
'duckPlayer'
@@ -827,7 +828,8 @@
827828
windows: [
828829
...baseFeatures,
829830
'windowsPermissionUsage',
830-
'duckPlayer'
831+
'duckPlayer',
832+
'harmfulApis'
831833
],
832834
firefox: [
833835
...baseFeatures,
@@ -1507,12 +1509,13 @@
15071509
}
15081510

15091511
/**
1512+
* Return a specific setting from the feature settings
15101513
* @param {string} featureKeyName
15111514
* @param {string} [featureName]
15121515
* @returns {any}
15131516
*/
15141517
getFeatureSetting (featureKeyName, featureName) {
1515-
let result = this._getFeatureSetting(featureName);
1518+
let result = this._getFeatureSettings(featureName);
15161519
if (featureKeyName === 'domains') {
15171520
throw new Error('domains is a reserved feature setting key name')
15181521
}
@@ -1533,15 +1536,17 @@
15331536
}
15341537

15351538
/**
1539+
* Return the settings object for a feature
15361540
* @param {string} [featureName] - The name of the feature to get the settings for; defaults to the name of the feature
15371541
* @returns {any}
15381542
*/
1539-
_getFeatureSetting (featureName) {
1543+
_getFeatureSettings (featureName) {
15401544
const camelFeatureName = featureName || camelcase(this.name);
15411545
return this.#args?.featureSettings?.[camelFeatureName]
15421546
}
15431547

15441548
/**
1549+
* For simple boolean settings, return true if the setting is 'enabled'
15451550
* @param {string} featureKeyName
15461551
* @param {string} [featureName]
15471552
* @returns {boolean}
@@ -1552,13 +1557,14 @@
15521557
}
15531558

15541559
/**
1560+
* Given a config key, interpret the value as a list of domain overrides, and return the elements that match the current page
15551561
* @param {string} featureKeyName
15561562
* @return {any[]}
15571563
*/
15581564
matchDomainFeatureSetting (featureKeyName) {
15591565
const domain = this.#args?.site.domain;
15601566
if (!domain) return []
1561-
const domains = this._getFeatureSetting()?.[featureKeyName] || [];
1567+
const domains = this._getFeatureSettings()?.[featureKeyName] || [];
15621568
return domains.filter((rule) => {
15631569
if (Array.isArray(rule.domain)) {
15641570
return rule.domain.some((domainRule) => {
@@ -1617,6 +1623,111 @@
16171623
}
16181624
}
16191625

1626+
/**
1627+
* Fixes incorrect sizing value for outerHeight and outerWidth
1628+
*/
1629+
function windowSizingFix () {
1630+
if (window.outerHeight !== 0 && window.outerWidth !== 0) {
1631+
return
1632+
}
1633+
window.outerHeight = window.innerHeight;
1634+
window.outerWidth = window.innerWidth;
1635+
}
1636+
1637+
/**
1638+
* Add missing navigator.credentials API
1639+
*/
1640+
function navigatorCredentialsFix () {
1641+
try {
1642+
if ('credentials' in navigator && 'get' in navigator.credentials) {
1643+
return
1644+
}
1645+
const value = {
1646+
get () {
1647+
return Promise.reject(new Error())
1648+
}
1649+
};
1650+
defineProperty(Navigator.prototype, 'credentials', {
1651+
value,
1652+
configurable: true,
1653+
enumerable: true
1654+
});
1655+
} catch {
1656+
// Ignore exceptions that could be caused by conflicting with other extensions
1657+
}
1658+
}
1659+
1660+
function safariObjectFix () {
1661+
try {
1662+
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
1663+
if (window.safari) {
1664+
return
1665+
}
1666+
defineProperty(window, 'safari', {
1667+
value: {
1668+
},
1669+
configurable: true,
1670+
enumerable: true
1671+
});
1672+
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
1673+
defineProperty(window.safari, 'pushNotification', {
1674+
value: {
1675+
},
1676+
configurable: true,
1677+
enumerable: true
1678+
});
1679+
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
1680+
defineProperty(window.safari.pushNotification, 'toString', {
1681+
value: () => { return '[object SafariRemoteNotification]' },
1682+
configurable: true,
1683+
enumerable: true
1684+
});
1685+
class SafariRemoteNotificationPermission {
1686+
constructor () {
1687+
this.deviceToken = null;
1688+
this.permission = 'denied';
1689+
}
1690+
}
1691+
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
1692+
defineProperty(window.safari.pushNotification, 'permission', {
1693+
value: () => {
1694+
return new SafariRemoteNotificationPermission()
1695+
},
1696+
configurable: true,
1697+
enumerable: true
1698+
});
1699+
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
1700+
defineProperty(window.safari.pushNotification, 'requestPermission', {
1701+
value: (name, domain, options, callback) => {
1702+
if (typeof callback === 'function') {
1703+
callback(new SafariRemoteNotificationPermission());
1704+
return
1705+
}
1706+
const reason = "Invalid 'callback' value passed to safari.pushNotification.requestPermission(). Expected a function.";
1707+
throw new Error(reason)
1708+
},
1709+
configurable: true,
1710+
enumerable: true
1711+
});
1712+
} catch {
1713+
// Ignore exceptions that could be caused by conflicting with other extensions
1714+
}
1715+
}
1716+
1717+
class WebCompat extends ContentFeature {
1718+
init () {
1719+
if (this.getFeatureSettingEnabled('windowSizing')) {
1720+
windowSizingFix();
1721+
}
1722+
if (this.getFeatureSettingEnabled('navigatorCredentials')) {
1723+
navigatorCredentialsFix();
1724+
}
1725+
if (this.getFeatureSettingEnabled('safariObject')) {
1726+
safariObjectFix();
1727+
}
1728+
}
1729+
}
1730+
16201731
function generateUniqueID () {
16211732
return Symbol(undefined)
16221733
}
@@ -5951,112 +6062,8 @@
59516062
}
59526063
}
59536064

5954-
/**
5955-
* Fixes incorrect sizing value for outerHeight and outerWidth
5956-
*/
5957-
function windowSizingFix () {
5958-
if (window.outerHeight !== 0 && window.outerWidth !== 0) {
5959-
return
5960-
}
5961-
window.outerHeight = window.innerHeight;
5962-
window.outerWidth = window.innerWidth;
5963-
}
5964-
5965-
/**
5966-
* Add missing navigator.credentials API
5967-
*/
5968-
function navigatorCredentialsFix () {
5969-
try {
5970-
if ('credentials' in navigator && 'get' in navigator.credentials) {
5971-
return
5972-
}
5973-
const value = {
5974-
get () {
5975-
return Promise.reject(new Error())
5976-
}
5977-
};
5978-
defineProperty(Navigator.prototype, 'credentials', {
5979-
value,
5980-
configurable: true,
5981-
enumerable: true
5982-
});
5983-
} catch {
5984-
// Ignore exceptions that could be caused by conflicting with other extensions
5985-
}
5986-
}
5987-
5988-
function safariObjectFix () {
5989-
try {
5990-
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
5991-
if (window.safari) {
5992-
return
5993-
}
5994-
defineProperty(window, 'safari', {
5995-
value: {
5996-
},
5997-
configurable: true,
5998-
enumerable: true
5999-
});
6000-
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
6001-
defineProperty(window.safari, 'pushNotification', {
6002-
value: {
6003-
},
6004-
configurable: true,
6005-
enumerable: true
6006-
});
6007-
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
6008-
defineProperty(window.safari.pushNotification, 'toString', {
6009-
value: () => { return '[object SafariRemoteNotification]' },
6010-
configurable: true,
6011-
enumerable: true
6012-
});
6013-
class SafariRemoteNotificationPermission {
6014-
constructor () {
6015-
this.deviceToken = null;
6016-
this.permission = 'denied';
6017-
}
6018-
}
6019-
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
6020-
defineProperty(window.safari.pushNotification, 'permission', {
6021-
value: () => {
6022-
return new SafariRemoteNotificationPermission()
6023-
},
6024-
configurable: true,
6025-
enumerable: true
6026-
});
6027-
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
6028-
defineProperty(window.safari.pushNotification, 'requestPermission', {
6029-
value: (name, domain, options, callback) => {
6030-
if (typeof callback === 'function') {
6031-
callback(new SafariRemoteNotificationPermission());
6032-
return
6033-
}
6034-
const reason = "Invalid 'callback' value passed to safari.pushNotification.requestPermission(). Expected a function.";
6035-
throw new Error(reason)
6036-
},
6037-
configurable: true,
6038-
enumerable: true
6039-
});
6040-
} catch {
6041-
// Ignore exceptions that could be caused by conflicting with other extensions
6042-
}
6043-
}
6044-
6045-
class WebCompat extends ContentFeature {
6046-
init () {
6047-
if (this.getFeatureSettingEnabled('windowSizing')) {
6048-
windowSizingFix();
6049-
}
6050-
if (this.getFeatureSettingEnabled('navigatorCredentials')) {
6051-
navigatorCredentialsFix();
6052-
}
6053-
if (this.getFeatureSettingEnabled('safariObject')) {
6054-
safariObjectFix();
6055-
}
6056-
}
6057-
}
6058-
60596065
var platformFeatures = {
6066+
ddg_feature_webCompat: WebCompat,
60606067
ddg_feature_runtimeChecks: RuntimeChecks,
60616068
ddg_feature_fingerprintingAudio: FingerprintingAudio,
60626069
ddg_feature_fingerprintingBattery: FingerprintingBattery,
@@ -6070,8 +6077,7 @@
60706077
ddg_feature_fingerprintingTemporaryStorage: FingerprintingTemporaryStorage,
60716078
ddg_feature_navigatorInterface: NavigatorInterface,
60726079
ddg_feature_elementHiding: ElementHiding,
6073-
ddg_feature_exceptionHandler: ExceptionHandler,
6074-
ddg_feature_webCompat: WebCompat
6080+
ddg_feature_exceptionHandler: ExceptionHandler
60756081
};
60766082

60776083
/* global false */

0 commit comments

Comments
 (0)