Bug 1583225 - Import WebCompat GoFaster 6.1.0 sources; r=miketaylr

Import WebCompat GoFaster 6.1.0 sources

Differential Revision: https://phabricator.services.mozilla.com/D46814

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Thomas Wisniewski 2019-09-24 13:08:42 +00:00
Родитель 853a3f73c7
Коммит 3dafbad575
40 изменённых файлов: 1506 добавлений и 120 удалений

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

@ -31,7 +31,6 @@ const AVAILABLE_INJECTIONS = [
file: "injections/js/bug0000000-testbed-js-injection.js",
},
],
runAt: "document_start",
},
},
{
@ -47,7 +46,6 @@ const AVAILABLE_INJECTIONS = [
"injections/js/bug1452707-window.controllers-shim-ib.absa.co.za.js",
},
],
runAt: "document_start",
},
},
{
@ -62,7 +60,6 @@ const AVAILABLE_INJECTIONS = [
file: "injections/js/bug1457335-histography.io-ua-change.js",
},
],
runAt: "document_start",
},
},
{
@ -77,7 +74,6 @@ const AVAILABLE_INJECTIONS = [
file: "injections/js/bug1472075-bankofamerica.com-ua-change.js",
},
],
runAt: "document_start",
},
},
{
@ -87,14 +83,13 @@ const AVAILABLE_INJECTIONS = [
bug: "1472081",
contentScripts: {
matches: ["http://202.166.205.141/bbvrs/*"],
allFrames: true,
js: [
{
file:
"injections/js/bug1472081-election.gov.np-window.sidebar-shim.js",
},
],
runAt: "document_start",
allFrames: true,
},
},
{
@ -104,16 +99,68 @@ const AVAILABLE_INJECTIONS = [
bug: "1482066",
contentScripts: {
matches: ["*://portalminasnet.com/*"],
allFrames: true,
js: [
{
file:
"injections/js/bug1482066-portalminasnet.com-window.sidebar-shim.js",
},
],
runAt: "document_start",
},
},
{
id: "bug1570856",
platform: "android",
domain: "medium.com",
bug: "1570856",
contentScripts: {
matches: ["*://medium.com/*"],
js: [
{
file: "injections/js/bug1570856-medium.com-menu-isTier1.js",
},
],
allFrames: true,
},
},
{
id: "bug1579159",
platform: "android",
domain: "m.tailieu.vn",
bug: "1579159",
contentScripts: {
matches: ["*://m.tailieu.vn/*", "*://m.elib.vn/*"],
js: [
{
file: "injections/js/bug1579159-m.tailieu.vn-pdfjs-worker-disable.js",
},
],
allFrames: true,
},
},
{
id: "bug1577245",
platform: "android",
domain: "help.pandora.com",
bug: "1577245",
contentScripts: {
matches: [
"https://faq.usps.com/*",
"https://help.duo.com/*",
"https://help.hulu.com/*",
"https://help.pandora.com/*",
"https://my211.force.com/*",
"https://support.paypay.ne.jp/*",
"https://usps.force.com/*",
],
js: [
{
file:
"injections/js/bug1577245-salesforce-communities-hide-unsupported.js",
},
],
},
},
{
id: "bug1526977",
platform: "desktop",
@ -147,10 +194,25 @@ const AVAILABLE_INJECTIONS = [
platform: "android",
domain: "Sites using PDK 5 video",
bug: "1551672",
pdk5fix: {
data: {
urls: ["https://*/*/tpPdk.js", "https://*/*/pdk/js/*/*.js"],
types: ["script"],
},
customFunc: "pdk5fix",
},
{
id: "bug1577870",
platform: "desktop",
domain: "slideshare.net",
bug: "1577870",
data: {
urls: ["https://*.linkedin.com/tscp-serving/dtag*"],
contentType: {
name: "content-type",
value: "text/html; charset=utf-8",
},
},
customFunc: "dtagFix",
},
{
id: "bug1305028",
@ -217,7 +279,7 @@ const AVAILABLE_INJECTIONS = [
domain: "dns.google.com",
bug: "1567610",
contentScripts: {
matches: ["*://dns.google.com/*"],
matches: ["*://dns.google.com/*", "*://dns.google/*"],
css: [
{
file: "injections/css/bug1567610-dns.google.com-moz-fit-content.css",
@ -239,6 +301,136 @@ const AVAILABLE_INJECTIONS = [
],
},
},
{
id: "bug1568908",
platform: "desktop",
domain: "console.cloud.google.com",
bug: "1568908",
contentScripts: {
matches: ["*://*.console.cloud.google.com/*"],
css: [
{
file:
"injections/css/bug1568908-console.cloud.google.com-scrollbar-fix.css",
},
],
},
},
{
id: "bug1570119",
platform: "desktop",
domain: "teamcoco.com",
bug: "1570119",
contentScripts: {
matches: ["*://teamcoco.com/*"],
css: [
{
file: "injections/css/bug1570119-teamcoco.com-scrollbar-width.css",
},
],
},
},
{
id: "bug1570328",
platform: "android",
domain: "developer.apple.com",
bug: "1570328",
contentScripts: {
matches: ["*://developer.apple.com/*"],
css: [
{
file:
"injections/css/bug1570328-developer-apple.com-transform-scale.css",
},
],
},
},
{
id: "bug1574973",
platform: "android",
domain: "patch.com",
bug: "1574973",
contentScripts: {
matches: ["*://patch.com/*"],
css: [
{
file: "injections/css/bug1574973-patch.com-dropdown-menu-fix.css",
},
],
},
},
{
id: "bug1575000",
platform: "all",
domain: "apply.lloydsbank.co.uk",
bug: "1575000",
contentScripts: {
matches: ["*://apply.lloydsbank.co.uk/*"],
css: [
{
file:
"injections/css/bug1575000-apply.lloydsbank.co.uk-radio-buttons-fix.css",
},
],
},
},
{
id: "bug1575011",
platform: "android",
domain: "holiday-weather.com",
bug: "1575011",
contentScripts: {
matches: ["*://*.holiday-weather.com/*"],
css: [
{
file:
"injections/css/bug1575011-holiday-weather.com-scrolling-fix.css",
},
],
},
},
{
id: "bug1575017",
platform: "desktop",
domain: "dunkindonuts.com",
bug: "1575017",
contentScripts: {
matches: ["*://*.dunkindonuts.com/en/sign-in*"],
css: [
{
file: "injections/css/bug1575017-dunkindonuts.com-flex-basis.css",
},
],
},
},
{
id: "bug1577270",
platform: "android",
domain: "binance.com",
bug: "1577270",
contentScripts: {
matches: ["*://*.binance.com/*"],
css: [
{
file: "injections/css/bug1577270-binance.com-calc-height-fix.css",
},
],
},
},
{
id: "bug1577297",
platform: "android",
domain: "kitkat.com.au",
bug: "1577297",
contentScripts: {
matches: ["*://*.kitkat.com.au/*"],
css: [
{
file: "injections/css/bug1577297-kitkat.com.au-slider-width-fix.css",
},
],
},
},
];
module.exports = AVAILABLE_INJECTIONS;

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

@ -49,7 +49,7 @@ const AVAILABLE_UA_OVERRIDES = [
blocks: [...getMatchPatternsForGoogleURL("www.google", "serviceworker")],
permanentPref: "enable_enhanced_search",
telemetryKey: "enhancedSearch",
experiment: "enhanced-search-experiment",
experiment: "enhanced-search",
uaTransformer: originalUA => {
return UAHelpers.getDeviceAppropriateChromeUA();
},
@ -79,6 +79,72 @@ const AVAILABLE_UA_OVERRIDES = [
},
},
},
{
/*
* Bug 1577179 - UA override for supportforms.embarcadero.com
* WebCompat issue #34682 - https://webcompat.com/issues/34682
*
* supportforms.embarcadero.com has a constant onchange event on a product selector
* which makes it unusable. Spoofing as Chrome allows to stop event from firing
*/
id: "bug1577179",
platform: "all",
domain: "supportforms.embarcadero.com",
bug: "1577179",
config: {
matches: ["*://supportforms.embarcadero.com/*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
);
},
},
},
{
/*
* Bug 1577519 - att.tv - Create a UA override for att.tv for playback on desktop
* WebCompat issue #3846 - https://webcompat.com/issues/3846
*
* att.tv (atttvnow.com) is blocking Firefox via UA sniffing. Spoofing as Chrome allows
* to access the site and playback works fine. This is former directvnow.com
*/
id: "bug1577519",
platform: "desktop",
domain: "att.tv",
bug: "1577519",
config: {
matches: ["*://*.att.tv/*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
);
},
},
},
{
/*
* Bug 1570108 - steamcommunity.com - UA override for steamcommunity.com
* WebCompat issue #34171 - https://webcompat.com/issues/34171
*
* steamcommunity.com blocks chat feature for Firefox users showing unsupported browser message.
* When spoofing as Chrome the chat works fine
*/
id: "bug1570108",
platform: "desktop",
domain: "steamcommunity.com",
bug: "1570108",
config: {
matches: ["*://steamcommunity.com/chat*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"
);
},
},
},
{
/*
* Bug 1480710 - m.imgur.com - Build UA override
@ -116,7 +182,11 @@ const AVAILABLE_UA_OVERRIDES = [
domain: "tieba.baidu.com",
bug: "945963",
config: {
matches: ["*://tieba.baidu.com/*", "*://tiebac.baidu.com/*"],
matches: [
"*://tieba.baidu.com/*",
"*://tiebac.baidu.com/*",
"*://zhidao.baidu.com/*",
],
uaTransformer: originalUA => {
return originalUA + " AppleWebKit/537.36 (KHTML, like Gecko)";
},
@ -342,6 +412,116 @@ const AVAILABLE_UA_OVERRIDES = [
},
},
},
{
/*
* Bug 1574522 - UA override for enuri.com on Firefox for Android
* WebCompat issue #37139 - https://webcompat.com/issues/37139
*
* enuri.com returns a different template for Firefox on Android
* based on server side UA detection. This results in page content cut offs.
* Spoofing as Chrome fixes the issue
*/
id: "bug1574522",
platform: "android",
domain: "enuri.com",
bug: "1574522",
config: {
matches: ["*://enuri.com/*"],
uaTransformer: _ => {
return "Mozilla/5.0 (Linux; Android 6.0.1; SM-G900M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36";
},
},
},
{
/*
* Bug 1574564 - UA override for ceskatelevize.cz on Firefox for Android
* WebCompat issue #15467 - https://webcompat.com/issues/15467
*
* ceskatelevize sets streamingProtocol depending on the User-Agent it sees
* in the request headers, returning DASH for Chrome, HLS for iOS,
* and Flash for Fennec. Since Fennec has no Flash, the video doesn't work.
* Spoofing as Chrome makes the video play
*/
id: "bug1574564",
platform: "android",
domain: "ceskatelevize.cz",
bug: "1574564",
config: {
matches: ["*://*.ceskatelevize.cz/*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36"
);
},
},
},
{
/*
* Bug 1577240 - UA override for heb.com on Firefox for Android
* WebCompat issue #33613 - https://webcompat.com/issues/33613
*
* heb.com shows desktop site on Firefox for Android for some pages based on
* UA detection. Spoofing as Chrome allows to get mobile site.
*/
id: "bug1577240",
platform: "android",
domain: "heb.com",
bug: "1577240",
config: {
matches: ["*://*.heb.com/*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36"
);
},
},
},
{
/*
* Bug 1577250 - UA override for homebook.pl on Firefox for Android
* WebCompat issue #24044 - https://webcompat.com/issues/24044
*
* homebook.pl shows desktop site on Firefox for Android based on
* UA detection. Spoofing as Chrome allows to get mobile site.
*/
id: "bug1577250",
platform: "android",
domain: "homebook.pl",
bug: "1577250",
config: {
matches: ["*://*.homebook.pl/*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36"
);
},
},
},
{
/*
* Bug 1577267 - UA override for metfone.com.kh on Firefox for Android
* WebCompat issue #16363 - https://webcompat.com/issues/16363
*
* metfone.com.kh has a server side UA detection which returns desktop site
* for Firefox for Android. Spoofing as Chrome allows to receive mobile version
*/
id: "bug1577267",
platform: "android",
domain: "metfone.com.kh",
bug: "1577267",
config: {
matches: ["*://*.metfone.com.kh/*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36"
);
},
},
},
];
const UAHelpers = {

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

@ -7,6 +7,6 @@
* CSS served to Fennec does not permit scrolling horizontally. To prevent
* this UX frustration, we enable horizontal scrolling.
*/
body > #views > div {
body > #views {
overflow: auto;
}

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

@ -0,0 +1,16 @@
/**
* console.cloud.google.com - Double scrollbar visisible on long pages
* Bug #1568908 - https://bugzilla.mozilla.org/show_bug.cgi?id=1568908
* WebCompat issue #33164 - https://webcompat.com/issues/33164
*
* For pages that have contents heigher than the page's height, a secondary
* scrollbar outside the scrollable content area is visible. This is caused
* by a difference in Flexbox behavior, which is being addressed in
* https://bugs.chromium.org/p/chromium/issues/detail?id=981134
*
* Until this fix hits release and Google has updated their UI properly,
* this intervention addresses the differences.
*/
central-page-area {
min-height: 0;
}

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

@ -0,0 +1,11 @@
/**
* teamcoco.com - a scrollbar at the top covering navigation menu
* Bug #1570119 - https://bugzilla.mozilla.org/show_bug.cgi?id=1570119
*
* The scrollbar is covering navigation items making them unusable.
* There are ::-webkit-scrollbar css rules already applied to the scrollbar,
* hiding it in Chrome. Adding the scrollbar-width: none fixes the issue in Firefox.
*/
.css-bdnz85 {
scrollbar-width: none;
}

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

@ -0,0 +1,17 @@
/**
* developer.apple.com - content of the page is shifted to the left
* Bug #1570328 - https://bugzilla.mozilla.org/show_bug.cgi?id=1570328
* WebCompat issue #4070 - https://webcompat.com/issues/4070
*
* The site is relying on zoom property which is not supported by Mozilla,
* see https://bugzilla.mozilla.org/show_bug.cgi?id=390936. Adding a combination
* of transform: scale(1.4), transform-origin and width fixes the issue
*/
@media only screen and (min-device-width: 320px) and (max-device-width: 980px),
(min-device-width: 1024px) and (max-device-width: 1024px) and (min-device-height: 1366px) and (max-device-height: 1366px) and (min-width: 320px) and (max-width: 980px) {
#tocContainer {
transform-origin: 0 0;
transform: scale(1.4);
width: 71.4%;
}
}

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

@ -0,0 +1,13 @@
/**
* patch.com - sub-menu expands at the bottom of the page and overlaps other elements.
* Bug #1574973 - https://bugzilla.mozilla.org/show_bug.cgi?id=1574973
* WebCompat issue #25384 - https://webcompat.com/issues/25384
*
* patch.con has a top:100% style on the relatively-positioned element
* with class="dropdown-menu", and Firefox is incorrectly honoring that
* style (resolving it to something nonzero), whereas Chrome just treats it as "auto"
* see https://bugzilla.mozilla.org/show_bug.cgi?id=1092007
*/
#patch-nav-secondary .dropdown-menu {
top: auto;
}

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

@ -0,0 +1,11 @@
/**
* apply.lloydsbank.co.uk - radio buttons are misplaced
* Bug #1575000 - https://bugzilla.mozilla.org/show_bug.cgi?id=1575000
* WebCompat issue #34969 - https://webcompat.com/issues/34969
*
* Radio buttons are displaced to the left due to positioning issue of ::before
* pseudo element, adding position relative to it's parent fixes the issue.
*/
.radio-content-field .radio.inline label span.text {
position: relative;
}

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

@ -0,0 +1,15 @@
/**
* holiday-weather.com - page is not scrollable
* Bug #1575011 - https://bugzilla.mozilla.org/show_bug.cgi?id=1575011
* WebCompat issue #18478 - https://webcompat.com/issues/18478
*
* the page won't scroll since the flex container is too high,
* adding min height to parent containers fixes the issue
*/
.page-container-style__pageContent {
min-height: 0;
}
.widgets-style__root {
min-height: 0;
}

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

@ -0,0 +1,11 @@
/**
* dunkindonuts.com - form input fields are small and misaligned
* Bug #1575017 - https://bugzilla.mozilla.org/show_bug.cgi?id=1575017
* WebCompat issue #28742 - https://webcompat.com/issues/28742
*
* Form input fields are small and misaligned due to flex-basis: min-content;
* applied on their parent element. Setting it to auto fixes the issue
*/
.grid__item {
flex-basis: auto;
}

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

@ -0,0 +1,12 @@
/**
* binance.com - can't see the full site
* Bug #1577270 - https://bugzilla.mozilla.org/show_bug.cgi?id=1577270
* WebCompat issue #17810 - https://webcompat.com/issues/17810
*
* The site does not have a doctype and is rendered in quirks mode. The calc() percentage
* height is applied on the .main-page .viewWrap element, but its parent does not have
* a specified height property. Adding a height of 100% to the parent fixes the issue.
*/
#tradeDiv {
height: 100%;
}

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

@ -0,0 +1,11 @@
/**
* kitkat.com.au - can't see the content
* Bug #1577297 - https://bugzilla.mozilla.org/show_bug.cgi?id=1577297
* WebCompat issue #28992 - https://webcompat.com/issues/28992
*
* Affected element is too wide due to https://bugzilla.mozilla.org/show_bug.cgi?id=1316534.
* Adding min-width: 0; fixes the issue
*/
.columns .column.main {
min-width: 0;
}

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

@ -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),
});

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

@ -0,0 +1,49 @@
"use strict";
/**
* help.pandora.com - Hide unsupported message in Firefox for Android
* WebCompat issue #38433 - https://webcompat.com/issues/38433
*
* SalesForce Communities are showing unsupported message
* for help.pandora.com and some more sites. See the full list here:
* https://github.com/webcompat/web-bugs/issues?utf8=%E2%9C%93&q=doNotShowUnsupportedBrowserModal
*/
console.info(
"Unsupported message has been hidden for compatibility reasons. See https://webcompat.com/issues/38433 for details."
);
const NOTIFICATIONS_LIMIT = 20;
const createObserver = callback => {
return new MutationObserver(callback).observe(document, {
childList: true,
subtree: true,
});
};
const removeElementWhenReady = elementId => {
const element = document.getElementById(elementId);
if (element) {
element.remove();
return;
}
let n = 0;
createObserver(function(records, observer) {
const _element = document.getElementById(elementId);
if (_element) {
_element.remove();
observer.disconnect();
return;
}
if (n > NOTIFICATIONS_LIMIT) {
observer.disconnect();
}
n++;
});
};
removeElementWhenReady("community-browser-not-support-message");

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

@ -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),
});

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

@ -0,0 +1,77 @@
/* 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 browser, module */
const replaceStringInRequest = (
requestId,
inString,
outString,
inEncoding = "utf-8"
) => {
const filter = browser.webRequest.filterResponseData(requestId);
const decoder = new TextDecoder(inEncoding);
const encoder = new TextEncoder();
const RE = new RegExp(inString, "g");
const carryoverLength = inString.length;
let carryover = "";
filter.ondata = event => {
const replaced = (
carryover + decoder.decode(event.data, { stream: true })
).replace(RE, outString);
filter.write(encoder.encode(replaced.slice(0, -carryoverLength)));
carryover = replaced.slice(-carryoverLength);
};
filter.onstop = event => {
if (carryover.length) {
filter.write(encoder.encode(carryover));
}
filter.close();
};
};
const CUSTOM_FUNCTIONS = {
dtagFix: injection => {
const { urls, contentType } = injection.data;
const listener = (injection.data.listener = e => {
e.responseHeaders.push(contentType);
return { responseHeaders: e.responseHeaders };
});
browser.webRequest.onHeadersReceived.addListener(listener, { urls }, [
"blocking",
"responseHeaders",
]);
},
dtagFixDisable: injection => {
const { listener } = injection.data;
browser.webRequest.onHeadersReceived.removeListener(listener);
delete injection.data.listener;
},
pdk5fix: injection => {
const { urls, types } = injection.data;
const listener = (injection.data.listener = ({ requestId }) => {
replaceStringInRequest(
requestId,
"VideoContextChromeAndroid",
"VideoContextAndroid"
);
return {};
});
browser.webRequest.onBeforeRequest.addListener(listener, { urls, types }, [
"blocking",
]);
},
pdk5fixDisable: injection => {
const { listener } = injection.data;
browser.webRequest.onBeforeRequest.removeListener(listener);
delete injection.data.listener;
},
};
module.exports = CUSTOM_FUNCTIONS;

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

@ -7,13 +7,14 @@
/* globals browser, module */
class Injections {
constructor(availableInjections) {
constructor(availableInjections, customFunctions) {
this.INJECTION_PREF = "perform_injections";
this._injectionsEnabled = true;
this._availableInjections = availableInjections;
this._activeInjections = new Map();
this._customFunctions = customFunctions;
}
bindAboutCompatBroker(broker) {
@ -67,57 +68,45 @@ class Injections {
});
}
replaceStringInRequest(requestId, inString, outString, inEncoding = "utf-8") {
const filter = browser.webRequest.filterResponseData(requestId);
const decoder = new TextDecoder(inEncoding);
const encoder = new TextEncoder();
const RE = new RegExp(inString, "g");
const carryoverLength = inString.length;
let carryover = "";
assignContentScriptDefaults(contentScripts) {
let finalConfig = Object.assign({}, contentScripts);
filter.ondata = event => {
const replaced = (
carryover + decoder.decode(event.data, { stream: true })
).replace(RE, outString);
filter.write(encoder.encode(replaced.slice(0, -carryoverLength)));
carryover = replaced.slice(-carryoverLength);
};
if (!finalConfig.runAt) {
finalConfig.runAt = "document_start";
}
filter.onstop = event => {
if (carryover.length) {
filter.write(encoder.encode(carryover));
}
filter.close();
};
return finalConfig;
}
async enableInjection(injection) {
if (injection.active) {
return;
return undefined;
}
if ("pdk5fix" in injection) {
const { urls, types } = injection.pdk5fix;
const listener = (injection.pdk5fix.listener = ({ requestId }) => {
this.replaceStringInRequest(
requestId,
"VideoContextChromeAndroid",
"VideoContextAndroid"
);
return {};
});
browser.webRequest.onBeforeRequest.addListener(
listener,
{ urls, types },
["blocking"]
);
if (injection.customFunc) {
return this.enableCustomInjection(injection);
}
return this.enableContentScripts(injection);
}
enableCustomInjection(injection) {
if (injection.customFunc in this._customFunctions) {
this._customFunctions[injection.customFunc](injection);
injection.active = true;
return;
} else {
console.error(
`Provided function ${
injection.customFunc
} wasn't found in functions list`
);
}
}
async enableContentScripts(injection) {
try {
const handle = await browser.contentScripts.register(
injection.contentScripts
this.assignContentScriptDefaults(injection.contentScripts)
);
this._activeInjections.set(injection, handle);
injection.active = true;
@ -142,17 +131,30 @@ class Injections {
async disableInjection(injection) {
if (!injection.active) {
return;
return undefined;
}
if (injection.pdk5fix) {
const { listener } = injection.pdk5fix;
browser.webRequest.onBeforeRequest.removeListener(listener);
if (injection.customFunc) {
return this.disableCustomInjections(injection);
}
return this.disableContentScripts(injection);
}
disableCustomInjections(injection) {
const disableFunc = injection.customFunc + "Disable";
if (disableFunc in this._customFunctions) {
this._customFunctions[disableFunc](injection);
injection.active = false;
delete injection.pdk5fix.listener;
return;
} else {
console.error(
`Provided function ${disableFunc} for disabling injection wasn't found in functions list`
);
}
}
async disableContentScripts(injection) {
const contentScript = this._activeInjections.get(injection);
await contentScript.unregister();
this._activeInjections.delete(injection);

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

@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Web Compat",
"description": "Urgent post-release fixes for web compatibility.",
"version": "6.0.3",
"version": "6.1.0",
"applications": {
"gecko": {
@ -61,6 +61,7 @@
"data/injections.js",
"data/ua_overrides.js",
"lib/about_compat_broker.js",
"lib/custom_functions.js",
"lib/injections.js",
"lib/ua_overrides.js",
"run.js"

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

@ -46,6 +46,15 @@ FINAL_TARGET_FILES.features['webcompat@mozilla.org']['injections']['css'] += [
'injections/css/bug1561371-mail.google.com-allow-horizontal-scrolling.css',
'injections/css/bug1567610-dns.google.com-moz-fit-content.css',
'injections/css/bug1568256-zertifikate.commerzbank.de-flex.css',
'injections/css/bug1568908-console.cloud.google.com-scrollbar-fix.css',
'injections/css/bug1570119-teamcoco.com-scrollbar-width.css',
'injections/css/bug1570328-developer-apple.com-transform-scale.css',
'injections/css/bug1574973-patch.com-dropdown-menu-fix.css',
'injections/css/bug1575000-apply.lloydsbank.co.uk-radio-buttons-fix.css',
'injections/css/bug1575011-holiday-weather.com-scrolling-fix.css',
'injections/css/bug1575017-dunkindonuts.com-flex-basis.css',
'injections/css/bug1577270-binance.com-calc-height-fix.css',
'injections/css/bug1577297-kitkat.com.au-slider-width-fix.css'
]
FINAL_TARGET_FILES.features['webcompat@mozilla.org']['injections']['js'] += [
@ -55,10 +64,14 @@ FINAL_TARGET_FILES.features['webcompat@mozilla.org']['injections']['js'] += [
'injections/js/bug1472075-bankofamerica.com-ua-change.js',
'injections/js/bug1472081-election.gov.np-window.sidebar-shim.js',
'injections/js/bug1482066-portalminasnet.com-window.sidebar-shim.js',
'injections/js/bug1570856-medium.com-menu-isTier1.js',
'injections/js/bug1577245-salesforce-communities-hide-unsupported.js',
'injections/js/bug1579159-m.tailieu.vn-pdfjs-worker-disable.js'
]
FINAL_TARGET_FILES.features['webcompat@mozilla.org']['lib'] += [
'lib/about_compat_broker.js',
'lib/custom_functions.js',
'lib/google.js',
'lib/injections.js',
'lib/module_shim.js',

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

@ -5,9 +5,9 @@
"use strict";
/* globals AVAILABLE_INJECTIONS, AVAILABLE_UA_OVERRIDES, AboutCompatBroker,
Injections, UAOverrides */
Injections, UAOverrides, CUSTOM_FUNCTIONS */
const injections = new Injections(AVAILABLE_INJECTIONS);
const injections = new Injections(AVAILABLE_INJECTIONS, CUSTOM_FUNCTIONS);
const uaOverrides = new UAOverrides(AVAILABLE_UA_OVERRIDES);
const aboutCompatBroker = new AboutCompatBroker({

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

@ -31,7 +31,6 @@ const AVAILABLE_INJECTIONS = [
file: "injections/js/bug0000000-testbed-js-injection.js",
},
],
runAt: "document_start",
},
},
{
@ -47,7 +46,6 @@ const AVAILABLE_INJECTIONS = [
"injections/js/bug1452707-window.controllers-shim-ib.absa.co.za.js",
},
],
runAt: "document_start",
},
},
{
@ -62,7 +60,6 @@ const AVAILABLE_INJECTIONS = [
file: "injections/js/bug1457335-histography.io-ua-change.js",
},
],
runAt: "document_start",
},
},
{
@ -77,7 +74,6 @@ const AVAILABLE_INJECTIONS = [
file: "injections/js/bug1472075-bankofamerica.com-ua-change.js",
},
],
runAt: "document_start",
},
},
{
@ -87,14 +83,13 @@ const AVAILABLE_INJECTIONS = [
bug: "1472081",
contentScripts: {
matches: ["http://202.166.205.141/bbvrs/*"],
allFrames: true,
js: [
{
file:
"injections/js/bug1472081-election.gov.np-window.sidebar-shim.js",
},
],
runAt: "document_start",
allFrames: true,
},
},
{
@ -104,16 +99,68 @@ const AVAILABLE_INJECTIONS = [
bug: "1482066",
contentScripts: {
matches: ["*://portalminasnet.com/*"],
allFrames: true,
js: [
{
file:
"injections/js/bug1482066-portalminasnet.com-window.sidebar-shim.js",
},
],
runAt: "document_start",
},
},
{
id: "bug1570856",
platform: "android",
domain: "medium.com",
bug: "1570856",
contentScripts: {
matches: ["*://medium.com/*"],
js: [
{
file: "injections/js/bug1570856-medium.com-menu-isTier1.js",
},
],
allFrames: true,
},
},
{
id: "bug1579159",
platform: "android",
domain: "m.tailieu.vn",
bug: "1579159",
contentScripts: {
matches: ["*://m.tailieu.vn/*", "*://m.elib.vn/*"],
js: [
{
file: "injections/js/bug1579159-m.tailieu.vn-pdfjs-worker-disable.js",
},
],
allFrames: true,
},
},
{
id: "bug1577245",
platform: "android",
domain: "help.pandora.com",
bug: "1577245",
contentScripts: {
matches: [
"https://faq.usps.com/*",
"https://help.duo.com/*",
"https://help.hulu.com/*",
"https://help.pandora.com/*",
"https://my211.force.com/*",
"https://support.paypay.ne.jp/*",
"https://usps.force.com/*",
],
js: [
{
file:
"injections/js/bug1577245-salesforce-communities-hide-unsupported.js",
},
],
},
},
{
id: "bug1526977",
platform: "desktop",
@ -147,10 +194,25 @@ const AVAILABLE_INJECTIONS = [
platform: "android",
domain: "Sites using PDK 5 video",
bug: "1551672",
pdk5fix: {
data: {
urls: ["https://*/*/tpPdk.js", "https://*/*/pdk/js/*/*.js"],
types: ["script"],
},
customFunc: "pdk5fix",
},
{
id: "bug1577870",
platform: "desktop",
domain: "slideshare.net",
bug: "1577870",
data: {
urls: ["https://*.linkedin.com/tscp-serving/dtag*"],
contentType: {
name: "content-type",
value: "text/html; charset=utf-8",
},
},
customFunc: "dtagFix",
},
{
id: "bug1305028",
@ -217,7 +279,7 @@ const AVAILABLE_INJECTIONS = [
domain: "dns.google.com",
bug: "1567610",
contentScripts: {
matches: ["*://dns.google.com/*"],
matches: ["*://dns.google.com/*", "*://dns.google/*"],
css: [
{
file: "injections/css/bug1567610-dns.google.com-moz-fit-content.css",
@ -239,6 +301,136 @@ const AVAILABLE_INJECTIONS = [
],
},
},
{
id: "bug1568908",
platform: "desktop",
domain: "console.cloud.google.com",
bug: "1568908",
contentScripts: {
matches: ["*://*.console.cloud.google.com/*"],
css: [
{
file:
"injections/css/bug1568908-console.cloud.google.com-scrollbar-fix.css",
},
],
},
},
{
id: "bug1570119",
platform: "desktop",
domain: "teamcoco.com",
bug: "1570119",
contentScripts: {
matches: ["*://teamcoco.com/*"],
css: [
{
file: "injections/css/bug1570119-teamcoco.com-scrollbar-width.css",
},
],
},
},
{
id: "bug1570328",
platform: "android",
domain: "developer.apple.com",
bug: "1570328",
contentScripts: {
matches: ["*://developer.apple.com/*"],
css: [
{
file:
"injections/css/bug1570328-developer-apple.com-transform-scale.css",
},
],
},
},
{
id: "bug1574973",
platform: "android",
domain: "patch.com",
bug: "1574973",
contentScripts: {
matches: ["*://patch.com/*"],
css: [
{
file: "injections/css/bug1574973-patch.com-dropdown-menu-fix.css",
},
],
},
},
{
id: "bug1575000",
platform: "all",
domain: "apply.lloydsbank.co.uk",
bug: "1575000",
contentScripts: {
matches: ["*://apply.lloydsbank.co.uk/*"],
css: [
{
file:
"injections/css/bug1575000-apply.lloydsbank.co.uk-radio-buttons-fix.css",
},
],
},
},
{
id: "bug1575011",
platform: "android",
domain: "holiday-weather.com",
bug: "1575011",
contentScripts: {
matches: ["*://*.holiday-weather.com/*"],
css: [
{
file:
"injections/css/bug1575011-holiday-weather.com-scrolling-fix.css",
},
],
},
},
{
id: "bug1575017",
platform: "desktop",
domain: "dunkindonuts.com",
bug: "1575017",
contentScripts: {
matches: ["*://*.dunkindonuts.com/en/sign-in*"],
css: [
{
file: "injections/css/bug1575017-dunkindonuts.com-flex-basis.css",
},
],
},
},
{
id: "bug1577270",
platform: "android",
domain: "binance.com",
bug: "1577270",
contentScripts: {
matches: ["*://*.binance.com/*"],
css: [
{
file: "injections/css/bug1577270-binance.com-calc-height-fix.css",
},
],
},
},
{
id: "bug1577297",
platform: "android",
domain: "kitkat.com.au",
bug: "1577297",
contentScripts: {
matches: ["*://*.kitkat.com.au/*"],
css: [
{
file: "injections/css/bug1577297-kitkat.com.au-slider-width-fix.css",
},
],
},
},
];
module.exports = AVAILABLE_INJECTIONS;

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

@ -49,7 +49,7 @@ const AVAILABLE_UA_OVERRIDES = [
blocks: [...getMatchPatternsForGoogleURL("www.google", "serviceworker")],
permanentPref: "enable_enhanced_search",
telemetryKey: "enhancedSearch",
experiment: "enhanced-search-experiment",
experiment: "enhanced-search",
uaTransformer: originalUA => {
return UAHelpers.getDeviceAppropriateChromeUA();
},
@ -79,6 +79,72 @@ const AVAILABLE_UA_OVERRIDES = [
},
},
},
{
/*
* Bug 1577179 - UA override for supportforms.embarcadero.com
* WebCompat issue #34682 - https://webcompat.com/issues/34682
*
* supportforms.embarcadero.com has a constant onchange event on a product selector
* which makes it unusable. Spoofing as Chrome allows to stop event from firing
*/
id: "bug1577179",
platform: "all",
domain: "supportforms.embarcadero.com",
bug: "1577179",
config: {
matches: ["*://supportforms.embarcadero.com/*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
);
},
},
},
{
/*
* Bug 1577519 - att.tv - Create a UA override for att.tv for playback on desktop
* WebCompat issue #3846 - https://webcompat.com/issues/3846
*
* att.tv (atttvnow.com) is blocking Firefox via UA sniffing. Spoofing as Chrome allows
* to access the site and playback works fine. This is former directvnow.com
*/
id: "bug1577519",
platform: "desktop",
domain: "att.tv",
bug: "1577519",
config: {
matches: ["*://*.att.tv/*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36"
);
},
},
},
{
/*
* Bug 1570108 - steamcommunity.com - UA override for steamcommunity.com
* WebCompat issue #34171 - https://webcompat.com/issues/34171
*
* steamcommunity.com blocks chat feature for Firefox users showing unsupported browser message.
* When spoofing as Chrome the chat works fine
*/
id: "bug1570108",
platform: "desktop",
domain: "steamcommunity.com",
bug: "1570108",
config: {
matches: ["*://steamcommunity.com/chat*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36"
);
},
},
},
{
/*
* Bug 1480710 - m.imgur.com - Build UA override
@ -116,7 +182,11 @@ const AVAILABLE_UA_OVERRIDES = [
domain: "tieba.baidu.com",
bug: "945963",
config: {
matches: ["*://tieba.baidu.com/*", "*://tiebac.baidu.com/*"],
matches: [
"*://tieba.baidu.com/*",
"*://tiebac.baidu.com/*",
"*://zhidao.baidu.com/*",
],
uaTransformer: originalUA => {
return originalUA + " AppleWebKit/537.36 (KHTML, like Gecko)";
},
@ -342,6 +412,116 @@ const AVAILABLE_UA_OVERRIDES = [
},
},
},
{
/*
* Bug 1574522 - UA override for enuri.com on Firefox for Android
* WebCompat issue #37139 - https://webcompat.com/issues/37139
*
* enuri.com returns a different template for Firefox on Android
* based on server side UA detection. This results in page content cut offs.
* Spoofing as Chrome fixes the issue
*/
id: "bug1574522",
platform: "android",
domain: "enuri.com",
bug: "1574522",
config: {
matches: ["*://enuri.com/*"],
uaTransformer: _ => {
return "Mozilla/5.0 (Linux; Android 6.0.1; SM-G900M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36";
},
},
},
{
/*
* Bug 1574564 - UA override for ceskatelevize.cz on Firefox for Android
* WebCompat issue #15467 - https://webcompat.com/issues/15467
*
* ceskatelevize sets streamingProtocol depending on the User-Agent it sees
* in the request headers, returning DASH for Chrome, HLS for iOS,
* and Flash for Fennec. Since Fennec has no Flash, the video doesn't work.
* Spoofing as Chrome makes the video play
*/
id: "bug1574564",
platform: "android",
domain: "ceskatelevize.cz",
bug: "1574564",
config: {
matches: ["*://*.ceskatelevize.cz/*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36"
);
},
},
},
{
/*
* Bug 1577240 - UA override for heb.com on Firefox for Android
* WebCompat issue #33613 - https://webcompat.com/issues/33613
*
* heb.com shows desktop site on Firefox for Android for some pages based on
* UA detection. Spoofing as Chrome allows to get mobile site.
*/
id: "bug1577240",
platform: "android",
domain: "heb.com",
bug: "1577240",
config: {
matches: ["*://*.heb.com/*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36"
);
},
},
},
{
/*
* Bug 1577250 - UA override for homebook.pl on Firefox for Android
* WebCompat issue #24044 - https://webcompat.com/issues/24044
*
* homebook.pl shows desktop site on Firefox for Android based on
* UA detection. Spoofing as Chrome allows to get mobile site.
*/
id: "bug1577250",
platform: "android",
domain: "homebook.pl",
bug: "1577250",
config: {
matches: ["*://*.homebook.pl/*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36"
);
},
},
},
{
/*
* Bug 1577267 - UA override for metfone.com.kh on Firefox for Android
* WebCompat issue #16363 - https://webcompat.com/issues/16363
*
* metfone.com.kh has a server side UA detection which returns desktop site
* for Firefox for Android. Spoofing as Chrome allows to receive mobile version
*/
id: "bug1577267",
platform: "android",
domain: "metfone.com.kh",
bug: "1577267",
config: {
matches: ["*://*.metfone.com.kh/*"],
uaTransformer: originalUA => {
return (
UAHelpers.getPrefix(originalUA) +
" AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.111 Mobile Safari/537.36"
);
},
},
},
];
const UAHelpers = {

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

@ -7,6 +7,6 @@
* CSS served to Fennec does not permit scrolling horizontally. To prevent
* this UX frustration, we enable horizontal scrolling.
*/
body > #views > div {
body > #views {
overflow: auto;
}

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

@ -0,0 +1,16 @@
/**
* console.cloud.google.com - Double scrollbar visisible on long pages
* Bug #1568908 - https://bugzilla.mozilla.org/show_bug.cgi?id=1568908
* WebCompat issue #33164 - https://webcompat.com/issues/33164
*
* For pages that have contents heigher than the page's height, a secondary
* scrollbar outside the scrollable content area is visible. This is caused
* by a difference in Flexbox behavior, which is being addressed in
* https://bugs.chromium.org/p/chromium/issues/detail?id=981134
*
* Until this fix hits release and Google has updated their UI properly,
* this intervention addresses the differences.
*/
central-page-area {
min-height: 0;
}

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

@ -0,0 +1,11 @@
/**
* teamcoco.com - a scrollbar at the top covering navigation menu
* Bug #1570119 - https://bugzilla.mozilla.org/show_bug.cgi?id=1570119
*
* The scrollbar is covering navigation items making them unusable.
* There are ::-webkit-scrollbar css rules already applied to the scrollbar,
* hiding it in Chrome. Adding the scrollbar-width: none fixes the issue in Firefox.
*/
.css-bdnz85 {
scrollbar-width: none;
}

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

@ -0,0 +1,17 @@
/**
* developer.apple.com - content of the page is shifted to the left
* Bug #1570328 - https://bugzilla.mozilla.org/show_bug.cgi?id=1570328
* WebCompat issue #4070 - https://webcompat.com/issues/4070
*
* The site is relying on zoom property which is not supported by Mozilla,
* see https://bugzilla.mozilla.org/show_bug.cgi?id=390936. Adding a combination
* of transform: scale(1.4), transform-origin and width fixes the issue
*/
@media only screen and (min-device-width: 320px) and (max-device-width: 980px),
(min-device-width: 1024px) and (max-device-width: 1024px) and (min-device-height: 1366px) and (max-device-height: 1366px) and (min-width: 320px) and (max-width: 980px) {
#tocContainer {
transform-origin: 0 0;
transform: scale(1.4);
width: 71.4%;
}
}

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

@ -0,0 +1,13 @@
/**
* patch.com - sub-menu expands at the bottom of the page and overlaps other elements.
* Bug #1574973 - https://bugzilla.mozilla.org/show_bug.cgi?id=1574973
* WebCompat issue #25384 - https://webcompat.com/issues/25384
*
* patch.con has a top:100% style on the relatively-positioned element
* with class="dropdown-menu", and Firefox is incorrectly honoring that
* style (resolving it to something nonzero), whereas Chrome just treats it as "auto"
* see https://bugzilla.mozilla.org/show_bug.cgi?id=1092007
*/
#patch-nav-secondary .dropdown-menu {
top: auto;
}

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

@ -0,0 +1,11 @@
/**
* apply.lloydsbank.co.uk - radio buttons are misplaced
* Bug #1575000 - https://bugzilla.mozilla.org/show_bug.cgi?id=1575000
* WebCompat issue #34969 - https://webcompat.com/issues/34969
*
* Radio buttons are displaced to the left due to positioning issue of ::before
* pseudo element, adding position relative to it's parent fixes the issue.
*/
.radio-content-field .radio.inline label span.text {
position: relative;
}

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

@ -0,0 +1,15 @@
/**
* holiday-weather.com - page is not scrollable
* Bug #1575011 - https://bugzilla.mozilla.org/show_bug.cgi?id=1575011
* WebCompat issue #18478 - https://webcompat.com/issues/18478
*
* the page won't scroll since the flex container is too high,
* adding min height to parent containers fixes the issue
*/
.page-container-style__pageContent {
min-height: 0;
}
.widgets-style__root {
min-height: 0;
}

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

@ -0,0 +1,11 @@
/**
* dunkindonuts.com - form input fields are small and misaligned
* Bug #1575017 - https://bugzilla.mozilla.org/show_bug.cgi?id=1575017
* WebCompat issue #28742 - https://webcompat.com/issues/28742
*
* Form input fields are small and misaligned due to flex-basis: min-content;
* applied on their parent element. Setting it to auto fixes the issue
*/
.grid__item {
flex-basis: auto;
}

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

@ -0,0 +1,12 @@
/**
* binance.com - can't see the full site
* Bug #1577270 - https://bugzilla.mozilla.org/show_bug.cgi?id=1577270
* WebCompat issue #17810 - https://webcompat.com/issues/17810
*
* The site does not have a doctype and is rendered in quirks mode. The calc() percentage
* height is applied on the .main-page .viewWrap element, but its parent does not have
* a specified height property. Adding a height of 100% to the parent fixes the issue.
*/
#tradeDiv {
height: 100%;
}

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

@ -0,0 +1,11 @@
/**
* kitkat.com.au - can't see the content
* Bug #1577297 - https://bugzilla.mozilla.org/show_bug.cgi?id=1577297
* WebCompat issue #28992 - https://webcompat.com/issues/28992
*
* Affected element is too wide due to https://bugzilla.mozilla.org/show_bug.cgi?id=1316534.
* Adding min-width: 0; fixes the issue
*/
.columns .column.main {
min-width: 0;
}

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

@ -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),
});

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

@ -0,0 +1,49 @@
"use strict";
/**
* help.pandora.com - Hide unsupported message in Firefox for Android
* WebCompat issue #38433 - https://webcompat.com/issues/38433
*
* SalesForce Communities are showing unsupported message
* for help.pandora.com and some more sites. See the full list here:
* https://github.com/webcompat/web-bugs/issues?utf8=%E2%9C%93&q=doNotShowUnsupportedBrowserModal
*/
console.info(
"Unsupported message has been hidden for compatibility reasons. See https://webcompat.com/issues/38433 for details."
);
const NOTIFICATIONS_LIMIT = 20;
const createObserver = callback => {
return new MutationObserver(callback).observe(document, {
childList: true,
subtree: true,
});
};
const removeElementWhenReady = elementId => {
const element = document.getElementById(elementId);
if (element) {
element.remove();
return;
}
let n = 0;
createObserver(function(records, observer) {
const _element = document.getElementById(elementId);
if (_element) {
_element.remove();
observer.disconnect();
return;
}
if (n > NOTIFICATIONS_LIMIT) {
observer.disconnect();
}
n++;
});
};
removeElementWhenReady("community-browser-not-support-message");

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

@ -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),
});

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

@ -0,0 +1,77 @@
/* 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 browser, module */
const replaceStringInRequest = (
requestId,
inString,
outString,
inEncoding = "utf-8"
) => {
const filter = browser.webRequest.filterResponseData(requestId);
const decoder = new TextDecoder(inEncoding);
const encoder = new TextEncoder();
const RE = new RegExp(inString, "g");
const carryoverLength = inString.length;
let carryover = "";
filter.ondata = event => {
const replaced = (
carryover + decoder.decode(event.data, { stream: true })
).replace(RE, outString);
filter.write(encoder.encode(replaced.slice(0, -carryoverLength)));
carryover = replaced.slice(-carryoverLength);
};
filter.onstop = event => {
if (carryover.length) {
filter.write(encoder.encode(carryover));
}
filter.close();
};
};
const CUSTOM_FUNCTIONS = {
dtagFix: injection => {
const { urls, contentType } = injection.data;
const listener = (injection.data.listener = e => {
e.responseHeaders.push(contentType);
return { responseHeaders: e.responseHeaders };
});
browser.webRequest.onHeadersReceived.addListener(listener, { urls }, [
"blocking",
"responseHeaders",
]);
},
dtagFixDisable: injection => {
const { listener } = injection.data;
browser.webRequest.onHeadersReceived.removeListener(listener);
delete injection.data.listener;
},
pdk5fix: injection => {
const { urls, types } = injection.data;
const listener = (injection.data.listener = ({ requestId }) => {
replaceStringInRequest(
requestId,
"VideoContextChromeAndroid",
"VideoContextAndroid"
);
return {};
});
browser.webRequest.onBeforeRequest.addListener(listener, { urls, types }, [
"blocking",
]);
},
pdk5fixDisable: injection => {
const { listener } = injection.data;
browser.webRequest.onBeforeRequest.removeListener(listener);
delete injection.data.listener;
},
};
module.exports = CUSTOM_FUNCTIONS;

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

@ -7,13 +7,14 @@
/* globals browser, module */
class Injections {
constructor(availableInjections) {
constructor(availableInjections, customFunctions) {
this.INJECTION_PREF = "perform_injections";
this._injectionsEnabled = true;
this._availableInjections = availableInjections;
this._activeInjections = new Map();
this._customFunctions = customFunctions;
}
bindAboutCompatBroker(broker) {
@ -67,57 +68,45 @@ class Injections {
});
}
replaceStringInRequest(requestId, inString, outString, inEncoding = "utf-8") {
const filter = browser.webRequest.filterResponseData(requestId);
const decoder = new TextDecoder(inEncoding);
const encoder = new TextEncoder();
const RE = new RegExp(inString, "g");
const carryoverLength = inString.length;
let carryover = "";
assignContentScriptDefaults(contentScripts) {
let finalConfig = Object.assign({}, contentScripts);
filter.ondata = event => {
const replaced = (
carryover + decoder.decode(event.data, { stream: true })
).replace(RE, outString);
filter.write(encoder.encode(replaced.slice(0, -carryoverLength)));
carryover = replaced.slice(-carryoverLength);
};
if (!finalConfig.runAt) {
finalConfig.runAt = "document_start";
}
filter.onstop = event => {
if (carryover.length) {
filter.write(encoder.encode(carryover));
}
filter.close();
};
return finalConfig;
}
async enableInjection(injection) {
if (injection.active) {
return;
return undefined;
}
if ("pdk5fix" in injection) {
const { urls, types } = injection.pdk5fix;
const listener = (injection.pdk5fix.listener = ({ requestId }) => {
this.replaceStringInRequest(
requestId,
"VideoContextChromeAndroid",
"VideoContextAndroid"
);
return {};
});
browser.webRequest.onBeforeRequest.addListener(
listener,
{ urls, types },
["blocking"]
);
if (injection.customFunc) {
return this.enableCustomInjection(injection);
}
return this.enableContentScripts(injection);
}
enableCustomInjection(injection) {
if (injection.customFunc in this._customFunctions) {
this._customFunctions[injection.customFunc](injection);
injection.active = true;
return;
} else {
console.error(
`Provided function ${
injection.customFunc
} wasn't found in functions list`
);
}
}
async enableContentScripts(injection) {
try {
const handle = await browser.contentScripts.register(
injection.contentScripts
this.assignContentScriptDefaults(injection.contentScripts)
);
this._activeInjections.set(injection, handle);
injection.active = true;
@ -142,17 +131,30 @@ class Injections {
async disableInjection(injection) {
if (!injection.active) {
return;
return undefined;
}
if (injection.pdk5fix) {
const { listener } = injection.pdk5fix;
browser.webRequest.onBeforeRequest.removeListener(listener);
if (injection.customFunc) {
return this.disableCustomInjections(injection);
}
return this.disableContentScripts(injection);
}
disableCustomInjections(injection) {
const disableFunc = injection.customFunc + "Disable";
if (disableFunc in this._customFunctions) {
this._customFunctions[disableFunc](injection);
injection.active = false;
delete injection.pdk5fix.listener;
return;
} else {
console.error(
`Provided function ${disableFunc} for disabling injection wasn't found in functions list`
);
}
}
async disableContentScripts(injection) {
const contentScript = this._activeInjections.get(injection);
await contentScript.unregister();
this._activeInjections.delete(injection);

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

@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Web Compat",
"description": "Urgent post-release fixes for web compatibility.",
"version": "6.0.3",
"version": "6.1.0",
"applications": {
"gecko": {
@ -61,6 +61,7 @@
"data/injections.js",
"data/ua_overrides.js",
"lib/about_compat_broker.js",
"lib/custom_functions.js",
"lib/injections.js",
"lib/ua_overrides.js",
"run.js"

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

@ -46,6 +46,15 @@ FINAL_TARGET_FILES.features['webcompat@mozilla.org']['injections']['css'] += [
'injections/css/bug1561371-mail.google.com-allow-horizontal-scrolling.css',
'injections/css/bug1567610-dns.google.com-moz-fit-content.css',
'injections/css/bug1568256-zertifikate.commerzbank.de-flex.css',
'injections/css/bug1568908-console.cloud.google.com-scrollbar-fix.css',
'injections/css/bug1570119-teamcoco.com-scrollbar-width.css',
'injections/css/bug1570328-developer-apple.com-transform-scale.css',
'injections/css/bug1574973-patch.com-dropdown-menu-fix.css',
'injections/css/bug1575000-apply.lloydsbank.co.uk-radio-buttons-fix.css',
'injections/css/bug1575011-holiday-weather.com-scrolling-fix.css',
'injections/css/bug1575017-dunkindonuts.com-flex-basis.css',
'injections/css/bug1577270-binance.com-calc-height-fix.css',
'injections/css/bug1577297-kitkat.com.au-slider-width-fix.css'
]
FINAL_TARGET_FILES.features['webcompat@mozilla.org']['injections']['js'] += [
@ -55,10 +64,14 @@ FINAL_TARGET_FILES.features['webcompat@mozilla.org']['injections']['js'] += [
'injections/js/bug1472075-bankofamerica.com-ua-change.js',
'injections/js/bug1472081-election.gov.np-window.sidebar-shim.js',
'injections/js/bug1482066-portalminasnet.com-window.sidebar-shim.js',
'injections/js/bug1570856-medium.com-menu-isTier1.js',
'injections/js/bug1577245-salesforce-communities-hide-unsupported.js',
'injections/js/bug1579159-m.tailieu.vn-pdfjs-worker-disable.js'
]
FINAL_TARGET_FILES.features['webcompat@mozilla.org']['lib'] += [
'lib/about_compat_broker.js',
'lib/custom_functions.js',
'lib/google.js',
'lib/injections.js',
'lib/module_shim.js',

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

@ -5,9 +5,9 @@
"use strict";
/* globals AVAILABLE_INJECTIONS, AVAILABLE_UA_OVERRIDES, AboutCompatBroker,
Injections, UAOverrides */
Injections, UAOverrides, CUSTOM_FUNCTIONS */
const injections = new Injections(AVAILABLE_INJECTIONS);
const injections = new Injections(AVAILABLE_INJECTIONS, CUSTOM_FUNCTIONS);
const uaOverrides = new UAOverrides(AVAILABLE_UA_OVERRIDES);
const aboutCompatBroker = new AboutCompatBroker({