darkreader 4.9.51 → 4.9.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/darkreader.js +215 -179
  3. package/package.json +39 -39
package/README.md CHANGED
@@ -16,7 +16,7 @@ If the help page doesn't answer your question, open up a new [discussion](https:
16
16
 
17
17
  ## How to contribute
18
18
 
19
- Read more about contributing to Dark Reader in [CONTRIBUTING.md](https://github.com/darkreader/darkreader/blob/master/CONTRIBUTING.md).
19
+ Read more about contributing to Dark Reader in [CONTRIBUTING.md](https://github.com/darkreader/darkreader/blob/main/CONTRIBUTING.md).
20
20
 
21
21
  ## Building for use
22
22
 
package/darkreader.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Dark Reader v4.9.51
2
+ * Dark Reader v4.9.55
3
3
  * https://darkreader.org/
4
4
  */
5
5
 
@@ -9,7 +9,7 @@
9
9
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.DarkReader = {}));
10
10
  })(this, (function (exports) { 'use strict';
11
11
 
12
- /*! *****************************************************************************
12
+ /******************************************************************************
13
13
  Copyright (c) Microsoft Corporation.
14
14
 
15
15
  Permission to use, copy, modify, and/or distribute this software for any
@@ -112,50 +112,57 @@
112
112
  return to.concat(ar || Array.prototype.slice.call(from));
113
113
  }
114
114
 
115
- var MessageType = {
116
- UI_GET_DATA: 'ui-get-data',
117
- UI_SUBSCRIBE_TO_CHANGES: 'ui-subscribe-to-changes',
118
- UI_UNSUBSCRIBE_FROM_CHANGES: 'ui-unsubscribe-from-changes',
119
- UI_CHANGE_SETTINGS: 'ui-change-settings',
120
- UI_SET_THEME: 'ui-set-theme',
121
- UI_SET_SHORTCUT: 'ui-set-shortcut',
122
- UI_TOGGLE_ACTIVE_TAB: 'ui-toggle-active-tab',
123
- UI_MARK_NEWS_AS_READ: 'ui-mark-news-as-read',
124
- UI_MARK_NEWS_AS_DISPLAYED: 'ui-mark-news-as-displayed',
125
- UI_LOAD_CONFIG: 'ui-load-config',
126
- UI_APPLY_DEV_DYNAMIC_THEME_FIXES: 'ui-apply-dev-dynamic-theme-fixes',
127
- UI_RESET_DEV_DYNAMIC_THEME_FIXES: 'ui-reset-dev-dynamic-theme-fixes',
128
- UI_APPLY_DEV_INVERSION_FIXES: 'ui-apply-dev-inversion-fixes',
129
- UI_RESET_DEV_INVERSION_FIXES: 'ui-reset-dev-inversion-fixes',
130
- UI_APPLY_DEV_STATIC_THEMES: 'ui-apply-dev-static-themes',
131
- UI_RESET_DEV_STATIC_THEMES: 'ui-reset-dev-static-themes',
132
- UI_SAVE_FILE: 'ui-save-file',
133
- UI_REQUEST_EXPORT_CSS: 'ui-request-export-css',
134
- BG_CHANGES: 'bg-changes',
135
- BG_ADD_CSS_FILTER: 'bg-add-css-filter',
136
- BG_ADD_STATIC_THEME: 'bg-add-static-theme',
137
- BG_ADD_SVG_FILTER: 'bg-add-svg-filter',
138
- BG_ADD_DYNAMIC_THEME: 'bg-add-dynamic-theme',
139
- BG_EXPORT_CSS: 'bg-export-css',
140
- BG_UNSUPPORTED_SENDER: 'bg-unsupported-sender',
141
- BG_CLEAN_UP: 'bg-clean-up',
142
- BG_RELOAD: 'bg-reload',
143
- BG_FETCH_RESPONSE: 'bg-fetch-response',
144
- BG_UI_UPDATE: 'bg-ui-update',
145
- BG_CSS_UPDATE: 'bg-css-update',
146
- CS_COLOR_SCHEME_CHANGE: 'cs-color-scheme-change',
147
- CS_FRAME_CONNECT: 'cs-frame-connect',
148
- CS_FRAME_FORGET: 'cs-frame-forget',
149
- CS_FRAME_FREEZE: 'cs-frame-freeze',
150
- CS_FRAME_RESUME: 'cs-frame-resume',
151
- CS_EXPORT_CSS_RESPONSE: 'cs-export-css-response',
152
- CS_FETCH: 'cs-fetch',
153
- CS_DARK_THEME_DETECTED: 'cs-dark-theme-detected',
154
- CS_DARK_THEME_NOT_DETECTED: 'cs-dark-theme-not-detected',
155
- };
115
+ var MessageType;
116
+ (function (MessageType) {
117
+ MessageType["UI_GET_DATA"] = "ui-get-data";
118
+ MessageType["UI_SUBSCRIBE_TO_CHANGES"] = "ui-subscribe-to-changes";
119
+ MessageType["UI_UNSUBSCRIBE_FROM_CHANGES"] = "ui-unsubscribe-from-changes";
120
+ MessageType["UI_CHANGE_SETTINGS"] = "ui-change-settings";
121
+ MessageType["UI_SET_THEME"] = "ui-set-theme";
122
+ MessageType["UI_SET_SHORTCUT"] = "ui-set-shortcut";
123
+ MessageType["UI_TOGGLE_ACTIVE_TAB"] = "ui-toggle-active-tab";
124
+ MessageType["UI_MARK_NEWS_AS_READ"] = "ui-mark-news-as-read";
125
+ MessageType["UI_MARK_NEWS_AS_DISPLAYED"] = "ui-mark-news-as-displayed";
126
+ MessageType["UI_LOAD_CONFIG"] = "ui-load-config";
127
+ MessageType["UI_APPLY_DEV_DYNAMIC_THEME_FIXES"] = "ui-apply-dev-dynamic-theme-fixes";
128
+ MessageType["UI_RESET_DEV_DYNAMIC_THEME_FIXES"] = "ui-reset-dev-dynamic-theme-fixes";
129
+ MessageType["UI_APPLY_DEV_INVERSION_FIXES"] = "ui-apply-dev-inversion-fixes";
130
+ MessageType["UI_RESET_DEV_INVERSION_FIXES"] = "ui-reset-dev-inversion-fixes";
131
+ MessageType["UI_APPLY_DEV_STATIC_THEMES"] = "ui-apply-dev-static-themes";
132
+ MessageType["UI_RESET_DEV_STATIC_THEMES"] = "ui-reset-dev-static-themes";
133
+ MessageType["UI_SAVE_FILE"] = "ui-save-file";
134
+ MessageType["UI_REQUEST_EXPORT_CSS"] = "ui-request-export-css";
135
+ MessageType["UI_COLOR_SCHEME_CHANGE"] = "ui-color-scheme-change";
136
+ MessageType["BG_CHANGES"] = "bg-changes";
137
+ MessageType["BG_ADD_CSS_FILTER"] = "bg-add-css-filter";
138
+ MessageType["BG_ADD_STATIC_THEME"] = "bg-add-static-theme";
139
+ MessageType["BG_ADD_SVG_FILTER"] = "bg-add-svg-filter";
140
+ MessageType["BG_ADD_DYNAMIC_THEME"] = "bg-add-dynamic-theme";
141
+ MessageType["BG_EXPORT_CSS"] = "bg-export-css";
142
+ MessageType["BG_UNSUPPORTED_SENDER"] = "bg-unsupported-sender";
143
+ MessageType["BG_CLEAN_UP"] = "bg-clean-up";
144
+ MessageType["BG_RELOAD"] = "bg-reload";
145
+ MessageType["BG_FETCH_RESPONSE"] = "bg-fetch-response";
146
+ MessageType["BG_UI_UPDATE"] = "bg-ui-update";
147
+ MessageType["BG_CSS_UPDATE"] = "bg-css-update";
148
+ MessageType["CS_COLOR_SCHEME_CHANGE"] = "cs-color-scheme-change";
149
+ MessageType["CS_FRAME_CONNECT"] = "cs-frame-connect";
150
+ MessageType["CS_FRAME_FORGET"] = "cs-frame-forget";
151
+ MessageType["CS_FRAME_FREEZE"] = "cs-frame-freeze";
152
+ MessageType["CS_FRAME_RESUME"] = "cs-frame-resume";
153
+ MessageType["CS_EXPORT_CSS_RESPONSE"] = "cs-export-css-response";
154
+ MessageType["CS_FETCH"] = "cs-fetch";
155
+ MessageType["CS_DARK_THEME_DETECTED"] = "cs-dark-theme-detected";
156
+ MessageType["CS_DARK_THEME_NOT_DETECTED"] = "cs-dark-theme-not-detected";
157
+ })(MessageType || (MessageType = {}));
156
158
 
157
- var userAgent = typeof navigator === 'undefined' ? 'some useragent' : navigator.userAgent.toLowerCase();
158
- var platform = typeof navigator === 'undefined' ? 'some platform' : navigator.platform.toLowerCase();
159
+ var isNavigatorDefined = typeof navigator !== 'undefined';
160
+ var userAgent = isNavigatorDefined ? (navigator.userAgentData && Array.isArray(navigator.userAgentData.brands)) ?
161
+ navigator.userAgentData.brands.map(function (brand) { return "".concat(brand.brand.toLowerCase(), " ").concat(brand.version); }).join(' ') : navigator.userAgent.toLowerCase()
162
+ : 'some useragent';
163
+ var platform = isNavigatorDefined ? (navigator.userAgentData && typeof navigator.userAgentData.platform === 'string') ?
164
+ navigator.userAgentData.platform.toLowerCase() : navigator.platform.toLowerCase()
165
+ : 'some platform';
159
166
  var isChromium = userAgent.includes('chrome') || userAgent.includes('chromium');
160
167
  var isThunderbird = userAgent.includes('thunderbird');
161
168
  var isFirefox = userAgent.includes('firefox') || userAgent.includes('librewolf') || isThunderbird;
@@ -166,12 +173,19 @@
166
173
  var isSafari = userAgent.includes('safari') && !isChromium;
167
174
  var isWindows = platform.startsWith('win');
168
175
  var isMacOS = platform.startsWith('mac');
169
- userAgent.includes('mobile');
176
+ (isNavigatorDefined && navigator.userAgentData) ? navigator.userAgentData.mobile : userAgent.includes('mobile');
170
177
  var isShadowDomSupported = typeof ShadowRoot === 'function';
171
178
  var isMatchMediaChangeEventListenerSupported = (typeof MediaQueryList === 'function' &&
172
179
  typeof MediaQueryList.prototype.addEventListener === 'function');
173
180
  ((function () {
174
- var m = userAgent.match(/chrom[e|ium]\/([^ ]+)/);
181
+ var m = userAgent.match(/chrom(?:e|ium)(?:\/| )([^ ]+)/);
182
+ if (m && m[1]) {
183
+ return m[1];
184
+ }
185
+ return '';
186
+ }))();
187
+ ((function () {
188
+ var m = userAgent.match(/(?:firefox|librewolf)(?:\/| )([^ ]+)/);
175
189
  if (m && m[1]) {
176
190
  return m[1];
177
191
  }
@@ -186,7 +200,6 @@
186
200
  return false;
187
201
  }
188
202
  })();
189
- globalThis.chrome && globalThis.chrome.runtime && globalThis.chrome.runtime.getManifest && globalThis.chrome.runtime.getManifest().manifest_version === 3;
190
203
  var isCSSColorSchemePropSupported = (function () {
191
204
  if (typeof document === 'undefined') {
192
205
  return false;
@@ -456,16 +469,8 @@
456
469
  }
457
470
 
458
471
  function logInfo() {
459
- var args = [];
460
- for (var _i = 0; _i < arguments.length; _i++) {
461
- args[_i] = arguments[_i];
462
- }
463
472
  }
464
473
  function logWarn() {
465
- var args = [];
466
- for (var _i = 0; _i < arguments.length; _i++) {
467
- args[_i] = arguments[_i];
468
- }
469
474
  }
470
475
 
471
476
  function throttle(callback) {
@@ -570,7 +575,6 @@
570
575
  }
571
576
  else if (attempts >= MAX_ATTEMPTS_COUNT) {
572
577
  if (now - start < ATTEMPTS_INTERVAL) {
573
- logWarn("Node position watcher paused: retry in ".concat(RETRY_TIMEOUT, "ms"), node, prevSibling);
574
578
  timeoutId = setTimeout(function () {
575
579
  start = null;
576
580
  attempts = 0;
@@ -584,23 +588,19 @@
584
588
  }
585
589
  if (mode === 'parent') {
586
590
  if (prevSibling && prevSibling.parentNode !== parent) {
587
- logWarn('Unable to restore node position: sibling parent changed', node, prevSibling, parent);
588
591
  stop();
589
592
  return;
590
593
  }
591
594
  }
592
595
  if (mode === 'prev-sibling') {
593
596
  if (prevSibling.parentNode == null) {
594
- logWarn('Unable to restore node position: sibling was removed', node, prevSibling, parent);
595
597
  stop();
596
598
  return;
597
599
  }
598
600
  if (prevSibling.parentNode !== parent) {
599
- logWarn('Style was moved to another parent', node, prevSibling, parent);
600
601
  updateParent(prevSibling.parentNode);
601
602
  }
602
603
  }
603
- logWarn('Restoring node position', node, prevSibling, parent);
604
604
  parent.insertBefore(node, prevSibling ? prevSibling.nextSibling : parent.firstChild);
605
605
  observer.takeRecords();
606
606
  onRestore && onRestore();
@@ -925,10 +925,10 @@
925
925
  }
926
926
  }
927
927
  }
928
- var cssURLRegex = /url\((('.+?')|(".+?")|([^\)]*?))\)/g;
928
+ var cssURLRegex = /url\((('.*?')|(".*?")|([^\)]*?))\)/g;
929
929
  var cssImportRegex = /@import\s*(url\()?(('.+?')|(".+?")|([^\)]*?))\)? ?(screen)?;?/gi;
930
930
  function getCSSURLValue(cssURL) {
931
- return cssURL.trim().replace(/^url\((.*)\)$/, '$1').trim().replace(/^"(.*)"$/, '$1').replace(/^'(.*)'$/, '$1');
931
+ return cssURL.trim().replace(/^url\((.*)\)$/, '$1').trim().replace(/^"(.*)"$/, '$1').replace(/^'(.*)'$/, '$1').replace(/(?:\\(.))/g, '$1');
932
932
  }
933
933
  function getCSSBaseBath(url) {
934
934
  var cssURL = parseURL(url);
@@ -941,7 +941,6 @@
941
941
  return "url(\"".concat(getAbsoluteURL(cssBasePath, pathValue), "\")");
942
942
  }
943
943
  catch (err) {
944
- logWarn('Not able to replace relative URL with Absolute URL, skipping');
945
944
  return match;
946
945
  }
947
946
  });
@@ -1108,6 +1107,36 @@
1108
1107
  return null;
1109
1108
  }
1110
1109
 
1110
+ var hslaParseCache = new Map();
1111
+ var rgbaParseCache = new Map();
1112
+ function parseColorWithCache($color) {
1113
+ $color = $color.trim();
1114
+ if (rgbaParseCache.has($color)) {
1115
+ return rgbaParseCache.get($color);
1116
+ }
1117
+ if ($color.includes('calc(')) {
1118
+ $color = lowerCalcExpression($color);
1119
+ }
1120
+ var color = parse($color);
1121
+ color && rgbaParseCache.set($color, color);
1122
+ return color;
1123
+ }
1124
+ function parseToHSLWithCache(color) {
1125
+ if (hslaParseCache.has(color)) {
1126
+ return hslaParseCache.get(color);
1127
+ }
1128
+ var rgb = parseColorWithCache(color);
1129
+ if (!rgb) {
1130
+ return null;
1131
+ }
1132
+ var hsl = rgbToHSL(rgb);
1133
+ hslaParseCache.set(color, hsl);
1134
+ return hsl;
1135
+ }
1136
+ function clearColorCache() {
1137
+ hslaParseCache.clear();
1138
+ rgbaParseCache.clear();
1139
+ }
1111
1140
  function hslToRGB(_a) {
1112
1141
  var h = _a.h, s = _a.s, l = _a.l, _b = _a.a, a = _b === void 0 ? 1 : _b;
1113
1142
  if (s === 0) {
@@ -1207,7 +1236,7 @@
1207
1236
  if ($color === 'transparent') {
1208
1237
  return { r: 0, g: 0, b: 0, a: 0 };
1209
1238
  }
1210
- throw new Error("Unable to parse ".concat($color));
1239
+ return null;
1211
1240
  }
1212
1241
  function getNumbers($color) {
1213
1242
  var numbers = [];
@@ -1284,7 +1313,7 @@
1284
1313
  return { r: r, g: g, b: b, a: a };
1285
1314
  }
1286
1315
  }
1287
- throw new Error("Unable to parse ".concat($hex));
1316
+ return null;
1288
1317
  }
1289
1318
  function getColorByName($color) {
1290
1319
  var n = knownColors.get($color);
@@ -1625,19 +1654,8 @@
1625
1654
  return theme[prop];
1626
1655
  }
1627
1656
  var colorModificationCache = new Map();
1628
- var colorParseCache$1 = new Map();
1629
- function parseToHSLWithCache(color) {
1630
- if (colorParseCache$1.has(color)) {
1631
- return colorParseCache$1.get(color);
1632
- }
1633
- var rgb = parse(color);
1634
- var hsl = rgbToHSL(rgb);
1635
- colorParseCache$1.set(color, hsl);
1636
- return hsl;
1637
- }
1638
1657
  function clearColorModificationCache() {
1639
1658
  colorModificationCache.clear();
1640
- colorParseCache$1.clear();
1641
1659
  }
1642
1660
  var rgbCacheKeys = ['r', 'g', 'b', 'a'];
1643
1661
  var themeCacheKeys$1 = ['mode', 'brightness', 'contrast', 'grayscale', 'sepia', 'darkSchemeBackgroundColor', 'darkSchemeTextColor', 'lightSchemeBackgroundColor', 'lightSchemeTextColor'];
@@ -2055,7 +2073,6 @@
2055
2073
  }
2056
2074
  var size = naturalWidth * naturalHeight * 4;
2057
2075
  if (size > MAX_IMAGE_SIZE) {
2058
- logInfo('Skipped large image analyzing(Larger than 5mb in memory)');
2059
2076
  return {
2060
2077
  isDark: false,
2061
2078
  isLight: false,
@@ -2205,11 +2222,14 @@
2205
2222
  return { property: property, value: modifier, important: getPriority(rule.style, property), sourceValue: value };
2206
2223
  }
2207
2224
  }
2225
+ else if (property === 'color-scheme') {
2226
+ return null;
2227
+ }
2208
2228
  else if ((property.includes('color') && property !== '-webkit-print-color-adjust') ||
2209
2229
  property === 'fill' ||
2210
2230
  property === 'stroke' ||
2211
2231
  property === 'stop-color') {
2212
- var modifier = getColorModifier(property, value);
2232
+ var modifier = getColorModifier(property, value, rule);
2213
2233
  if (modifier) {
2214
2234
  return { property: property, value: modifier, important: getPriority(rule.style, property), sourceValue: value };
2215
2235
  }
@@ -2288,7 +2308,7 @@
2288
2308
  foregroundColorSelection = modifyForegroundColor({ r: 255, g: 255, b: 255 }, __assign(__assign({}, theme), { grayscale: 0 }));
2289
2309
  }
2290
2310
  else {
2291
- var rgb = parse(theme.selectionColor);
2311
+ var rgb = parseColorWithCache(theme.selectionColor);
2292
2312
  var hsl = rgbToHSL(rgb);
2293
2313
  backgroundColorSelection = theme.selectionColor;
2294
2314
  if (hsl.l < 0.5) {
@@ -2330,7 +2350,7 @@
2330
2350
  colorCorner = modifyBackgroundColor({ r: 255, g: 255, b: 255 }, theme);
2331
2351
  }
2332
2352
  else {
2333
- var rgb = parse(theme.scrollbarColor);
2353
+ var rgb = parseColorWithCache(theme.scrollbarColor);
2334
2354
  var hsl_1 = rgbToHSL(rgb);
2335
2355
  var isLight = hsl_1.l > 0.5;
2336
2356
  var lighten = function (lighter) { return (__assign(__assign({}, hsl_1), { l: clamp(hsl_1.l + lighter, 0, 1) })); };
@@ -2367,7 +2387,7 @@
2367
2387
  function getModifiedFallbackStyle(filter, _a) {
2368
2388
  var strict = _a.strict;
2369
2389
  var lines = [];
2370
- var isMicrosoft = location.hostname.endsWith('microsoft.com');
2390
+ var isMicrosoft = ['microsoft.com', 'docs.microsoft.com'].includes(location.hostname);
2371
2391
  lines.push("html, body, ".concat(strict ? "body :not(iframe)".concat(isMicrosoft ? ':not(div[style^="position:absolute;top:0;left:-"]' : '') : 'body > :not(iframe)', " {"));
2372
2392
  lines.push(" background-color: ".concat(modifyBackgroundColor({ r: 255, g: 255, b: 255 }, filter), " !important;"));
2373
2393
  lines.push(" border-color: ".concat(modifyBorderColor({ r: 64, g: 64, b: 64 }, filter), " !important;"));
@@ -2383,45 +2403,27 @@
2383
2403
  'none',
2384
2404
  'unset',
2385
2405
  ]);
2386
- var colorParseCache = new Map();
2387
- function parseColorWithCache($color) {
2388
- $color = $color.trim();
2389
- if (colorParseCache.has($color)) {
2390
- return colorParseCache.get($color);
2391
- }
2392
- if ($color.includes('calc(')) {
2393
- $color = lowerCalcExpression($color);
2394
- }
2395
- var color = parse($color);
2396
- colorParseCache.set($color, color);
2397
- return color;
2398
- }
2399
- function tryParseColor($color) {
2400
- try {
2401
- return parseColorWithCache($color);
2402
- }
2403
- catch (err) {
2404
- return null;
2405
- }
2406
- }
2407
- function getColorModifier(prop, value) {
2406
+ function getColorModifier(prop, value, rule) {
2408
2407
  if (unparsableColors.has(value.toLowerCase())) {
2409
2408
  return value;
2410
2409
  }
2411
- try {
2412
- var rgb_1 = parseColorWithCache(value);
2413
- if (prop.includes('background')) {
2414
- return function (filter) { return modifyBackgroundColor(rgb_1, filter); };
2415
- }
2416
- if (prop.includes('border') || prop.includes('outline')) {
2417
- return function (filter) { return modifyBorderColor(rgb_1, filter); };
2410
+ var rgb = parseColorWithCache(value);
2411
+ if (!rgb) {
2412
+ return null;
2413
+ }
2414
+ if (prop.includes('background')) {
2415
+ if ((rule.style.webkitMaskImage && rule.style.webkitMaskImage !== 'none') ||
2416
+ (rule.style.webkitMask && rule.style.webkitMask !== 'none') ||
2417
+ (rule.style.mask && rule.style.mask !== 'none') ||
2418
+ (rule.style.getPropertyValue('mask-image') && rule.style.getPropertyValue('mask-image') !== 'none')) {
2419
+ return function (filter) { return modifyForegroundColor(rgb, filter); };
2418
2420
  }
2419
- return function (filter) { return modifyForegroundColor(rgb_1, filter); };
2421
+ return function (filter) { return modifyBackgroundColor(rgb, filter); };
2420
2422
  }
2421
- catch (err) {
2422
- logWarn('Color parse error', err);
2423
- return null;
2423
+ if (prop.includes('border') || prop.includes('outline')) {
2424
+ return function (filter) { return modifyBorderColor(rgb, filter); };
2424
2425
  }
2426
+ return function (filter) { return modifyForegroundColor(rgb, filter); };
2425
2427
  }
2426
2428
  var imageDetailsCache = new Map();
2427
2429
  var awaitingForImageLoading = new Map();
@@ -2467,22 +2469,22 @@
2467
2469
  .sort(function (a, b) { return a.index > b.index ? 1 : -1; });
2468
2470
  var getGradientModifier_1 = function (gradient) {
2469
2471
  var typeGradient = gradient.typeGradient, match = gradient.match, hasComma = gradient.hasComma;
2470
- var partsRegex = /([^\(\),]+(\([^\(\)]*(\([^\(\)]*\)*[^\(\)]*)?\))?[^\(\),]*),?/g;
2472
+ var partsRegex = /([^\(\),]+(\([^\(\)]*(\([^\(\)]*\)*[^\(\)]*)?\))?([^\(\), ]|( (?!calc)))*),?/g;
2471
2473
  var colorStopRegex = /^(from|color-stop|to)\(([^\(\)]*?,\s*)?(.*?)\)$/;
2472
2474
  var parts = getMatches(partsRegex, match, 1).map(function (part) {
2473
2475
  part = part.trim();
2474
- var rgb = tryParseColor(part);
2476
+ var rgb = parseColorWithCache(part);
2475
2477
  if (rgb) {
2476
2478
  return function (filter) { return modifyGradientColor(rgb, filter); };
2477
2479
  }
2478
2480
  var space = part.lastIndexOf(' ');
2479
- rgb = tryParseColor(part.substring(0, space));
2481
+ rgb = parseColorWithCache(part.substring(0, space));
2480
2482
  if (rgb) {
2481
2483
  return function (filter) { return "".concat(modifyGradientColor(rgb, filter), " ").concat(part.substring(space + 1)); };
2482
2484
  }
2483
2485
  var colorStopMatch = part.match(colorStopRegex);
2484
2486
  if (colorStopMatch) {
2485
- rgb = tryParseColor(colorStopMatch[3]);
2487
+ rgb = parseColorWithCache(colorStopMatch[3]);
2486
2488
  if (rgb) {
2487
2489
  return function (filter) { return "".concat(colorStopMatch[1], "(").concat(colorStopMatch[2] ? "".concat(colorStopMatch[2], ", ") : '').concat(modifyGradientColor(rgb, filter), ")"); };
2488
2490
  }
@@ -2499,6 +2501,7 @@
2499
2501
  return null;
2500
2502
  }
2501
2503
  var url = getCSSURLValue(urlValue);
2504
+ var isURLEmpty = url.length === 0;
2502
2505
  var parentStyleSheet = rule.parentStyleSheet;
2503
2506
  var baseURL = (parentStyleSheet && parentStyleSheet.href) ?
2504
2507
  getCSSBaseBath(parentStyleSheet.href) :
@@ -2510,6 +2513,9 @@
2510
2513
  return __generator(this, function (_a) {
2511
2514
  switch (_a.label) {
2512
2515
  case 0:
2516
+ if (isURLEmpty) {
2517
+ return [2, "url('')"];
2518
+ }
2513
2519
  if (!imageDetailsCache.has(url)) return [3, 1];
2514
2520
  imageDetails = imageDetailsCache.get(url);
2515
2521
  return [3, 7];
@@ -2586,13 +2592,28 @@
2586
2592
  };
2587
2593
  var modifiers_1 = [];
2588
2594
  var matchIndex_1 = 0;
2595
+ var prevHasComma_1 = false;
2589
2596
  matches_1.forEach(function (_a, i) {
2590
2597
  var type = _a.type, match = _a.match, index = _a.index, typeGradient = _a.typeGradient, hasComma = _a.hasComma, offset = _a.offset;
2591
2598
  var matchStart = index;
2592
2599
  var prefixStart = matchIndex_1;
2593
2600
  var matchEnd = matchStart + match.length + offset;
2594
2601
  matchIndex_1 = matchEnd;
2595
- prefixStart !== matchStart && modifiers_1.push(function () { return value.substring(prefixStart, matchStart); });
2602
+ if (prefixStart !== matchStart) {
2603
+ if (prevHasComma_1) {
2604
+ modifiers_1.push(function () {
2605
+ var betweenValue = value.substring(prefixStart, matchStart);
2606
+ if (betweenValue[0] === ',') {
2607
+ betweenValue = betweenValue.substring(1);
2608
+ }
2609
+ return betweenValue;
2610
+ });
2611
+ }
2612
+ else {
2613
+ modifiers_1.push(function () { return value.substring(prefixStart, matchStart); });
2614
+ }
2615
+ }
2616
+ prevHasComma_1 = hasComma || false;
2596
2617
  if (type === 'url') {
2597
2618
  modifiers_1.push(getURLModifier_1(match));
2598
2619
  }
@@ -2610,11 +2631,14 @@
2610
2631
  return asyncResults.filter(Boolean).join('');
2611
2632
  });
2612
2633
  }
2613
- return results.join('');
2634
+ var combinedResult = results.join('');
2635
+ if (combinedResult.endsWith(', initial')) {
2636
+ return combinedResult.slice(0, -9);
2637
+ }
2638
+ return combinedResult;
2614
2639
  };
2615
2640
  }
2616
2641
  catch (err) {
2617
- logWarn("Unable to parse gradient ".concat(value), err);
2618
2642
  return null;
2619
2643
  }
2620
2644
  }
@@ -2628,7 +2652,7 @@
2628
2652
  var matchIndex = value.indexOf(match, index_1);
2629
2653
  var matchEnd = matchIndex + match.length;
2630
2654
  index_1 = matchEnd;
2631
- var rgb = tryParseColor(match);
2655
+ var rgb = parseColorWithCache(match);
2632
2656
  if (!rgb) {
2633
2657
  notParsed_1++;
2634
2658
  return function () { return value.substring(prefixIndex, matchEnd); };
@@ -2645,7 +2669,6 @@
2645
2669
  };
2646
2670
  }
2647
2671
  catch (err) {
2648
- logWarn("Unable to parse shadow ".concat(value), err);
2649
2672
  return null;
2650
2673
  }
2651
2674
  }
@@ -2669,7 +2692,6 @@
2669
2692
  return variablesStore.getModifierForVarDependant(prop, value);
2670
2693
  }
2671
2694
  function cleanModificationCache() {
2672
- colorParseCache.clear();
2673
2695
  clearColorModificationCache();
2674
2696
  imageDetailsCache.clear();
2675
2697
  cleanImageProcessingCache();
@@ -2956,7 +2978,7 @@
2956
2978
  return;
2957
2979
  }
2958
2980
  this.definedVars.add(varName);
2959
- var color = tryParseColor(value);
2981
+ var color = parseColorWithCache(value);
2960
2982
  if (color) {
2961
2983
  this.unknownColorVars.add(varName);
2962
2984
  }
@@ -3234,11 +3256,11 @@
3234
3256
  }
3235
3257
  function handleRawValue(color, theme, modifyFunction) {
3236
3258
  var _a = parseRawValue(color), isRaw = _a.isRaw, newColor = _a.color;
3237
- var rgb = tryParseColor(newColor);
3259
+ var rgb = parseColorWithCache(newColor);
3238
3260
  if (rgb) {
3239
3261
  var outputColor = modifyFunction(rgb, theme);
3240
3262
  if (isRaw) {
3241
- var outputInRGB = tryParseColor(outputColor);
3263
+ var outputInRGB = parseColorWithCache(outputColor);
3242
3264
  return outputInRGB ? "".concat(outputInRGB.r, ", ").concat(outputInRGB.g, ", ").concat(outputInRGB.b) : outputColor;
3243
3265
  }
3244
3266
  return outputColor;
@@ -3507,7 +3529,7 @@
3507
3529
  function setCustomProp(targetCSSProp, modifierCSSProp, cssVal) {
3508
3530
  var isPropertyVariable = targetCSSProp.startsWith('--');
3509
3531
  var _a = isPropertyVariable ? {} : overrides[targetCSSProp], customProp = _a.customProp, dataAttr = _a.dataAttr;
3510
- var mod = getModifiableCSSDeclaration(modifierCSSProp, cssVal, {}, variablesStore, ignoreImageSelectors, null);
3532
+ var mod = getModifiableCSSDeclaration(modifierCSSProp, cssVal, { style: element.style }, variablesStore, ignoreImageSelectors, null);
3511
3533
  if (!mod) {
3512
3534
  return;
3513
3535
  }
@@ -3616,13 +3638,11 @@
3616
3638
  var observer = null;
3617
3639
  function changeMetaThemeColor(meta, theme) {
3618
3640
  srcMetaThemeColor = srcMetaThemeColor || meta.content;
3619
- try {
3620
- var color = parse(srcMetaThemeColor);
3621
- meta.content = modifyBackgroundColor(color, theme);
3622
- }
3623
- catch (err) {
3624
- logWarn(err);
3641
+ var color = parseColorWithCache(srcMetaThemeColor);
3642
+ if (!color) {
3643
+ return;
3625
3644
  }
3645
+ meta.content = modifyBackgroundColor(color, theme);
3626
3646
  }
3627
3647
  function changeMetaThemeColorWhenAvailable(theme) {
3628
3648
  var meta = document.querySelector(metaThemeColorSelector);
@@ -3912,15 +3932,29 @@
3912
3932
  }
3913
3933
 
3914
3934
  var STYLE_SELECTOR = 'style, link[rel*="stylesheet" i]:not([disabled])';
3935
+ function isFontsGoogleApiStyle(element) {
3936
+ if (!element.href) {
3937
+ return false;
3938
+ }
3939
+ try {
3940
+ var elementURL = new URL(element.href);
3941
+ return elementURL.hostname === 'fonts.googleapis.com';
3942
+ }
3943
+ catch (err) {
3944
+ logInfo("Couldn't construct ".concat(element.href, " as URL"));
3945
+ return false;
3946
+ }
3947
+ }
3915
3948
  function shouldManageStyle(element) {
3916
3949
  return (((element instanceof HTMLStyleElement) ||
3917
3950
  (element instanceof SVGStyleElement) ||
3918
3951
  (element instanceof HTMLLinkElement &&
3919
3952
  element.rel &&
3920
3953
  element.rel.toLowerCase().includes('stylesheet') &&
3954
+ element.href &&
3921
3955
  !element.disabled &&
3922
3956
  (isFirefox ? !element.href.startsWith('moz-extension://') : true) &&
3923
- !element.href.startsWith('https://fonts.googleapis.com'))) &&
3957
+ !isFontsGoogleApiStyle(element))) &&
3924
3958
  !element.classList.contains('darkreader') &&
3925
3959
  element.media.toLowerCase() !== 'print' &&
3926
3960
  !element.classList.contains('stylus'));
@@ -3995,26 +4029,20 @@
3995
4029
  }
3996
4030
  function getRulesSync() {
3997
4031
  if (corsCopy) {
3998
- logInfo('[getRulesSync] Using cors-copy.');
3999
4032
  return corsCopy.sheet.cssRules;
4000
4033
  }
4001
4034
  if (containsCSSImport()) {
4002
- logInfo('[getRulesSync] CSSImport detected.');
4003
4035
  return null;
4004
4036
  }
4005
4037
  var cssRules = safeGetSheetRules();
4006
4038
  if (element instanceof HTMLLinkElement &&
4007
4039
  !isRelativeHrefOnAbsolutePath(element.href) &&
4008
4040
  hasImports(cssRules, false)) {
4009
- logInfo('[getRulesSync] CSSImportRule detected on non-local href.');
4010
4041
  return null;
4011
4042
  }
4012
4043
  if (hasImports(cssRules, true)) {
4013
- logInfo('[getRulesSync] Cross-Origin CSSImportRule detected.');
4014
4044
  return null;
4015
4045
  }
4016
- logInfo('[getRulesSync] Using cssRules.');
4017
- !cssRules && logWarn('[getRulesSync] cssRules is null, trying again.');
4018
4046
  return cssRules;
4019
4047
  }
4020
4048
  function insertStyle() {
@@ -4047,30 +4075,25 @@
4047
4075
  var loadingLinkId = ++loadingLinkCounter;
4048
4076
  function getRulesAsync() {
4049
4077
  return __awaiter(this, void 0, void 0, function () {
4050
- var cssText, cssBasePath, _a, cssRules, accessError, err_1, fullCSSText, err_2;
4078
+ var cssText, cssBasePath, _a, cssRules, accessError, fullCSSText;
4051
4079
  var _b;
4052
4080
  return __generator(this, function (_c) {
4053
4081
  switch (_c.label) {
4054
4082
  case 0:
4055
4083
  if (!(element instanceof HTMLLinkElement)) return [3, 7];
4056
4084
  _a = __read(getRulesOrError(), 2), cssRules = _a[0], accessError = _a[1];
4057
- if (accessError) {
4058
- logWarn(accessError);
4059
- }
4060
4085
  if (!((!cssRules && !accessError && !isSafari) ||
4061
4086
  (isSafari && !element.sheet) ||
4062
4087
  isStillLoadingError(accessError))) return [3, 5];
4063
4088
  _c.label = 1;
4064
4089
  case 1:
4065
4090
  _c.trys.push([1, 3, , 4]);
4066
- logInfo("Linkelement ".concat(loadingLinkId, " is not loaded yet and thus will be await for"), element);
4067
4091
  return [4, linkLoading(element, loadingLinkId)];
4068
4092
  case 2:
4069
4093
  _c.sent();
4070
4094
  return [3, 4];
4071
4095
  case 3:
4072
- err_1 = _c.sent();
4073
- logWarn(err_1);
4096
+ _c.sent();
4074
4097
  wasLoadingError = true;
4075
4098
  return [3, 4];
4076
4099
  case 4:
@@ -4078,9 +4101,6 @@
4078
4101
  return [2, null];
4079
4102
  }
4080
4103
  _b = __read(getRulesOrError(), 2), cssRules = _b[0], accessError = _b[1];
4081
- if (accessError) {
4082
- logWarn(accessError);
4083
- }
4084
4104
  _c.label = 5;
4085
4105
  case 5:
4086
4106
  if (cssRules) {
@@ -4116,8 +4136,7 @@
4116
4136
  corsCopy = createCORSCopy(element, fullCSSText);
4117
4137
  return [3, 12];
4118
4138
  case 11:
4119
- err_2 = _c.sent();
4120
- logWarn(err_2);
4139
+ _c.sent();
4121
4140
  return [3, 12];
4122
4141
  case 12:
4123
4142
  if (corsCopy) {
@@ -4134,7 +4153,6 @@
4134
4153
  var rules = getRulesSync();
4135
4154
  if (!rules) {
4136
4155
  if (options.secondRound) {
4137
- logWarn('Detected dead-lock at details(), returning early to prevent it.');
4138
4156
  return null;
4139
4157
  }
4140
4158
  if (isLoadingRules || wasLoadingError) {
@@ -4149,7 +4167,6 @@
4149
4167
  update();
4150
4168
  }
4151
4169
  }).catch(function (err) {
4152
- logWarn(err);
4153
4170
  isLoadingRules = false;
4154
4171
  loadingEnd();
4155
4172
  });
@@ -4226,7 +4243,6 @@
4226
4243
  function safeGetSheetRules() {
4227
4244
  var _a = __read(getRulesOrError(), 2), cssRules = _a[0], err = _a[1];
4228
4245
  if (err) {
4229
- logWarn(err);
4230
4246
  return null;
4231
4247
  }
4232
4248
  return cssRules;
@@ -4329,10 +4345,8 @@
4329
4345
  }
4330
4346
  moveCount++;
4331
4347
  if (moveCount > maxMoveCount) {
4332
- logWarn('Style sheet was moved multiple times', element);
4333
4348
  return;
4334
4349
  }
4335
- logWarn('Restore style', syncStyle, element);
4336
4350
  insertStyle();
4337
4351
  corsCopyPositionWatcher && corsCopyPositionWatcher.skip();
4338
4352
  syncStylePositionWatcher && syncStylePositionWatcher.skip();
@@ -4361,7 +4375,6 @@
4361
4375
  };
4362
4376
  var onLoad = function () {
4363
4377
  cleanUp();
4364
- logInfo("Linkelement ".concat(loadingId, " has been loaded"));
4365
4378
  resolve();
4366
4379
  };
4367
4380
  var onError = function () {
@@ -4402,7 +4415,7 @@
4402
4415
  function replaceCSSImports(cssText, basePath, cache) {
4403
4416
  if (cache === void 0) { cache = new Map(); }
4404
4417
  return __awaiter(this, void 0, void 0, function () {
4405
- var importMatches, importMatches_1, importMatches_1_1, match, importURL, absoluteURL, importedCSS, err_3, e_1_1;
4418
+ var importMatches, importMatches_1, importMatches_1_1, match, importURL, absoluteURL, importedCSS, e_1_1;
4406
4419
  var e_1, _a;
4407
4420
  return __generator(this, function (_b) {
4408
4421
  switch (_b.label) {
@@ -4436,8 +4449,7 @@
4436
4449
  importedCSS = _b.sent();
4437
4450
  return [3, 7];
4438
4451
  case 6:
4439
- err_3 = _b.sent();
4440
- logWarn(err_3);
4452
+ _b.sent();
4441
4453
  importedCSS = '';
4442
4454
  return [3, 7];
4443
4455
  case 7:
@@ -4661,7 +4673,7 @@
4661
4673
  onHugeMutations: handleHugeTreeMutations,
4662
4674
  });
4663
4675
  var attrObserver = new MutationObserver(handleAttributeMutations);
4664
- attrObserver.observe(root, { attributes: true, attributeFilter: ['rel', 'disabled', 'media'], subtree: true });
4676
+ attrObserver.observe(root, { attributes: true, attributeFilter: ['rel', 'disabled', 'media', 'href'], subtree: true });
4665
4677
  observers.push(treeObserver, attrObserver);
4666
4678
  observedRoots.add(root);
4667
4679
  }
@@ -4786,7 +4798,18 @@
4786
4798
  var removeRuleDescriptor = Object.getOwnPropertyDescriptor(CSSStyleSheet.prototype, 'removeRule');
4787
4799
  var documentStyleSheetsDescriptor = enableStyleSheetsProxy ?
4788
4800
  Object.getOwnPropertyDescriptor(Document.prototype, 'styleSheets') : null;
4789
- var shouldWrapHTMLElement = location.hostname.endsWith('baidu.com');
4801
+ var shouldWrapHTMLElement = [
4802
+ 'baidu.com',
4803
+ 'baike.baidu.com',
4804
+ 'ditu.baidu.com',
4805
+ 'map.baidu.com',
4806
+ 'maps.baidu.com',
4807
+ 'haokan.baidu.com',
4808
+ 'pan.baidu.com',
4809
+ 'passport.baidu.com',
4810
+ 'tieba.baidu.com',
4811
+ 'www.baidu.com'
4812
+ ].includes(location.hostname);
4790
4813
  var getElementsByTagNameDescriptor = shouldWrapHTMLElement ?
4791
4814
  Object.getOwnPropertyDescriptor(Element.prototype, 'getElementsByTagName') : null;
4792
4815
  var cleanUp = function () {
@@ -4973,8 +4996,8 @@
4973
4996
  var darkSchemeBackgroundColor = filter.darkSchemeBackgroundColor, darkSchemeTextColor = filter.darkSchemeTextColor, lightSchemeBackgroundColor = filter.lightSchemeBackgroundColor, lightSchemeTextColor = filter.lightSchemeTextColor, mode = filter.mode;
4974
4997
  var schemeBackgroundColor = mode === 0 ? lightSchemeBackgroundColor : darkSchemeBackgroundColor;
4975
4998
  var schemeTextColor = mode === 0 ? lightSchemeTextColor : darkSchemeTextColor;
4976
- schemeBackgroundColor = modifyBackgroundColor(parse(schemeBackgroundColor), filter);
4977
- schemeTextColor = modifyForegroundColor(parse(schemeTextColor), filter);
4999
+ schemeBackgroundColor = modifyBackgroundColor(parseColorWithCache(schemeBackgroundColor), filter);
5000
+ schemeTextColor = modifyForegroundColor(parseColorWithCache(schemeTextColor), filter);
4978
5001
  variableStyle.textContent = [
4979
5002
  ":root {",
4980
5003
  " --darkreader-neutral-background: ".concat(schemeBackgroundColor, ";"),
@@ -4987,10 +5010,13 @@
4987
5010
  setupNodePositionWatcher(variableStyle, 'variables');
4988
5011
  var rootVarsStyle = createOrUpdateStyle('darkreader--root-vars');
4989
5012
  document.head.insertBefore(rootVarsStyle, variableStyle.nextSibling);
4990
- var proxyScript = createOrUpdateScript('darkreader--proxy');
4991
- proxyScript.append("(".concat(injectProxy, ")(!").concat(fixes && fixes.disableStyleSheetsProxy, ")"));
4992
- document.head.insertBefore(proxyScript, rootVarsStyle.nextSibling);
4993
- proxyScript.remove();
5013
+ var injectProxyArg = !(fixes && fixes.disableStyleSheetsProxy);
5014
+ {
5015
+ var proxyScript = createOrUpdateScript('darkreader--proxy');
5016
+ proxyScript.append("(".concat(injectProxy, ")(").concat(injectProxyArg, ")"));
5017
+ document.head.insertBefore(proxyScript, rootVarsStyle.nextSibling);
5018
+ proxyScript.remove();
5019
+ }
4994
5020
  }
4995
5021
  var shadowRootsWithOverrides = new Set();
4996
5022
  function createShadowStaticStyleOverrides(root) {
@@ -5016,11 +5042,10 @@
5016
5042
  }
5017
5043
  function replaceCSSTemplates($cssText) {
5018
5044
  return $cssText.replace(/\${(.+?)}/g, function (_, $color) {
5019
- var color = tryParseColor($color);
5045
+ var color = parseColorWithCache($color);
5020
5046
  if (color) {
5021
5047
  return modifyColor(color, filter);
5022
5048
  }
5023
- logWarn("Couldn't parse CSSTemplate's color.");
5024
5049
  return $color;
5025
5050
  });
5026
5051
  }
@@ -5067,7 +5092,6 @@
5067
5092
  var loadingStyles = new Set();
5068
5093
  function createManager(element) {
5069
5094
  var loadingStyleId = ++loadingStylesCounter;
5070
- logInfo("New manager for element, with loadingStyleID ".concat(loadingStyleId), element);
5071
5095
  function loadingStart() {
5072
5096
  if (!isDOMReady() || !didDocumentShowUp) {
5073
5097
  loadingStyles.add(loadingStyleId);
@@ -5081,7 +5105,6 @@
5081
5105
  function loadingEnd() {
5082
5106
  loadingStyles.delete(loadingStyleId);
5083
5107
  logInfo("Removed loadingStyle ".concat(loadingStyleId, ", now awaiting: ").concat(loadingStyles.size));
5084
- logInfo("To-do to be loaded", loadingStyles);
5085
5108
  if (loadingStyles.size === 0 && isDOMReady()) {
5086
5109
  cleanFallbackStyle();
5087
5110
  }
@@ -5119,7 +5142,6 @@
5119
5142
  cleanFallbackStyle();
5120
5143
  return;
5121
5144
  }
5122
- logWarn("DOM is ready, but still have styles being loaded.", loadingStyles);
5123
5145
  }
5124
5146
  var documentVisibilityListener = null;
5125
5147
  var didDocumentShowUp = !document.hidden;
@@ -5165,7 +5187,6 @@
5165
5187
  }
5166
5188
  }
5167
5189
  catch (err) {
5168
- logWarn('Error occured in handleAdoptedStyleSheets: ', err);
5169
5190
  }
5170
5191
  }
5171
5192
  function watchForUpdates() {
@@ -5177,7 +5198,6 @@
5177
5198
  .filter(function (style) { return !styleManagers.has(style); });
5178
5199
  var stylesToRestore = moved
5179
5200
  .filter(function (style) { return styleManagers.has(style); });
5180
- logInfo("Styles to be removed:", stylesToRemove);
5181
5201
  stylesToRemove.forEach(function (style) { return removeManager(style); });
5182
5202
  var newManagers = stylesToManage
5183
5203
  .map(function (style) { return createManager(style); });
@@ -5221,6 +5241,16 @@
5221
5241
  removeDOMReadyListener(onDOMReady);
5222
5242
  cleanReadyStateCompleteListeners();
5223
5243
  }
5244
+ var metaObserver;
5245
+ function addMetaListener() {
5246
+ metaObserver = new MutationObserver(function () {
5247
+ if (document.querySelector('meta[name="darkreader-lock"]')) {
5248
+ metaObserver.disconnect();
5249
+ removeDynamicTheme();
5250
+ }
5251
+ });
5252
+ metaObserver.observe(document.head, { childList: true, subtree: true });
5253
+ }
5224
5254
  function createDarkReaderInstanceMarker() {
5225
5255
  var metaElement = document.createElement('meta');
5226
5256
  metaElement.name = 'darkreader';
@@ -5228,6 +5258,9 @@
5228
5258
  document.head.appendChild(metaElement);
5229
5259
  }
5230
5260
  function isAnotherDarkReaderInstanceActive() {
5261
+ if (document.querySelector('meta[name="darkreader-lock"]')) {
5262
+ return true;
5263
+ }
5231
5264
  var meta = document.querySelector('meta[name="darkreader"]');
5232
5265
  if (meta) {
5233
5266
  if (meta.content !== INSTANCE_ID) {
@@ -5236,6 +5269,7 @@
5236
5269
  return false;
5237
5270
  }
5238
5271
  createDarkReaderInstanceMarker();
5272
+ addMetaListener();
5239
5273
  return false;
5240
5274
  }
5241
5275
  function createOrUpdateDynamicTheme(filterConfig, dynamicThemeFixes, iframe) {
@@ -5316,6 +5350,7 @@
5316
5350
  manager.destroy();
5317
5351
  });
5318
5352
  adoptedStyleManagers.splice(0);
5353
+ metaObserver && metaObserver.disconnect();
5319
5354
  }
5320
5355
  function cleanDynamicThemeCache() {
5321
5356
  variablesStore.clear();
@@ -5324,6 +5359,7 @@
5324
5359
  cancelRendering();
5325
5360
  stopWatchingForUpdates();
5326
5361
  cleanModificationCache();
5362
+ clearColorCache();
5327
5363
  }
5328
5364
 
5329
5365
  var blobRegex = /url\(\"(blob\:.*?)\"\)/g;
@@ -5346,7 +5382,7 @@
5346
5382
  });
5347
5383
  });
5348
5384
  }
5349
- var banner = "/*\n _______\n / \\\n .==. .==.\n (( ))==(( ))\n / \"==\" \"==\"\\\n /____|| || ||___\\\n ________ ____ ________ ___ ___\n | ___ \\ / \\ | ___ \\ | | / /\n | | \\ \\ / /\\ \\ | | \\ \\| |_/ /\n | | ) / /__\\ \\ | |__/ /| ___ \\\n | |__/ / ______ \\| ____ \\| | \\ \\\n_______|_______/__/ ____ \\__\\__|___\\__\\__|___\\__\\____\n| ___ \\ | ____/ / \\ | ___ \\ | ____| ___ \\\n| | \\ \\| |___ / /\\ \\ | | \\ \\| |___| | \\ \\\n| |__/ /| ____/ /__\\ \\ | | ) | ____| |__/ /\n| ____ \\| |__/ ______ \\| |__/ /| |___| ____ \\\n|__| \\__\\____/__/ \\__\\_______/ |______|__| \\__\\\n https://darkreader.org\n*/\n\n/*! Dark reader generated CSS | Licensed under MIT https://github.com/darkreader/darkreader/blob/master/LICENSE */\n";
5385
+ var banner = "/*\n _______\n / \\\n .==. .==.\n (( ))==(( ))\n / \"==\" \"==\"\\\n /____|| || ||___\\\n ________ ____ ________ ___ ___\n | ___ \\ / \\ | ___ \\ | | / /\n | | \\ \\ / /\\ \\ | | \\ \\| |_/ /\n | | ) / /__\\ \\ | |__/ /| ___ \\\n | |__/ / ______ \\| ____ \\| | \\ \\\n_______|_______/__/ ____ \\__\\__|___\\__\\__|___\\__\\____\n| ___ \\ | ____/ / \\ | ___ \\ | ____| ___ \\\n| | \\ \\| |___ / /\\ \\ | | \\ \\| |___| | \\ \\\n| |__/ /| ____/ /__\\ \\ | | ) | ____| |__/ /\n| ____ \\| |__/ ______ \\| |__/ /| |___| ____ \\\n|__| \\__\\____/__/ \\__\\_______/ |______|__| \\__\\\n https://darkreader.org\n*/\n\n/*! Dark reader generated CSS | Licensed under MIT https://github.com/darkreader/darkreader/blob/main/LICENSE */\n";
5350
5386
  function collectCSS() {
5351
5387
  return __awaiter(this, void 0, void 0, function () {
5352
5388
  function addStaticCSS(selector, comment) {
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "darkreader",
3
- "version": "4.9.51",
3
+ "version": "4.9.55",
4
4
  "description": "Dark mode for every website",
5
5
  "scripts": {
6
6
  "api": "node tasks/build.js --api",
7
- "benchmark-server": "node tests/benchmark-server/index.js",
8
7
  "build": "node tasks/build.js --release",
9
8
  "build:all": "node tasks/build.js --debug --release --api",
10
9
  "code-style": "eslint --ignore-pattern '!.eslintplugin.js' --cache --fix -- 'src/**/*.ts' 'src/**/*.tsx' 'tasks/**/*.js' 'tests/[!coverage]**/*.js' 'tests/**/*.ts' '.eslintrc.js' 'index.d.ts' '.eslintplugin.js'",
@@ -17,16 +16,17 @@
17
16
  "test": "npm run test:unit",
18
17
  "test:all": "npm run test:unit; npm run test:browser; npm run test:inject; npm run test:project",
19
18
  "test:browser": "npm run debug && npm run test:chrome && npm run test:firefox",
20
- "test:chrome": "npm run debug && jest --config=tests/browser/jest.config.js --runInBand",
19
+ "test:chrome": "npm run debug -- --test --chrome && jest --config=tests/browser/jest.config.mjs --runInBand",
21
20
  "test:ci": "npm run test:unit",
22
- "test:coverage": "jest --config=tests/unit/jest.config.js --coverage",
23
- "test:firefox": " npm run debug && jest --config=tests/browser/jest.config.firefox.js --runInBand",
24
- "test:inject": "node --max-old-space-size=3072 node_modules/.bin/karma start ./tests/inject/karma.conf.js",
25
- "test:inject:debug": "node --max-old-space-size=3072 node_modules/.bin/karma start ./tests/inject/karma.conf.js --debug",
21
+ "test:coverage": "jest --config=tests/unit/jest.config.mjs --coverage",
22
+ "test:firefox": " npm run debug -- --test --firefox && jest --config=tests/browser/jest.config.firefox.mjs --runInBand",
23
+ "test:inject": "node --max-old-space-size=3072 node_modules/.bin/karma start ./tests/inject/karma.conf.cjs",
24
+ "test:inject:debug": "node --max-old-space-size=3072 node_modules/.bin/karma start ./tests/inject/karma.conf.cjs --debug",
26
25
  "test:project": "jest --config=tests/project/jest.config.js",
27
- "test:unit": "jest --config=tests/unit/jest.config.js",
28
- "test:unit:debug": "node --inspect-brk ./node_modules/jest/bin/jest --config=tests/unit/jest.config.js --runInBand --no-cache --watch",
29
- "test:update-snapshots": "npm run test -- --updateSnapshot && npm run test:project -- --updateSnapshot"
26
+ "test:unit": "jest --config=tests/unit/jest.config.mjs",
27
+ "test:unit:debug": "node --inspect-brk ./node_modules/jest/bin/jest --config=tests/unit/jest.config.mjs --runInBand --no-cache --watch",
28
+ "test:update-snapshots": "npm run test -- --updateSnapshot && npm run test:project -- --updateSnapshot",
29
+ "translate-line": "node ./tasks/translate.js --line"
30
30
  },
31
31
  "main": "darkreader.js",
32
32
  "repository": {
@@ -53,49 +53,49 @@
53
53
  "url": "https://opencollective.com/darkreader/donate"
54
54
  },
55
55
  "devDependencies": {
56
- "@rollup/plugin-node-resolve": "13.1.3",
56
+ "@rollup/plugin-node-resolve": "13.3.0",
57
57
  "@rollup/plugin-replace": "4.0.0",
58
- "@rollup/plugin-typescript": "8.3.1",
59
- "@rollup/pluginutils": "4.2.0",
60
- "@types/chrome": "0.0.180",
61
- "@types/eslint": "8.4.1",
62
- "@types/jasmine": "4.0.0",
63
- "@types/jest": "27.4.1",
58
+ "@rollup/plugin-typescript": "8.3.4",
59
+ "@rollup/pluginutils": "4.2.1",
60
+ "@types/chrome": "0.0.193",
61
+ "@types/eslint": "8.4.5",
62
+ "@types/jasmine": "4.0.3",
63
+ "@types/jest": "28.1.6",
64
64
  "@types/karma": "6.3.3",
65
65
  "@types/karma-coverage": "2.0.1",
66
- "@types/node": "17.0.23",
67
- "@types/offscreencanvas": "2019.6.4",
68
- "@typescript-eslint/eslint-plugin": "5.16.0",
69
- "@typescript-eslint/parser": "5.16.0",
66
+ "@types/node": "18.6.4",
67
+ "@types/offscreencanvas": "2019.7.0",
68
+ "@typescript-eslint/eslint-plugin": "5.32.0",
69
+ "@typescript-eslint/parser": "5.32.0",
70
70
  "chokidar": "3.5.3",
71
- "eslint": "8.11.0",
71
+ "eslint": "8.21.0",
72
72
  "eslint-plugin-compat": "4.0.2",
73
- "eslint-plugin-import": "2.25.4",
73
+ "eslint-plugin-import": "2.26.0",
74
74
  "eslint-plugin-local": "1.0.0",
75
75
  "get-stream": "6.0.1",
76
- "globby": "13.1.1",
77
- "jasmine-core": "4.0.1",
78
- "jest": "27.5.1",
79
- "jest-extended": "2.0.0",
80
- "karma": "6.3.17",
76
+ "globby": "13.1.2",
77
+ "jasmine-core": "4.3.0",
78
+ "jest": "28.1.3",
79
+ "jest-extended": "3.0.2",
80
+ "karma": "6.4.0",
81
81
  "karma-chrome-launcher": "3.1.1",
82
82
  "karma-coverage": "2.2.0",
83
83
  "karma-firefox-launcher": "2.1.2",
84
- "karma-jasmine": "4.0.1",
84
+ "karma-jasmine": "5.1.0",
85
85
  "karma-rollup-preprocessor": "7.0.8",
86
86
  "karma-safari-launcher": "1.0.0",
87
- "karma-spec-reporter": "0.0.33",
88
- "less": "4.1.2",
87
+ "karma-spec-reporter": "0.0.34",
88
+ "less": "4.1.3",
89
89
  "malevic": "0.19.1",
90
- "prettier": "2.6.1",
91
- "puppeteer-core": "13.5.1",
92
- "rollup": "2.70.1",
90
+ "prettier": "2.7.1",
91
+ "puppeteer-core": "16.0.0",
92
+ "rollup": "2.77.2",
93
93
  "rollup-plugin-istanbul2": "2.0.2",
94
- "ts-jest": "27.1.4",
95
- "tslib": "2.3.1",
96
- "typescript": "4.6.3",
97
- "web-ext": "6.8.0",
98
- "ws": "8.5.0",
94
+ "ts-jest": "28.0.7",
95
+ "tslib": "2.4.0",
96
+ "typescript": "4.7.4",
97
+ "web-ext": "7.1.1",
98
+ "ws": "8.8.1",
99
99
  "yazl": "2.5.1"
100
100
  }
101
101
  }