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.js11
-rw-r--r--browser/extensions/webcompat/injections/js/bug1452707-window.controllers-shim-ib.absa.co.za.js29
-rw-r--r--browser/extensions/webcompat/injections/js/bug1457335-histography.io-ua-change.js34
-rw-r--r--browser/extensions/webcompat/injections/js/bug1472075-bankofamerica.com-ua-change.js48
-rw-r--r--browser/extensions/webcompat/injections/js/bug1570856-medium.com-menu-isTier1.js34
-rw-r--r--browser/extensions/webcompat/injections/js/bug1579159-m.tailieu.vn-pdfjs-worker-disable.js28
-rw-r--r--browser/extensions/webcompat/injections/js/bug1605611-maps.google.com-directions-time.js82
-rw-r--r--browser/extensions/webcompat/injections/js/bug1610358-pcloud.com-appVersion-change.js25
-rw-r--r--browser/extensions/webcompat/injections/js/bug1631811-datastudio.google.com-indexedDB.js18
-rw-r--r--browser/extensions/webcompat/injections/js/bug1665035-dckids.com-cookieEnabled.js30
-rw-r--r--browser/extensions/webcompat/injections/js/bug1677442-store.hp.com-disable-indexeddb.js20
-rw-r--r--browser/extensions/webcompat/injections/js/bug1682238-gamearter.com-ua-change.js27
12 files changed, 386 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..4e7db8c5f9
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug0000000-testbed-js-injection.js
@@ -0,0 +1,11 @@
+"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/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..d04dcd7638
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1452707-window.controllers-shim-ib.absa.co.za.js
@@ -0,0 +1,29 @@
+"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..8bbab329c4
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1457335-histography.io-ua-change.js
@@ -0,0 +1,34 @@
+"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..0f61422494
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1472075-bankofamerica.com-ua-change.js
@@ -0,0 +1,48 @@
+"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/bug1570856-medium.com-menu-isTier1.js b/browser/extensions/webcompat/injections/js/bug1570856-medium.com-menu-isTier1.js
new file mode 100644
index 0000000000..f8bb926b60
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1570856-medium.com-menu-isTier1.js
@@ -0,0 +1,34 @@
+"use strict";
+
+/**
+ * medium.com - Override window.GLOBALS.useragent.isTier1 to be true
+ * WebCompat issue #25844 - https://webcompat.com/issues/25844
+ *
+ * This site is not showing main menu when scrolling. There is a GLOBALS variable
+ * at the bottom of the template being defined based on a server side UA detection.
+ * Setting window.GLOBALS.useragent.isTier1 to true makes the menu appear when scrolling
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "window.GLOBALS.useragent.isTier1 has been set to true for compatibility reasons. See https://webcompat.com/issues/25844 for details."
+);
+
+let globals = {};
+
+Object.defineProperty(window.wrappedJSObject, "GLOBALS", {
+ get: exportFunction(function() {
+ return globals;
+ }, window),
+
+ set: exportFunction(function(value = {}) {
+ globals = value;
+
+ if (!globals.useragent) {
+ globals.useragent = {};
+ }
+
+ globals.useragent.isTier1 = true;
+ }, 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..b6600e93f8
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1579159-m.tailieu.vn-pdfjs-worker-disable.js
@@ -0,0 +1,28 @@
+"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/bug1605611-maps.google.com-directions-time.js b/browser/extensions/webcompat/injections/js/bug1605611-maps.google.com-directions-time.js
new file mode 100644
index 0000000000..aee07df0cc
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1605611-maps.google.com-directions-time.js
@@ -0,0 +1,82 @@
+"use strict";
+
+/* globals exportFunction */
+
+/**
+ * Bug 1605611 - Cannot change Departure/arrival dates in Google Maps on Android
+ *
+ * This patch does the following:
+ * 1. Re-enable the disabled "Leave now" button.
+ * 2. Fix the precision of datetime-local inputs (to minutes).
+ * 3. Fixup side effect from enabling the date picker UI via
+ * injections/css/bug1605611-maps.google.com-directions-time.css
+ *
+ * See https://bugzilla.mozilla.org/show_bug.cgi?id=1605611#c0 for details.
+ */
+
+// Step 1.
+document.addEventListener("DOMContentLoaded", () => {
+ // In case the element appeared before the MutationObserver was activated.
+ for (const elem of document.querySelectorAll(
+ ".ml-directions-time[disabled]"
+ )) {
+ elem.disabled = false;
+ }
+ // Start watching for the insertion of the "Leave now" button.
+ const moOptions = {
+ attributeFilter: ["disabled"],
+ attributes: true,
+ subtree: true,
+ };
+ const mo = new MutationObserver(function(records) {
+ let restore = false;
+ for (const { target } of records) {
+ if (target.classList.contains("ml-directions-time")) {
+ if (!restore) {
+ restore = true;
+ mo.disconnect();
+ }
+ target.disabled = false;
+ }
+ }
+ if (restore) {
+ mo.observe(document.body, moOptions);
+ }
+ });
+ mo.observe(document.body, moOptions);
+});
+
+// Step 2.
+const originalValueAsNumberGetter = Object.getOwnPropertyDescriptor(
+ HTMLInputElement.prototype.wrappedJSObject,
+ "valueAsNumber"
+).get;
+Object.defineProperty(
+ HTMLInputElement.prototype.wrappedJSObject,
+ "valueAsNumber",
+ {
+ configurable: true,
+ enumerable: true,
+ get: originalValueAsNumberGetter,
+ set: exportFunction(function(v) {
+ if (this.type === "datetime-local" && v) {
+ const d = new Date(v);
+ d.setSeconds(0);
+ d.setMilliseconds(0);
+ v = d.getTime();
+ }
+ this.valueAsNumber = v;
+ }, window),
+ }
+);
+
+// Step 3.
+// injections/css/bug1605611-maps.google.com-directions-time.css fixes the bug,
+// but a side effect of allowing the user to click on the datetime-local input
+// is that the keyboard appears when the native date picker is closed.
+// Fix this by unfocusing the datetime-local input upon focus.
+document.addEventListener("focusin", ({ target }) => {
+ if (target.id === "ml-route-options-time-selector-time-input") {
+ target.blur();
+ }
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1610358-pcloud.com-appVersion-change.js b/browser/extensions/webcompat/injections/js/bug1610358-pcloud.com-appVersion-change.js
new file mode 100644
index 0000000000..c7654227e1
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1610358-pcloud.com-appVersion-change.js
@@ -0,0 +1,25 @@
+"use strict";
+
+/**
+ * Bug 1610358 - Add "mobile" to navigator.appVersion
+ * WebCompat issue #40353 - https://webcompat.com/issues/40353
+ *
+ * the site expecting navigator.appVersion to contain "mobile",
+ * otherwise it's serving a tablet version for Firefox mobile
+ */
+
+/* globals exportFunction */
+
+console.info(
+ "The user agent has been overridden for compatibility reasons. See https://webcompat.com/issues/40353 for details."
+);
+
+const APP_VERSION = navigator.appVersion + " mobile";
+
+Object.defineProperty(window.navigator.wrappedJSObject, "appVersion", {
+ get: exportFunction(function() {
+ return APP_VERSION;
+ }, window),
+
+ set: exportFunction(function() {}, 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..63bb420d8d
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1631811-datastudio.google.com-indexedDB.js
@@ -0,0 +1,18 @@
+"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/bug1665035-dckids.com-cookieEnabled.js b/browser/extensions/webcompat/injections/js/bug1665035-dckids.com-cookieEnabled.js
new file mode 100644
index 0000000000..a243fae54a
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1665035-dckids.com-cookieEnabled.js
@@ -0,0 +1,30 @@
+"use strict";
+
+/**
+ * Bug 1665035 - enable navigator.cookieEnabled and spoof window.navigator on Linux
+ *
+ * Some of the games are not starting because navigator.cookieEnabled
+ * returns false for trackers with ETP strict. Overwriting the value allows
+ * to play the games. In addition, Linux desktop devices are incorrectly
+ * flagged as mobile devices (even if ETP is disabled), so spoofing
+ * window.navigator.platform here.
+ */
+
+console.info(
+ "window.cookieEnabled has been overwritten for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1665035 for details."
+);
+
+Object.defineProperty(window.navigator.wrappedJSObject, "cookieEnabled", {
+ value: true,
+ writable: false,
+});
+
+if (navigator.platform.includes("Linux")) {
+ console.info(
+ "navigator.platform has been overwritten for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1665035 for details."
+ );
+ Object.defineProperty(window.navigator.wrappedJSObject, "platform", {
+ value: "Win64",
+ writable: false,
+ });
+}
diff --git a/browser/extensions/webcompat/injections/js/bug1677442-store.hp.com-disable-indexeddb.js b/browser/extensions/webcompat/injections/js/bug1677442-store.hp.com-disable-indexeddb.js
new file mode 100644
index 0000000000..507e39cff5
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1677442-store.hp.com-disable-indexeddb.js
@@ -0,0 +1,20 @@
+"use strict";
+
+/**
+ * Bug 1677442 - disable indexedDB for d3nkfb7815bs43.cloudfront.net
+ *
+ * The site embeds an iframe with a 3D viewer. The request fails
+ * because BabylonJS (the 3d library) tries to access indexedDB
+ * from the third party context (d3nkfb7815bs43.cloudfront.net)
+ * Disabling indexedDB fixes it, causing it to fetch the 3d resource
+ * via network.
+ */
+
+console.info(
+ "window.indexedDB has been overwritten for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1677442 for details."
+);
+
+Object.defineProperty(window.wrappedJSObject, "indexedDB", {
+ get: undefined,
+ set: undefined,
+});
diff --git a/browser/extensions/webcompat/injections/js/bug1682238-gamearter.com-ua-change.js b/browser/extensions/webcompat/injections/js/bug1682238-gamearter.com-ua-change.js
new file mode 100644
index 0000000000..8475a9486f
--- /dev/null
+++ b/browser/extensions/webcompat/injections/js/bug1682238-gamearter.com-ua-change.js
@@ -0,0 +1,27 @@
+"use strict";
+
+/*
+ * Bug 1682238 - Override navigator.userAgent for gamearter.com on macOS 11.0
+ * Bug 1680516 - Game is not loaded on gamearter.com
+ *
+ * Unity < 2021.1.0a2 is unable to correctly parse User Agents with
+ * "Mac OS X 11.0" in them, so let's override to "Mac OS X 10.16" instead
+ * for now.
+ */
+
+/* globals exportFunction */
+
+if (navigator.userAgent.includes("Mac OS X 11.")) {
+ console.info(
+ "The user agent has been overridden for compatibility reasons. See https://bugzilla.mozilla.org/show_bug.cgi?id=1680516 for details."
+ );
+
+ let originalUA = navigator.userAgent;
+ Object.defineProperty(window.navigator.wrappedJSObject, "userAgent", {
+ get: exportFunction(function() {
+ return originalUA.replace(/Mac OS X 11\.(\d)+;/, "Mac OS X 10.16;");
+ }, window),
+
+ set: exportFunction(function() {}, window),
+ });
+}