From 614dce0e8c8adeb4b4b76f8812566f7a0feaf4da Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 8 Mar 2022 23:38:51 +0300 Subject: [PATCH] transition patch is redundant in Chrome 93+ --- content/style-injector.js | 2 +- global.css | 7 +++++-- js/dom-on-load.js | 14 ++++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/content/style-injector.js b/content/style-injector.js index ceeb1c60..d870ae63 100644 --- a/content/style-injector.js +++ b/content/style-injector.js @@ -15,7 +15,7 @@ window.StyleInjector = window.INJECTED === 1 ? window.StyleInjector : ({ const list = []; const table = new Map(); let isEnabled = true; - let isTransitionPatched; + let isTransitionPatched = chrome.app && CSS.supports('accent-color', 'red'); // Chrome 93 let exposeStyleName; // will store the original method refs because the page can override them let creationDoc, createElement, createElementNS; diff --git a/global.css b/global.css index 785afdcd..6f782515 100644 --- a/global.css +++ b/global.css @@ -1,8 +1,11 @@ -html#stylus #header *:not(#\1transition-suppressor) { +@supports not (accent-color: red) { /* This suppresses a bug in all? browsers: they apply transitions during page load. + * It was fixed by crrev.com/886802 in Chrome 93, which we detect via `accent-color`. * Using an increased specificity to override sane selectors in user styles. * Using \1 to simplify js code because \0 is converted to \xFFFD per spec. */ - transition: none !important; + html#stylus #header *:not(#\1transition-suppressor) { + transition: none !important; + } } :root { --family: Arial, "Helvetica Neue", Helvetica, system-ui, sans-serif; diff --git a/js/dom-on-load.js b/js/dom-on-load.js index 213fcb02..8358ca38 100644 --- a/js/dom-on-load.js +++ b/js/dom-on-load.js @@ -1,5 +1,5 @@ /* global $$ $ $create focusAccessibility getEventKeyName moveFocus */// dom.js -/* global clamp debounce */// toolbox.js +/* global CHROME clamp debounce */// toolbox.js /* global msg */ /* global t */// localization.js 'use strict'; @@ -24,11 +24,13 @@ } }); // Removing transition-suppressor rule - const {sheet} = $('link[href$="global.css"]'); - for (let i = 0, rule; (rule = sheet.cssRules[i]); i++) { - if (/#\\1\s?transition-suppressor/.test(rule.selectorText)) { - sheet.deleteRule(i); - break; + if (!CHROME || CHROME < 93) { + const {sheet} = $('link[href$="global.css"]'); + for (let i = 0, rule; (rule = sheet.cssRules[i]); i++) { + if (/#\\1\s?transition-suppressor/.test(rule.cssText)) { + sheet.deleteRule(i); + break; + } } }