From 36d790e0c2b3b857a03d17e780bd829ba43ea670 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 3 Sep 2017 23:52:06 +0300 Subject: [PATCH] improve CSS transition suppression on own pages in FF --- background/background.js | 2 +- background/storage.js | 4 ++-- edit.html | 11 +++++++++++ js/dom.js | 6 ++++-- manage.html | 10 ++++++++++ options.html | 11 +++++++++++ popup.html | 10 ++++++++++ 7 files changed, 49 insertions(+), 5 deletions(-) diff --git a/background/background.js b/background/background.js index 398265e6..6ab3711a 100644 --- a/background/background.js +++ b/background/background.js @@ -196,7 +196,7 @@ function webNavigationListener(method, {url, tabId, frameId}) { getStyles({matchUrl: url, enabled: true, asHash: true}).then(styles => { if (method && URLS.supported(url) && tabId >= 0) { if (method === 'styleApply') { - handleCssTransitionBug(tabId, frameId, styles); + handleCssTransitionBug({tabId, frameId, url, styles}); } chrome.tabs.sendMessage(tabId, { method, diff --git a/background/storage.js b/background/storage.js index c71cc007..c3d30b4a 100644 --- a/background/storage.js +++ b/background/storage.js @@ -726,7 +726,7 @@ function calcStyleDigest(style) { } -function handleCssTransitionBug(tabId, frameId, styles) { +function handleCssTransitionBug({tabId, frameId, url, styles}) { for (let id in styles) { id |= 0; if (!id) { @@ -743,7 +743,7 @@ function handleCssTransitionBug(tabId, frameId, styles) { continue; } } - if (FIREFOX) { + if (FIREFOX && !url.startsWith(URLS.ownOrigin)) { patchFirefox(); } else { styles.needTransitionPatch = true; diff --git a/edit.html b/edit.html index 52a7d86e..bc1527f6 100644 --- a/edit.html +++ b/edit.html @@ -2,6 +2,17 @@ + + diff --git a/js/dom.js b/js/dom.js index ed21d634..249de722 100644 --- a/js/dom.js +++ b/js/dom.js @@ -36,9 +36,10 @@ for (const type of [NodeList, NamedNodeMap, HTMLCollection, HTMLAllCollection]) window.addEventListener('resize', () => debounce(addTooltipsToEllipsized, 100)); } -// add favicon in Firefox -// eslint-disable-next-line no-unused-expressions +onDOMready().then(() => $('#firefox-transitions-bug-suppressor').remove()); + if (navigator.userAgent.includes('Firefox')) { + // die if unable to access BG directly chrome.windows.getCurrent(wnd => { if (!BG && wnd.incognito) { // private windows can't get bg page @@ -46,6 +47,7 @@ if (navigator.userAgent.includes('Firefox')) { throw 0; } }); + // add favicon in Firefox setTimeout(() => { if (!window.prefs) { return; diff --git a/manage.html b/manage.html index bd6f73d8..529dd305 100644 --- a/manage.html +++ b/manage.html @@ -8,6 +8,16 @@ + +