summaryrefslogtreecommitdiffstats
path: root/browser/extensions/webcompat/injections/js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/extensions/webcompat/injections/js')
-rw-r--r--browser/extensions/webcompat/injections/js/bug0000000-testbed-js-injection.js15
-rw-r--r--browser/extensions/webcompat/injections/js/bug1448747-fastclick-shim.js35
-rw-r--r--browser/extensions/webcompat/injections/js/bug1452707-window.controllers-shim-ib.absa.co.za.js33
-rw-r--r--browser/extensions/webcompat/injections/js/bug1457335-histography.io-ua-change.js38
-rw-r--r--browser/extensions/webcompat/injections/js/bug1472075-bankofamerica.com-ua-change.js52
-rw-r--r--browser/extensions/webcompat/injections/js/bug1579159-m.tailieu.vn-pdfjs-worker-disable.js32
-rw-r--r--browser/extensions/webcompat/injections/js/bug1631811-datastudio.google.com-indexedDB.js22
-rw-r--r--browser/extensions/webcompat/injections/js/bug1722955-frontgate.com-ua-override.js21
-rw-r--r--browser/extensions/webcompat/injections/js/bug1724868-news.yahoo.co.jp-ua-override.js29
-rw-r--r--browser/extensions/webcompat/injections/js/bug1739489-draftjs-beforeinput.js116
-rw-r--r--browser/extensions/webcompat/injections/js/bug1769762-tiktok.com-plugins-shim.js35
-rw-r--r--browser/extensions/webcompat/injections/js/bug1774005-installtrigger-shim.js26
-rw-r--r--browser/extensions/webcompat/injections/js/bug1790750-relearnings.com-linkedinlearning-iframe-fix.js33
-rw-r--r--browser/extensions/webcompat/injections/js/bug1799968-www.samsung.com-appVersion-linux-fix.js31
-rw-r--r--browser/extensions/webcompat/injections/js/bug1799980-healow.com-infinite-loop-fix.js37
-rw-r--r--browser/extensions/webcompat/injections/js/bug1818818-fastclick-legacy-shim.js24
-rw-r--r--browser/extensions/webcompat/injections/js/bug1819450-cmbchina.com-ua-change.js29
-rw-r--r--browser/extensions/webcompat/injections/js/bug1819476-axisbank.com-webkitSpeechRecognition-shim.js26
-rw-r--r--browser/extensions/webcompat/injections/js/bug1819678-free4talk.com-window-chrome-shim.js25
-rw-r--r--browser/extensions/webcompat/injections/js/bug1830776-blueshieldca.com-unsupported.js24
-rw-r--r--browser/extensions/webcompat/injections/js/bug1831007-nintendo-window-OnetrustActiveGroups.js27
-rw-r--r--browser/extensions/webcompat/injections/js/bug1836157-thai-masszazs-niceScroll-disable.js23
-rw-r--r--browser/extensions/webcompat/injections/js/bug1842437-www.youtube.com-performance-now-precision.js39
-rw-r--r--browser/extensions/webcompat/injections/js/bug1849058-nicochannel.jp-picture-in-picture-shim.js26
-rw-r--r--browser/extensions/webcompat/injections/js/bug1855014-eksiseyler.com.js27
-rw-r--r--browser/extensions/webcompat/injections/js/bug1855071-www.meteoam.it.js46
-rw-r--r--browser/extensions/webcompat/injections/js/bug1859617-installtrigger-removal-shim.js26
-rw-r--r--browser/extensions/webcompat/injections/js/bug1864564-esri-transfrom-names-shim.js46
28 files changed, 943 insertions, 0 deletions
diff --git a/browser/extensions/webcompat/injections/js/bug0000000-testbed-js-injection.js b/browser/extensions/webcompat/injections/js/bug0000000-testbed-js-injection.js
new file mode 100644
index 0000000000..7a192d6c41
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug0000000-testbed-js-injection.js
@@ -0,0 +1,15 @@
+/* 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";
+
+/* globals exportFunction */
+
+Object.defineProperty(window.wrappedJSObject, "isTestFeatureSupported", {
+ get: exportFunction(function () {
+ return true;
+ }, window),
+
+ set: exportFunction(function () {}, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1448747-fastclick-shim.js b/browser/extensions/webcompat/injections/js/bug1448747-fastclick-shim.js
new file mode 100644
index 0000000000..7a8e85f538
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1448747-fastclick-shim.js
@@ -0,0 +1,35 @@
+/* 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 1448747 - Neutralize FastClick
+ *
+ * The patch is applied on sites using FastClick library
+ * to make sure `FastClick.notNeeded` returns `true`.
+ * This allows to disable FastClick and fix various breakage caused
+ * by the library (mainly non-functioning drop-down lists).
+ */
+
+/* globals exportFunction */
+
+(function () {
+ const proto = CSS2Properties.prototype.wrappedJSObject;
+ const descriptor = Object.getOwnPropertyDescriptor(proto, "touchAction");
+ const { get } = descriptor;
+
+ descriptor.get = exportFunction(function () {
+ try {
+ throw Error();
+ } catch (e) {
+ if (e.stack?.includes("notNeeded")) {
+ return "none";
+ }
+ }
+ return get.call(this);
+ }, window);
+
+ Object.defineProperty(proto, "touchAction", descriptor);
+})();
diff --git a/browser/extensions/webcompat/injections/js/bug1452707-window.controllers-shim-ib.absa.co.za.js b/browser/extensions/webcompat/injections/js/bug1452707-window.controllers-shim-ib.absa.co.za.js
new file mode 100644
index 0000000000..40e17b4a36
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1452707-window.controllers-shim-ib.absa.co.za.js
@@ -0,0 +1,33 @@
+/* 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 1452707 - Build site patch for ib.absa.co.za
+ * WebCompat issue #16401 - https://webcompat.com/issues/16401
+ *
+ * The online banking at ib.absa.co.za detect if window.controllers is a
+ * non-falsy value to detect if the current browser is Firefox or something
+ * else. In bug 1448045, this shim has been disabled for Firefox Nightly 61+,
+ * which breaks the UA detection on this site and results in a "Browser
+ * unsuppored" error message.
+ *
+ * This site patch simply sets window.controllers to a string, resulting in
+ * their check to work again.
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "window.controllers has been shimmed for compatibility reasons. See https://webcompat.com/issues/16401 for details."
+);
+
+Object.defineProperty(window.wrappedJSObject, "controllers", {
+ get: exportFunction(function () {
+ return true;
+ }, window),
+
+ set: exportFunction(function () {}, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1457335-histography.io-ua-change.js b/browser/extensions/webcompat/injections/js/bug1457335-histography.io-ua-change.js
new file mode 100644
index 0000000000..06085acc5a
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1457335-histography.io-ua-change.js
@@ -0,0 +1,38 @@
+/* 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 1457335 - histography.io - Override UA & navigator.vendor
+ * WebCompat issue #1804 - https://webcompat.com/issues/1804
+ *
+ * This site is using a strict matching of navigator.userAgent and
+ * navigator.vendor to allow access for Safari or Chrome. Here, we set the
+ * values appropriately so we get recognized as Chrome.
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "The user agent has been overridden for compatibility reasons. See https://webcompat.com/issues/1804 for details."
+);
+
+const CHROME_UA = navigator.userAgent + " Chrome for WebCompat";
+
+Object.defineProperty(window.navigator.wrappedJSObject, "userAgent", {
+ get: exportFunction(function () {
+ return CHROME_UA;
+ }, window),
+
+ set: exportFunction(function () {}, window),
+});
+
+Object.defineProperty(window.navigator.wrappedJSObject, "vendor", {
+ get: exportFunction(function () {
+ return "Google Inc.";
+ }, window),
+
+ set: exportFunction(function () {}, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1472075-bankofamerica.com-ua-change.js b/browser/extensions/webcompat/injections/js/bug1472075-bankofamerica.com-ua-change.js
new file mode 100644
index 0000000000..5aa72e75ae
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1472075-bankofamerica.com-ua-change.js
@@ -0,0 +1,52 @@
+/* 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 1472075 - Build UA override for Bank of America for OSX & Linux
+ * WebCompat issue #2787 - https://webcompat.com/issues/2787
+ *
+ * BoA is showing a red warning to Linux and macOS users, while accepting
+ * Windows users without warning. From our side, there is no difference here
+ * and we receive a lot of user complains about the warnings, so we spoof
+ * as Firefox on Windows in those cases.
+ */
+
+/* globals exportFunction */
+
+if (!navigator.platform.includes("Win")) {
+ console.info(
+ "The user agent has been overridden for compatibility reasons. See https://webcompat.com/issues/2787 for details."
+ );
+
+ const WINDOWS_UA = navigator.userAgent.replace(
+ /\(.*; rv:/i,
+ "(Windows NT 10.0; Win64; x64; rv:"
+ );
+
+ Object.defineProperty(window.navigator.wrappedJSObject, "userAgent", {
+ get: exportFunction(function () {
+ return WINDOWS_UA;
+ }, window),
+
+ set: exportFunction(function () {}, window),
+ });
+
+ Object.defineProperty(window.navigator.wrappedJSObject, "appVersion", {
+ get: exportFunction(function () {
+ return "appVersion";
+ }, window),
+
+ set: exportFunction(function () {}, window),
+ });
+
+ Object.defineProperty(window.navigator.wrappedJSObject, "platform", {
+ get: exportFunction(function () {
+ return "Win64";
+ }, window),
+
+ set: exportFunction(function () {}, window),
+ });
+}
diff --git a/browser/extensions/webcompat/injections/js/bug1579159-m.tailieu.vn-pdfjs-worker-disable.js b/browser/extensions/webcompat/injections/js/bug1579159-m.tailieu.vn-pdfjs-worker-disable.js
new file mode 100644
index 0000000000..5c757466c6
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1579159-m.tailieu.vn-pdfjs-worker-disable.js
@@ -0,0 +1,32 @@
+/* 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";
+
+/**
+ * m.tailieu.vn - Override PDFJS.disableWorker to be true
+ * WebCompat issue #39057 - https://webcompat.com/issues/39057
+ *
+ * Custom viewer built with PDF.js is not working in Firefox for Android
+ * Disabling worker to match Chrome behavior fixes the issue
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "window.PDFJS.disableWorker has been set to true for compatibility reasons. See https://webcompat.com/issues/39057 for details."
+);
+
+let globals = {};
+
+Object.defineProperty(window.wrappedJSObject, "PDFJS", {
+ get: exportFunction(function () {
+ return globals;
+ }, window),
+
+ set: exportFunction(function (value = {}) {
+ globals = value;
+ globals.disableWorker = true;
+ }, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1631811-datastudio.google.com-indexedDB.js b/browser/extensions/webcompat/injections/js/bug1631811-datastudio.google.com-indexedDB.js
new file mode 100644
index 0000000000..fb9be74039
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1631811-datastudio.google.com-indexedDB.js
@@ -0,0 +1,22 @@
+/* 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 1631811 - disable indexedDB for datastudio.google.com iframes
+ *
+ * Indexed DB is disabled already for these iframes due to cookie blocking.
+ * This intervention changes the functionality from throwing a SecurityError
+ * when indexedDB is accessed to removing it from the window object
+ */
+
+console.info(
+ "window.indexedDB has been overwritten for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1631811 for details."
+);
+
+Object.defineProperty(window.wrappedJSObject, "indexedDB", {
+ get: undefined,
+ set: undefined,
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1722955-frontgate.com-ua-override.js b/browser/extensions/webcompat/injections/js/bug1722955-frontgate.com-ua-override.js
new file mode 100644
index 0000000000..577a55450a
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1722955-frontgate.com-ua-override.js
@@ -0,0 +1,21 @@
+/* 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 1722955 - Add UA override for frontgate.com
+ * Webcompat issue #36277 - https://github.com/webcompat/web-bugs/issues/36277
+ *
+ * The website is sending the desktop version to Firefox on mobile devices
+ * based on UA sniffing. Spoofing as Chrome fixes this.
+ */
+
+/* globals exportFunction, UAHelpers */
+
+console.info(
+ "The user agent has been overridden for compatibility reasons. See https://webcompat.com/issues/36277 for details."
+);
+
+UAHelpers.overrideWithDeviceAppropriateChromeUA();
diff --git a/browser/extensions/webcompat/injections/js/bug1724868-news.yahoo.co.jp-ua-override.js b/browser/extensions/webcompat/injections/js/bug1724868-news.yahoo.co.jp-ua-override.js
new file mode 100644
index 0000000000..ab7b76c799
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1724868-news.yahoo.co.jp-ua-override.js
@@ -0,0 +1,29 @@
+/* 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 1724868 - news.yahoo.co.jp - Override UA
+ * WebCompat issue #82605 - https://webcompat.com/issues/82605
+ *
+ * Yahoo Japan news doesn't allow playing video in Firefox on Android
+ * as they don't have it in their support matrix. They check UA override twice
+ * and display different ui with the same error. Changing UA to Chrome via
+ * content script allows playing the videos.
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "The user agent has been overridden for compatibility reasons. See https://webcompat.com/issues/82605 for details."
+);
+
+Object.defineProperty(window.navigator.wrappedJSObject, "userAgent", {
+ get: exportFunction(function () {
+ return "Mozilla/5.0 (Linux; Android 11; Pixel 4a) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Mobile Safari/537.36";
+ }, window),
+
+ set: exportFunction(function () {}, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1739489-draftjs-beforeinput.js b/browser/extensions/webcompat/injections/js/bug1739489-draftjs-beforeinput.js
new file mode 100644
index 0000000000..5ae55ec6f3
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1739489-draftjs-beforeinput.js
@@ -0,0 +1,116 @@
+/* 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 1739489 - Entering an emoji using the MacOS IME "crashes" Draft.js editors.
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "textInput event has been remapped to beforeinput for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1739489 for details."
+);
+
+window.wrappedJSObject.TextEvent = window.wrappedJSObject.InputEvent;
+
+const { CustomEvent, Event, EventTarget } = window.wrappedJSObject;
+var Remapped = [
+ [CustomEvent, "constructor"],
+ [Event, "constructor"],
+ [Event, "initEvent"],
+ [EventTarget, "addEventListener"],
+ [EventTarget, "removeEventListener"],
+];
+
+for (const [obj, name] of Remapped) {
+ const { prototype } = obj;
+ const orig = prototype[name];
+ Object.defineProperty(prototype, name, {
+ value: exportFunction(function (type, b, c, d) {
+ if (type?.toLowerCase() === "textinput") {
+ type = "beforeinput";
+ }
+ return orig.call(this, type, b, c, d);
+ }, window),
+ });
+}
+
+if (location.host === "www.reddit.com") {
+ (function () {
+ const EditorCSS = ".public-DraftEditor-content[contenteditable=true]";
+ let obsEditor, obsStart, obsText, obsKey, observer;
+ const obsConfig = { characterData: true, childList: true, subtree: true };
+ const obsHandler = () => {
+ observer.disconnect();
+ const finalTextNode = obsEditor.querySelector(
+ `[data-offset-key="${obsKey}"] [data-text='true']`
+ ).firstChild;
+ const end = obsStart + obsText.length;
+ window
+ .getSelection()
+ .setBaseAndExtent(finalTextNode, end, finalTextNode, end);
+ };
+ observer = new MutationObserver(obsHandler);
+
+ document.documentElement.addEventListener(
+ "beforeinput",
+ e => {
+ if (e.inputType != "insertFromPaste") {
+ return;
+ }
+ const { target } = e;
+ obsEditor = target.closest(EditorCSS);
+ if (!obsEditor) {
+ return;
+ }
+ const items = e?.dataTransfer.items;
+ for (let item of items) {
+ if (item.type === "text/plain") {
+ e.preventDefault();
+ item.getAsString(text => {
+ obsText = text;
+
+ // find the editor-managed <span> which contains the text node the
+ // cursor starts on, and the cursor's location (or the selection start)
+ const sel = window.getSelection();
+ obsStart = sel.anchorOffset;
+ let anchor = sel.anchorNode;
+ if (!anchor.closest) {
+ anchor = anchor.parentElement;
+ }
+ anchor = anchor.closest("[data-offset-key]");
+ obsKey = anchor.getAttribute("data-offset-key");
+
+ // set us up to wait for the editor to either update or replace the
+ // <span> with that key (the one containing the text to be changed).
+ // we will then make sure the cursor is after the pasted text, as if
+ // the editor recreates the node, the cursor position is lost
+ observer.observe(obsEditor, obsConfig);
+
+ // force the editor to "paste". sending paste or other events will not
+ // work, nor using execCommand (adding HTML will screw up the DOM that
+ // the editor expects, and adding plain text will make it ignore newlines).
+ target.dispatchEvent(
+ new InputEvent("beforeinput", {
+ inputType: "insertText",
+ data: text,
+ bubbles: true,
+ cancelable: true,
+ })
+ );
+
+ // blur the editor to force it to update/flush its state, because otherwise
+ // the paste works, but the editor doesn't show it (until it is re-focused).
+ obsEditor.blur();
+ });
+ break;
+ }
+ }
+ },
+ true
+ );
+ })();
+}
diff --git a/browser/extensions/webcompat/injections/js/bug1769762-tiktok.com-plugins-shim.js b/browser/extensions/webcompat/injections/js/bug1769762-tiktok.com-plugins-shim.js
new file mode 100644
index 0000000000..7383a4e567
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1769762-tiktok.com-plugins-shim.js
@@ -0,0 +1,35 @@
+/* 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 1769762 - Empty out navigator.plugins
+ * WebCompat issue #103612 - https://webcompat.com/issues/103612
+ *
+ * Certain features of the site are breaking if navigator.plugins array is not empty:
+ *
+ * 1. "Likes" on the comments are not saved
+ * 2. Can't reply to other people's comments
+ * 3. "Likes" on the videos are not saved
+ * 4. Can't follow an account (after refreshing "Follow" button is visible again)
+ *
+ * (note that the first 2 are still broken if you open devtools even with this intervention)
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "The PluginArray has been overridden for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1753874 for details."
+);
+
+const pluginsArray = new window.wrappedJSObject.Array();
+Object.setPrototypeOf(pluginsArray, PluginArray.prototype);
+
+Object.defineProperty(navigator.wrappedJSObject, "plugins", {
+ get: exportFunction(function () {
+ return pluginsArray;
+ }, window),
+ set: exportFunction(function (val) {}, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1774005-installtrigger-shim.js b/browser/extensions/webcompat/injections/js/bug1774005-installtrigger-shim.js
new file mode 100644
index 0000000000..ca7ef5b6c5
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1774005-installtrigger-shim.js
@@ -0,0 +1,26 @@
+/* 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 1774005 - Generic window.InstallTrigger shim
+ *
+ * This interventions shims window.InstallTrigger to a string, which evaluates
+ * as `true` in web developers browser sniffing code. This intervention will
+ * be applied to multiple domains, see bug 1774005 for more information.
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "The InstallTrigger has been shimmed for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1774005 for details."
+);
+
+Object.defineProperty(window.wrappedJSObject, "InstallTrigger", {
+ get: exportFunction(function () {
+ return "This property has been shimed for Web Compatibility reasons.";
+ }, window),
+ set: exportFunction(function (_) {}, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1790750-relearnings.com-linkedinlearning-iframe-fix.js b/browser/extensions/webcompat/injections/js/bug1790750-relearnings.com-linkedinlearning-iframe-fix.js
new file mode 100644
index 0000000000..4ad0e6f4e7
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1790750-relearnings.com-linkedinlearning-iframe-fix.js
@@ -0,0 +1,33 @@
+/* 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 1790750 - The page is blank on relearnings.com/linkedinlearning.html
+ * with ETP set to Standard
+ *
+ * The linkedin video iframe loaded on relearnings.com/linkedinlearning.html is
+ * denied storage access by ETP due to being a tracker breaking the website.
+ * Since the iframe is a video which users want to access if visiting the URL
+ * this intervention sets the window location to the iframe URL allowing it
+ * first party storage access.
+ */
+
+/* globals exportFunction */
+
+const LINKEDIN_LEARNING_PATH_PREFIX =
+ "https://www.linkedin.com/learning/embed/";
+
+document.addEventListener("DOMContentLoaded", function () {
+ let iframes = document.getElementsByTagName("iframe");
+ if (iframes.length === 1) {
+ if (iframes[0].src.startsWith(LINKEDIN_LEARNING_PATH_PREFIX)) {
+ window.location = iframes[0].src;
+ console.info(
+ "The window.location has been changed for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1790750 for details."
+ );
+ }
+ }
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1799968-www.samsung.com-appVersion-linux-fix.js b/browser/extensions/webcompat/injections/js/bug1799968-www.samsung.com-appVersion-linux-fix.js
new file mode 100644
index 0000000000..941f071e2c
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1799968-www.samsung.com-appVersion-linux-fix.js
@@ -0,0 +1,31 @@
+/* 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 1799968 - Build site patch for www.samsung.com
+ * WebCompat issue #108993 - https://webcompat.com/issues/108993
+ *
+ * Samsung's Watch pages try to detect the OS via navigator.appVersion,
+ * but fail with Linux because they expect it to contain the literal
+ * string "linux", and their JS breaks.
+ *
+ * As such this site patch sets appVersion to "5.0 (Linux)", and is
+ * only meant to be applied on Linux.
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "navigator.appVersion has been shimmed for compatibility reasons. See https://webcompat.com/issues/108993 for details."
+);
+
+Object.defineProperty(navigator.wrappedJSObject, "appVersion", {
+ get: exportFunction(function () {
+ return "5.0 (Linux)";
+ }, window),
+
+ set: exportFunction(function () {}, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1799980-healow.com-infinite-loop-fix.js b/browser/extensions/webcompat/injections/js/bug1799980-healow.com-infinite-loop-fix.js
new file mode 100644
index 0000000000..191e97dec1
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1799980-healow.com-infinite-loop-fix.js
@@ -0,0 +1,37 @@
+/* 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 1799980 - Healow gets stuck in an infinite loop while pages load
+ *
+ * This patch keeps Healow's localization scripts from getting stuck in
+ * an infinite loop while their pages are loading.
+ *
+ * This happens because they use synchronous XMLHttpRequests to fetch a
+ * JSON file with their localized text on the first call to their i18n
+ * function, and then force subsequent calls to wait for it by waiting
+ * in an infinite loop.
+ *
+ * But since they're in an infinite loop, the code after the syncXHR will
+ * never be able to run, so this ultimately triggers a slow script warning.
+ *
+ * We can improve this by just preventing the infinite loop from happening,
+ * though since they disable caching on their JSON files it means that more
+ * XHRs may happen. But since those files are small, this seems like a
+ * reasonable compromise until they migrate to a better i18n solution.
+ *
+ * See https://bugzilla.mozilla.org/show_bug.cgi?id=1799980 for details.
+ */
+
+/* globals exportFunction */
+
+Object.defineProperty(window.wrappedJSObject, "ajaxRequestProcessing", {
+ get: exportFunction(function () {
+ return false;
+ }, window),
+
+ set: exportFunction(function () {}, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1818818-fastclick-legacy-shim.js b/browser/extensions/webcompat/injections/js/bug1818818-fastclick-legacy-shim.js
new file mode 100644
index 0000000000..91f1c1a19a
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1818818-fastclick-legacy-shim.js
@@ -0,0 +1,24 @@
+/* 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 1818818 - Neutralize FastClick
+ *
+ * The patch is applied on sites using older version of FastClick library.
+ * This allows to disable FastClick and fix various breakage caused
+ * by the library.
+ */
+
+/* globals exportFunction */
+
+const proto = CSS2Properties.prototype.wrappedJSObject;
+Object.defineProperty(proto, "msTouchAction", {
+ get: exportFunction(function () {
+ return "none";
+ }, window),
+
+ set: exportFunction(function () {}, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1819450-cmbchina.com-ua-change.js b/browser/extensions/webcompat/injections/js/bug1819450-cmbchina.com-ua-change.js
new file mode 100644
index 0000000000..bbe76c465f
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1819450-cmbchina.com-ua-change.js
@@ -0,0 +1,29 @@
+/* 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 1819450 - cmbchina.com - Override UA
+ *
+ * The site is using UA detection to redirect to
+ * m.cmbchina.com (mobile version of the site). Adding `SAMSUNG` allows
+ * to bypass the detection of mobile browser.
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "The user agent has been overridden for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1081239 for details."
+);
+
+const MODIFIED_UA = navigator.userAgent + " SAMSUNG";
+
+Object.defineProperty(window.navigator.wrappedJSObject, "userAgent", {
+ get: exportFunction(function () {
+ return MODIFIED_UA;
+ }, window),
+
+ set: exportFunction(function () {}, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1819476-axisbank.com-webkitSpeechRecognition-shim.js b/browser/extensions/webcompat/injections/js/bug1819476-axisbank.com-webkitSpeechRecognition-shim.js
new file mode 100644
index 0000000000..a72e938e4f
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1819476-axisbank.com-webkitSpeechRecognition-shim.js
@@ -0,0 +1,26 @@
+/* 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";
+
+/**
+ * axisbank.com - Shim webkitSpeechRecognition
+ * WebCompat issue #117770 - https://webcompat.com/issues/117770
+ *
+ * The page with bank offerings is not loading options due to the
+ * site relying on webkitSpeechRecognition, which is undefined in Firefox.
+ * Shimming it to `class {}` makes the pages work.
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "webkitSpeechRecognition was shimmed for compatibility reasons. See https://webcompat.com/issues/117770 for details."
+);
+
+Object.defineProperty(window.wrappedJSObject, "webkitSpeechRecognition", {
+ value: exportFunction(function () {
+ return class {};
+ }, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1819678-free4talk.com-window-chrome-shim.js b/browser/extensions/webcompat/injections/js/bug1819678-free4talk.com-window-chrome-shim.js
new file mode 100644
index 0000000000..6e6b5823cb
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1819678-free4talk.com-window-chrome-shim.js
@@ -0,0 +1,25 @@
+/* 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 1827678 - UA spoof for www.free4talk.com
+ *
+ * This site is checking for window.chrome, so let's spoof that.
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "window.chrome has been shimmed for compatibility reasons. See https://github.com/webcompat/web-bugs/issues/77727 for details."
+);
+
+Object.defineProperty(window.wrappedJSObject, "chrome", {
+ get: exportFunction(function () {
+ return true;
+ }, window),
+
+ set: exportFunction(function () {}, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1830776-blueshieldca.com-unsupported.js b/browser/extensions/webcompat/injections/js/bug1830776-blueshieldca.com-unsupported.js
new file mode 100644
index 0000000000..2b1eb11baf
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1830776-blueshieldca.com-unsupported.js
@@ -0,0 +1,24 @@
+/* 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 1830776 - blueshieldca.com
+ * WebCompat issue #112630 - https://webcompat.com/issues/112630
+ *
+ * The site is showing unsupported message in Firefox.
+ * They're also checking for "browserCollapsed" item in sessionStorage
+ * before showing the message, to only show it once. Adding this
+ * item to sessionStorage will make sure the message is not shown
+ * on the initial load.
+ */
+
+console.info(
+ "browserCollapsed in sessionStorage has been shimmed for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1830776 for details."
+);
+
+if (!sessionStorage.getItem("browserCollapsed")) {
+ sessionStorage.setItem("browserCollapsed", "true");
+}
diff --git a/browser/extensions/webcompat/injections/js/bug1831007-nintendo-window-OnetrustActiveGroups.js b/browser/extensions/webcompat/injections/js/bug1831007-nintendo-window-OnetrustActiveGroups.js
new file mode 100644
index 0000000000..433c416770
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1831007-nintendo-window-OnetrustActiveGroups.js
@@ -0,0 +1,27 @@
+/* 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 1831007 - Shim window.OnetrustActiveGroups for Nintendo sites
+ *
+ * Nintendo relies on `window.OnetrustActiveGroups` being defined. If it's not,
+ * users may have intermittent issues signing into their account, as they're
+ * then trying to call `.split()` on `undefined`.
+ *
+ * This intervention sets a default value (an empty string), but still allows
+ * the value to be overwritten at any time.
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "The window.OnetrustActiveGroups property has been shimmed for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1831007 for details."
+);
+
+Object.defineProperty(window.wrappedJSObject, "OnetrustActiveGroups", {
+ value: "",
+ writable: true,
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1836157-thai-masszazs-niceScroll-disable.js b/browser/extensions/webcompat/injections/js/bug1836157-thai-masszazs-niceScroll-disable.js
new file mode 100644
index 0000000000..719267748b
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1836157-thai-masszazs-niceScroll-disable.js
@@ -0,0 +1,23 @@
+/* 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/. */
+
+/**
+ * Bug 1836157 - Shim navigator.platform on www.thai-massaszs.net/en/
+ *
+ * This page adds niceScroll on Android, which breaks scrolling and
+ * zooming on Firefox. Adding ` Mac` to `navigator.platform` makes
+ * the page avoid adding niceScroll entirely, unbreaking the page.
+ */
+
+var plat = navigator.platform;
+if (!plat.includes("Mac")) {
+ console.info(
+ "The navigator.platform property has been shimmed to include 'Mac' for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1836157 for details."
+ );
+
+ Object.defineProperty(navigator.__proto__.wrappedJSObject, "platform", {
+ value: plat + " Mac",
+ writable: true,
+ });
+}
diff --git a/browser/extensions/webcompat/injections/js/bug1842437-www.youtube.com-performance-now-precision.js b/browser/extensions/webcompat/injections/js/bug1842437-www.youtube.com-performance-now-precision.js
new file mode 100644
index 0000000000..2d328de108
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1842437-www.youtube.com-performance-now-precision.js
@@ -0,0 +1,39 @@
+/* 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 1842437 - When attempting to go back on youtube.com, the content remains the same
+ *
+ * If consecutive session history entries had history.state.entryTime set to same value,
+ * back button doesn't work as expected. The entryTime value is coming from performance.now()
+ * and modifying its return value slightly to make sure two close consecutive calls don't
+ * get the same result helped with resolving the issue.
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "performance.now precision has been modified for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1756970 for details."
+);
+
+const origPerf = performance.wrappedJSObject;
+const origNow = origPerf.now;
+
+let counter = 0;
+let previousVal = 0;
+
+Object.defineProperty(window.performance.wrappedJSObject, "now", {
+ value: exportFunction(function () {
+ let originalVal = origNow.call(origPerf);
+ if (originalVal === previousVal) {
+ originalVal += 0.00000003 * ++counter;
+ } else {
+ previousVal = originalVal;
+ counter = 0;
+ }
+ return originalVal;
+ }, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1849058-nicochannel.jp-picture-in-picture-shim.js b/browser/extensions/webcompat/injections/js/bug1849058-nicochannel.jp-picture-in-picture-shim.js
new file mode 100644
index 0000000000..16245858ca
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1849058-nicochannel.jp-picture-in-picture-shim.js
@@ -0,0 +1,26 @@
+/* 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 1849058 - Shim PictureInPictureWindow for nicochannel.jp
+ * WebCompat issue #124463 - https://webcompat.com/issues/124463
+ *
+ * The page is showing unsupported message based on typeof
+ * window.PictureInPictureWindow, which is undefined in Firefox.
+ * Shimming it to `class {}` makes the pages work.
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "PictureInPictureWindow was shimmed for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1849058 for details."
+);
+
+Object.defineProperty(window.wrappedJSObject, "PictureInPictureWindow", {
+ value: exportFunction(function () {
+ return class {};
+ }, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1855014-eksiseyler.com.js b/browser/extensions/webcompat/injections/js/bug1855014-eksiseyler.com.js
new file mode 100644
index 0000000000..9c22c762a9
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1855014-eksiseyler.com.js
@@ -0,0 +1,27 @@
+/* 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";
+
+/**
+ * eksiseyler.com - Set window.loggingEnabled = false
+ * WebCompat issue #77221 - https://webcompat.com/issues/77221
+ *
+ * A scripting error on the site causes images to not load unless
+ * window.loggingEnabled = false
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "loggingEnabled been set to true for compatibility reasons. See https://webcompat.com/issues/77221 for details."
+);
+
+Object.defineProperty(window.wrappedJSObject, "loggingEnabled", {
+ get: exportFunction(function () {
+ return false;
+ }, window),
+
+ set: exportFunction(function (value = {}) {}, window),
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1855071-www.meteoam.it.js b/browser/extensions/webcompat/injections/js/bug1855071-www.meteoam.it.js
new file mode 100644
index 0000000000..2bf38345dc
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1855071-www.meteoam.it.js
@@ -0,0 +1,46 @@
+/* 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";
+
+/**
+ * www.meteoam.it - virtual keyboard is hidden as it is opened
+ * webcompat issue #121197 - https://webcompat.com/issues/121197
+ *
+ * the site's map is 75vh tall, and it hides the keyboard onresize,
+ * meaning the keyboard is closed as it it brought up in Firefox.
+ */
+
+console.info(
+ "Map iframe height is being managed for compatibility reasons. see https://webcompat.com/issues/77221 for details."
+);
+
+const selector = "#iframe_map";
+
+const moOptions = {
+ childList: true,
+ subtree: true,
+};
+
+const mo = new MutationObserver(() => {
+ const map = document.querySelector(selector);
+ let lastSize;
+ if (map) {
+ mo.disconnect();
+ const maybeGrowMap = () => {
+ const winHeight = window.outerHeight;
+ if (lastSize && lastSize > winHeight) {
+ return;
+ }
+ map.style.height = winHeight * 0.75 + "px";
+ lastSize = winHeight;
+ };
+ maybeGrowMap();
+ window.addEventListener("resize", () =>
+ window.requestAnimationFrame(maybeGrowMap)
+ );
+ }
+});
+
+mo.observe(document.documentElement, moOptions);
diff --git a/browser/extensions/webcompat/injections/js/bug1859617-installtrigger-removal-shim.js b/browser/extensions/webcompat/injections/js/bug1859617-installtrigger-removal-shim.js
new file mode 100644
index 0000000000..e91ef64422
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1859617-installtrigger-removal-shim.js
@@ -0,0 +1,26 @@
+/* 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 1859617 - Generic window.InstallTrigger removal shim
+ *
+ * This interventions shims window.InstallTrigger to undefine it.
+ */
+
+/* globals exportFunction */
+
+if (typeof window.InstallTrigger !== "undefined") {
+ console.info(
+ "window.InstallTrigger has been undefined for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1859617 for details."
+ );
+
+ Object.defineProperty(window.wrappedJSObject, "InstallTrigger", {
+ get: exportFunction(function () {
+ return undefined;
+ }, window),
+ set: exportFunction(function (_) {}, window),
+ });
+}
diff --git a/browser/extensions/webcompat/injections/js/bug1864564-esri-transfrom-names-shim.js b/browser/extensions/webcompat/injections/js/bug1864564-esri-transfrom-names-shim.js
new file mode 100644
index 0000000000..99bad007cc
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1864564-esri-transfrom-names-shim.js
@@ -0,0 +1,46 @@
+/* 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 1864564 - Override esri._css.names containing -moz-prefixed css rules names
+ * Webcompat issue #129144 - https://github.com/webcompat/web-bugs/issues/129144
+ *
+ * Esri library is applying -moz-transform to maps built with it, based on UA detection.
+ * Since support for -moz-transform has been removed in
+ * https://bugzilla.mozilla.org/show_bug.cgi?id=1855763, this results
+ * in maps partially or incorrectly displayed. Overriding esri._css.names
+ * containing -moz-prefixed css properties to their unprefixed versions
+ * fixes the issues.
+ */
+
+/* globals exportFunction, cloneInto */
+
+console.info(
+ "Overriding esri._css.names for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1864564 for details."
+);
+
+const transformNames = {
+ transition: "transition",
+ transform: "transform",
+ transformName: "transform",
+ origin: "transformOrigin",
+ endEvent: "transitionend",
+};
+
+let esriGlobal;
+
+Object.defineProperty(window.wrappedJSObject, "esri", {
+ get: exportFunction(function () {
+ if ("_css" in esriGlobal && "names" in esriGlobal._css) {
+ esriGlobal._css.names = cloneInto(transformNames, esriGlobal);
+ }
+ return esriGlobal;
+ }, window),
+
+ set: exportFunction(function (value) {
+ esriGlobal = value;
+ }, window),
+});