Bug 1716220 - add a SmartBlock shim for Branch Web SDK; r=webcompat-reviewers,denschub

Differential Revision: https://phabricator.services.mozilla.com/D148471
This commit is contained in:
Thomas Wisniewski 2022-06-07 14:27:47 +00:00
Родитель b554820c29
Коммит d0c4cefea1
4 изменённых файлов: 93 добавлений и 1 удалений

Просмотреть файл

@ -167,6 +167,15 @@ const AVAILABLE_SHIMS = [
matches: ["*://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"],
onlyIfBlockedByETP: true,
},
{
id: "Branch",
platform: "all",
name: "Branch Web SDK",
bug: "1716220",
file: "branch.js",
matches: ["*://cdn.branch.io/branch-latest.min.js*"],
onlyIfBlockedByETP: true,
},
{
id: "DoubleVerify",
platform: "all",

Просмотреть файл

@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Web Compatibility Interventions",
"description": "Urgent post-release fixes for web compatibility.",
"version": "102.5.0",
"version": "102.6.0",
"applications": {
"gecko": {
"id": "webcompat@mozilla.org",
@ -98,6 +98,7 @@
"shims/adsafeprotected-ima.js",
"shims/apstag.js",
"shims/bmauth.js",
"shims/branch.js",
"shims/chartbeat.js",
"shims/crave-ca.js",
"shims/criteo.js",

Просмотреть файл

@ -91,6 +91,7 @@ FINAL_TARGET_FILES.features["webcompat@mozilla.org"]["shims"] += [
"shims/adsafeprotected-ima.js",
"shims/apstag.js",
"shims/bmauth.js",
"shims/branch.js",
"shims/chartbeat.js",
"shims/crave-ca.js",
"shims/criteo.js",

Просмотреть файл

@ -0,0 +1,81 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/**
* Bug 1716220 - Shim Branch Web SDK
*
* Sites such as TataPlay may not load properly if Branch Web SDK is
* blocked. This shim stubs out its script so the page still loads.
*/
if (!window?.branch?.b) {
const queue = window?.branch?._q || [];
window.branch = new (class {
V = {};
g = 0;
X = "web2.62.0";
b = {
A: {},
clear() {},
get() {},
getAll() {},
isEnabled: () => true,
remove() {},
set() {},
ca() {},
g: [],
l: 0,
o: 0,
s: null,
};
addListener() {}
applyCode() {}
autoAppIndex() {}
banner() {}
c() {}
closeBanner() {}
closeJourney() {}
constructor() {}
creditHistory() {}
credits() {}
crossPlatformIds() {}
data() {}
deepview() {}
deepviewCta() {}
disableTracking() {}
first() {}
getBrowserFingerprintId() {}
getCode() {}
init(key, cb) {
cb?.(undefined, {});
}
lastAttributedTouchData() {}
link() {}
logEvent() {}
logout() {}
qrCode() {}
redeem() {}
referrals() {}
removeListener() {}
renderFinalize() {}
renderQueue() {}
sendSMS() {}
setAPIResponseCallback() {}
setBranchViewData() {}
setIdentity() {}
track() {}
trackCommerceEvent() {}
validateCode() {}
})();
const push = (fn, args) => {
try {
window.branch[fn].apply(window.branch, args);
} catch (e) {
console.error(e);
}
};
queue.forEach(push);
}