darkreader 4.9.52 → 4.9.53
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.
- package/README.md +1 -1
- package/darkreader.js +187 -175
- package/package.json +37 -38
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/
|
|
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.
|
|
2
|
+
* Dark Reader v4.9.53
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
|
158
|
-
var
|
|
159
|
+
var isNavigatorDefined = typeof navigator !== 'undefined';
|
|
160
|
+
var userAgent = isNavigatorDefined ? navigator.userAgentData ?
|
|
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 ?
|
|
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
|
|
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,7 +925,7 @@
|
|
|
925
925
|
}
|
|
926
926
|
}
|
|
927
927
|
}
|
|
928
|
-
var cssURLRegex = /url\((('
|
|
928
|
+
var cssURLRegex = /url\((('.*?')|(".*?")|([^\)]*?))\)/g;
|
|
929
929
|
var cssImportRegex = /@import\s*(url\()?(('.+?')|(".+?")|([^\)]*?))\)? ?(screen)?;?/gi;
|
|
930
930
|
function getCSSURLValue(cssURL) {
|
|
931
931
|
return cssURL.trim().replace(/^url\((.*)\)$/, '$1').trim().replace(/^"(.*)"$/, '$1').replace(/^'(.*)'$/, '$1').replace(/(?:\\(.))/g, '$1');
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
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) })); };
|
|
@@ -2383,45 +2403,27 @@
|
|
|
2383
2403
|
'none',
|
|
2384
2404
|
'unset',
|
|
2385
2405
|
]);
|
|
2386
|
-
|
|
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
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
if (
|
|
2417
|
-
|
|
2410
|
+
var rgb = parseColorWithCache(value);
|
|
2411
|
+
if (!rgb) {
|
|
2412
|
+
return null;
|
|
2413
|
+
}
|
|
2414
|
+
if (prop.includes('background')) {
|
|
2415
|
+
if (rule.style.webkitMaskImage ||
|
|
2416
|
+
rule.style.webkitMask ||
|
|
2417
|
+
rule.style.mask ||
|
|
2418
|
+
rule.style.getPropertyValue('mask-image')) {
|
|
2419
|
+
return function (filter) { return modifyForegroundColor(rgb, filter); };
|
|
2418
2420
|
}
|
|
2419
|
-
return function (filter) { return
|
|
2421
|
+
return function (filter) { return modifyBackgroundColor(rgb, filter); };
|
|
2420
2422
|
}
|
|
2421
|
-
|
|
2422
|
-
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
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 =
|
|
3259
|
+
var rgb = parseColorWithCache(newColor);
|
|
3238
3260
|
if (rgb) {
|
|
3239
3261
|
var outputColor = modifyFunction(rgb, theme);
|
|
3240
3262
|
if (isRaw) {
|
|
3241
|
-
var outputInRGB =
|
|
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
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
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);
|
|
@@ -3931,6 +3951,7 @@
|
|
|
3931
3951
|
(element instanceof HTMLLinkElement &&
|
|
3932
3952
|
element.rel &&
|
|
3933
3953
|
element.rel.toLowerCase().includes('stylesheet') &&
|
|
3954
|
+
element.href &&
|
|
3934
3955
|
!element.disabled &&
|
|
3935
3956
|
(isFirefox ? !element.href.startsWith('moz-extension://') : true) &&
|
|
3936
3957
|
!isFontsGoogleApiStyle(element))) &&
|
|
@@ -4008,26 +4029,20 @@
|
|
|
4008
4029
|
}
|
|
4009
4030
|
function getRulesSync() {
|
|
4010
4031
|
if (corsCopy) {
|
|
4011
|
-
logInfo('[getRulesSync] Using cors-copy.');
|
|
4012
4032
|
return corsCopy.sheet.cssRules;
|
|
4013
4033
|
}
|
|
4014
4034
|
if (containsCSSImport()) {
|
|
4015
|
-
logInfo('[getRulesSync] CSSImport detected.');
|
|
4016
4035
|
return null;
|
|
4017
4036
|
}
|
|
4018
4037
|
var cssRules = safeGetSheetRules();
|
|
4019
4038
|
if (element instanceof HTMLLinkElement &&
|
|
4020
4039
|
!isRelativeHrefOnAbsolutePath(element.href) &&
|
|
4021
4040
|
hasImports(cssRules, false)) {
|
|
4022
|
-
logInfo('[getRulesSync] CSSImportRule detected on non-local href.');
|
|
4023
4041
|
return null;
|
|
4024
4042
|
}
|
|
4025
4043
|
if (hasImports(cssRules, true)) {
|
|
4026
|
-
logInfo('[getRulesSync] Cross-Origin CSSImportRule detected.');
|
|
4027
4044
|
return null;
|
|
4028
4045
|
}
|
|
4029
|
-
logInfo('[getRulesSync] Using cssRules.');
|
|
4030
|
-
!cssRules && logWarn('[getRulesSync] cssRules is null, trying again.');
|
|
4031
4046
|
return cssRules;
|
|
4032
4047
|
}
|
|
4033
4048
|
function insertStyle() {
|
|
@@ -4060,30 +4075,25 @@
|
|
|
4060
4075
|
var loadingLinkId = ++loadingLinkCounter;
|
|
4061
4076
|
function getRulesAsync() {
|
|
4062
4077
|
return __awaiter(this, void 0, void 0, function () {
|
|
4063
|
-
var cssText, cssBasePath, _a, cssRules, accessError,
|
|
4078
|
+
var cssText, cssBasePath, _a, cssRules, accessError, fullCSSText;
|
|
4064
4079
|
var _b;
|
|
4065
4080
|
return __generator(this, function (_c) {
|
|
4066
4081
|
switch (_c.label) {
|
|
4067
4082
|
case 0:
|
|
4068
4083
|
if (!(element instanceof HTMLLinkElement)) return [3, 7];
|
|
4069
4084
|
_a = __read(getRulesOrError(), 2), cssRules = _a[0], accessError = _a[1];
|
|
4070
|
-
if (accessError) {
|
|
4071
|
-
logWarn(accessError);
|
|
4072
|
-
}
|
|
4073
4085
|
if (!((!cssRules && !accessError && !isSafari) ||
|
|
4074
4086
|
(isSafari && !element.sheet) ||
|
|
4075
4087
|
isStillLoadingError(accessError))) return [3, 5];
|
|
4076
4088
|
_c.label = 1;
|
|
4077
4089
|
case 1:
|
|
4078
4090
|
_c.trys.push([1, 3, , 4]);
|
|
4079
|
-
logInfo("Linkelement ".concat(loadingLinkId, " is not loaded yet and thus will be await for"), element);
|
|
4080
4091
|
return [4, linkLoading(element, loadingLinkId)];
|
|
4081
4092
|
case 2:
|
|
4082
4093
|
_c.sent();
|
|
4083
4094
|
return [3, 4];
|
|
4084
4095
|
case 3:
|
|
4085
|
-
|
|
4086
|
-
logWarn(err_1);
|
|
4096
|
+
_c.sent();
|
|
4087
4097
|
wasLoadingError = true;
|
|
4088
4098
|
return [3, 4];
|
|
4089
4099
|
case 4:
|
|
@@ -4091,9 +4101,6 @@
|
|
|
4091
4101
|
return [2, null];
|
|
4092
4102
|
}
|
|
4093
4103
|
_b = __read(getRulesOrError(), 2), cssRules = _b[0], accessError = _b[1];
|
|
4094
|
-
if (accessError) {
|
|
4095
|
-
logWarn(accessError);
|
|
4096
|
-
}
|
|
4097
4104
|
_c.label = 5;
|
|
4098
4105
|
case 5:
|
|
4099
4106
|
if (cssRules) {
|
|
@@ -4129,8 +4136,7 @@
|
|
|
4129
4136
|
corsCopy = createCORSCopy(element, fullCSSText);
|
|
4130
4137
|
return [3, 12];
|
|
4131
4138
|
case 11:
|
|
4132
|
-
|
|
4133
|
-
logWarn(err_2);
|
|
4139
|
+
_c.sent();
|
|
4134
4140
|
return [3, 12];
|
|
4135
4141
|
case 12:
|
|
4136
4142
|
if (corsCopy) {
|
|
@@ -4147,7 +4153,6 @@
|
|
|
4147
4153
|
var rules = getRulesSync();
|
|
4148
4154
|
if (!rules) {
|
|
4149
4155
|
if (options.secondRound) {
|
|
4150
|
-
logWarn('Detected dead-lock at details(), returning early to prevent it.');
|
|
4151
4156
|
return null;
|
|
4152
4157
|
}
|
|
4153
4158
|
if (isLoadingRules || wasLoadingError) {
|
|
@@ -4162,7 +4167,6 @@
|
|
|
4162
4167
|
update();
|
|
4163
4168
|
}
|
|
4164
4169
|
}).catch(function (err) {
|
|
4165
|
-
logWarn(err);
|
|
4166
4170
|
isLoadingRules = false;
|
|
4167
4171
|
loadingEnd();
|
|
4168
4172
|
});
|
|
@@ -4239,7 +4243,6 @@
|
|
|
4239
4243
|
function safeGetSheetRules() {
|
|
4240
4244
|
var _a = __read(getRulesOrError(), 2), cssRules = _a[0], err = _a[1];
|
|
4241
4245
|
if (err) {
|
|
4242
|
-
logWarn(err);
|
|
4243
4246
|
return null;
|
|
4244
4247
|
}
|
|
4245
4248
|
return cssRules;
|
|
@@ -4342,10 +4345,8 @@
|
|
|
4342
4345
|
}
|
|
4343
4346
|
moveCount++;
|
|
4344
4347
|
if (moveCount > maxMoveCount) {
|
|
4345
|
-
logWarn('Style sheet was moved multiple times', element);
|
|
4346
4348
|
return;
|
|
4347
4349
|
}
|
|
4348
|
-
logWarn('Restore style', syncStyle, element);
|
|
4349
4350
|
insertStyle();
|
|
4350
4351
|
corsCopyPositionWatcher && corsCopyPositionWatcher.skip();
|
|
4351
4352
|
syncStylePositionWatcher && syncStylePositionWatcher.skip();
|
|
@@ -4374,7 +4375,6 @@
|
|
|
4374
4375
|
};
|
|
4375
4376
|
var onLoad = function () {
|
|
4376
4377
|
cleanUp();
|
|
4377
|
-
logInfo("Linkelement ".concat(loadingId, " has been loaded"));
|
|
4378
4378
|
resolve();
|
|
4379
4379
|
};
|
|
4380
4380
|
var onError = function () {
|
|
@@ -4415,7 +4415,7 @@
|
|
|
4415
4415
|
function replaceCSSImports(cssText, basePath, cache) {
|
|
4416
4416
|
if (cache === void 0) { cache = new Map(); }
|
|
4417
4417
|
return __awaiter(this, void 0, void 0, function () {
|
|
4418
|
-
var importMatches, importMatches_1, importMatches_1_1, match, importURL, absoluteURL, importedCSS,
|
|
4418
|
+
var importMatches, importMatches_1, importMatches_1_1, match, importURL, absoluteURL, importedCSS, e_1_1;
|
|
4419
4419
|
var e_1, _a;
|
|
4420
4420
|
return __generator(this, function (_b) {
|
|
4421
4421
|
switch (_b.label) {
|
|
@@ -4449,8 +4449,7 @@
|
|
|
4449
4449
|
importedCSS = _b.sent();
|
|
4450
4450
|
return [3, 7];
|
|
4451
4451
|
case 6:
|
|
4452
|
-
|
|
4453
|
-
logWarn(err_3);
|
|
4452
|
+
_b.sent();
|
|
4454
4453
|
importedCSS = '';
|
|
4455
4454
|
return [3, 7];
|
|
4456
4455
|
case 7:
|
|
@@ -4674,7 +4673,7 @@
|
|
|
4674
4673
|
onHugeMutations: handleHugeTreeMutations,
|
|
4675
4674
|
});
|
|
4676
4675
|
var attrObserver = new MutationObserver(handleAttributeMutations);
|
|
4677
|
-
attrObserver.observe(root, { attributes: true, attributeFilter: ['rel', 'disabled', 'media'], subtree: true });
|
|
4676
|
+
attrObserver.observe(root, { attributes: true, attributeFilter: ['rel', 'disabled', 'media', 'href'], subtree: true });
|
|
4678
4677
|
observers.push(treeObserver, attrObserver);
|
|
4679
4678
|
observedRoots.add(root);
|
|
4680
4679
|
}
|
|
@@ -4997,8 +4996,8 @@
|
|
|
4997
4996
|
var darkSchemeBackgroundColor = filter.darkSchemeBackgroundColor, darkSchemeTextColor = filter.darkSchemeTextColor, lightSchemeBackgroundColor = filter.lightSchemeBackgroundColor, lightSchemeTextColor = filter.lightSchemeTextColor, mode = filter.mode;
|
|
4998
4997
|
var schemeBackgroundColor = mode === 0 ? lightSchemeBackgroundColor : darkSchemeBackgroundColor;
|
|
4999
4998
|
var schemeTextColor = mode === 0 ? lightSchemeTextColor : darkSchemeTextColor;
|
|
5000
|
-
schemeBackgroundColor = modifyBackgroundColor(
|
|
5001
|
-
schemeTextColor = modifyForegroundColor(
|
|
4999
|
+
schemeBackgroundColor = modifyBackgroundColor(parseColorWithCache(schemeBackgroundColor), filter);
|
|
5000
|
+
schemeTextColor = modifyForegroundColor(parseColorWithCache(schemeTextColor), filter);
|
|
5002
5001
|
variableStyle.textContent = [
|
|
5003
5002
|
":root {",
|
|
5004
5003
|
" --darkreader-neutral-background: ".concat(schemeBackgroundColor, ";"),
|
|
@@ -5011,10 +5010,13 @@
|
|
|
5011
5010
|
setupNodePositionWatcher(variableStyle, 'variables');
|
|
5012
5011
|
var rootVarsStyle = createOrUpdateStyle('darkreader--root-vars');
|
|
5013
5012
|
document.head.insertBefore(rootVarsStyle, variableStyle.nextSibling);
|
|
5014
|
-
var
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
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
|
+
}
|
|
5018
5020
|
}
|
|
5019
5021
|
var shadowRootsWithOverrides = new Set();
|
|
5020
5022
|
function createShadowStaticStyleOverrides(root) {
|
|
@@ -5040,11 +5042,10 @@
|
|
|
5040
5042
|
}
|
|
5041
5043
|
function replaceCSSTemplates($cssText) {
|
|
5042
5044
|
return $cssText.replace(/\${(.+?)}/g, function (_, $color) {
|
|
5043
|
-
var color =
|
|
5045
|
+
var color = parseColorWithCache($color);
|
|
5044
5046
|
if (color) {
|
|
5045
5047
|
return modifyColor(color, filter);
|
|
5046
5048
|
}
|
|
5047
|
-
logWarn("Couldn't parse CSSTemplate's color.");
|
|
5048
5049
|
return $color;
|
|
5049
5050
|
});
|
|
5050
5051
|
}
|
|
@@ -5091,7 +5092,6 @@
|
|
|
5091
5092
|
var loadingStyles = new Set();
|
|
5092
5093
|
function createManager(element) {
|
|
5093
5094
|
var loadingStyleId = ++loadingStylesCounter;
|
|
5094
|
-
logInfo("New manager for element, with loadingStyleID ".concat(loadingStyleId), element);
|
|
5095
5095
|
function loadingStart() {
|
|
5096
5096
|
if (!isDOMReady() || !didDocumentShowUp) {
|
|
5097
5097
|
loadingStyles.add(loadingStyleId);
|
|
@@ -5105,7 +5105,6 @@
|
|
|
5105
5105
|
function loadingEnd() {
|
|
5106
5106
|
loadingStyles.delete(loadingStyleId);
|
|
5107
5107
|
logInfo("Removed loadingStyle ".concat(loadingStyleId, ", now awaiting: ").concat(loadingStyles.size));
|
|
5108
|
-
logInfo("To-do to be loaded", loadingStyles);
|
|
5109
5108
|
if (loadingStyles.size === 0 && isDOMReady()) {
|
|
5110
5109
|
cleanFallbackStyle();
|
|
5111
5110
|
}
|
|
@@ -5143,7 +5142,6 @@
|
|
|
5143
5142
|
cleanFallbackStyle();
|
|
5144
5143
|
return;
|
|
5145
5144
|
}
|
|
5146
|
-
logWarn("DOM is ready, but still have styles being loaded.", loadingStyles);
|
|
5147
5145
|
}
|
|
5148
5146
|
var documentVisibilityListener = null;
|
|
5149
5147
|
var didDocumentShowUp = !document.hidden;
|
|
@@ -5189,7 +5187,6 @@
|
|
|
5189
5187
|
}
|
|
5190
5188
|
}
|
|
5191
5189
|
catch (err) {
|
|
5192
|
-
logWarn('Error occured in handleAdoptedStyleSheets: ', err);
|
|
5193
5190
|
}
|
|
5194
5191
|
}
|
|
5195
5192
|
function watchForUpdates() {
|
|
@@ -5201,7 +5198,6 @@
|
|
|
5201
5198
|
.filter(function (style) { return !styleManagers.has(style); });
|
|
5202
5199
|
var stylesToRestore = moved
|
|
5203
5200
|
.filter(function (style) { return styleManagers.has(style); });
|
|
5204
|
-
logInfo("Styles to be removed:", stylesToRemove);
|
|
5205
5201
|
stylesToRemove.forEach(function (style) { return removeManager(style); });
|
|
5206
5202
|
var newManagers = stylesToManage
|
|
5207
5203
|
.map(function (style) { return createManager(style); });
|
|
@@ -5245,6 +5241,16 @@
|
|
|
5245
5241
|
removeDOMReadyListener(onDOMReady);
|
|
5246
5242
|
cleanReadyStateCompleteListeners();
|
|
5247
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
|
+
}
|
|
5248
5254
|
function createDarkReaderInstanceMarker() {
|
|
5249
5255
|
var metaElement = document.createElement('meta');
|
|
5250
5256
|
metaElement.name = 'darkreader';
|
|
@@ -5252,6 +5258,9 @@
|
|
|
5252
5258
|
document.head.appendChild(metaElement);
|
|
5253
5259
|
}
|
|
5254
5260
|
function isAnotherDarkReaderInstanceActive() {
|
|
5261
|
+
if (document.querySelector('meta[name="darkreader-lock"]')) {
|
|
5262
|
+
return true;
|
|
5263
|
+
}
|
|
5255
5264
|
var meta = document.querySelector('meta[name="darkreader"]');
|
|
5256
5265
|
if (meta) {
|
|
5257
5266
|
if (meta.content !== INSTANCE_ID) {
|
|
@@ -5260,6 +5269,7 @@
|
|
|
5260
5269
|
return false;
|
|
5261
5270
|
}
|
|
5262
5271
|
createDarkReaderInstanceMarker();
|
|
5272
|
+
addMetaListener();
|
|
5263
5273
|
return false;
|
|
5264
5274
|
}
|
|
5265
5275
|
function createOrUpdateDynamicTheme(filterConfig, dynamicThemeFixes, iframe) {
|
|
@@ -5340,6 +5350,7 @@
|
|
|
5340
5350
|
manager.destroy();
|
|
5341
5351
|
});
|
|
5342
5352
|
adoptedStyleManagers.splice(0);
|
|
5353
|
+
metaObserver && metaObserver.disconnect();
|
|
5343
5354
|
}
|
|
5344
5355
|
function cleanDynamicThemeCache() {
|
|
5345
5356
|
variablesStore.clear();
|
|
@@ -5348,6 +5359,7 @@
|
|
|
5348
5359
|
cancelRendering();
|
|
5349
5360
|
stopWatchingForUpdates();
|
|
5350
5361
|
cleanModificationCache();
|
|
5362
|
+
clearColorCache();
|
|
5351
5363
|
}
|
|
5352
5364
|
|
|
5353
5365
|
var blobRegex = /url\(\"(blob\:.*?)\"\)/g;
|
|
@@ -5370,7 +5382,7 @@
|
|
|
5370
5382
|
});
|
|
5371
5383
|
});
|
|
5372
5384
|
}
|
|
5373
|
-
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/
|
|
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";
|
|
5374
5386
|
function collectCSS() {
|
|
5375
5387
|
return __awaiter(this, void 0, void 0, function () {
|
|
5376
5388
|
function addStaticCSS(selector, comment) {
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "darkreader",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.53",
|
|
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,15 +16,15 @@
|
|
|
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.
|
|
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.
|
|
23
|
-
"test:firefox": " npm run debug && jest --config=tests/browser/jest.config.firefox.
|
|
24
|
-
"test:inject": "node --max-old-space-size=3072 node_modules/.bin/karma start ./tests/inject/karma.conf.
|
|
25
|
-
"test:inject:debug": "node --max-old-space-size=3072 node_modules/.bin/karma start ./tests/inject/karma.conf.
|
|
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.
|
|
28
|
-
"test:unit:debug": "node --inspect-brk ./node_modules/jest/bin/jest --config=tests/unit/jest.config.
|
|
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",
|
|
29
28
|
"test:update-snapshots": "npm run test -- --updateSnapshot && npm run test:project -- --updateSnapshot",
|
|
30
29
|
"translate-line": "node ./tasks/translate.js --line"
|
|
31
30
|
},
|
|
@@ -54,49 +53,49 @@
|
|
|
54
53
|
"url": "https://opencollective.com/darkreader/donate"
|
|
55
54
|
},
|
|
56
55
|
"devDependencies": {
|
|
57
|
-
"@rollup/plugin-node-resolve": "13.
|
|
56
|
+
"@rollup/plugin-node-resolve": "13.3.0",
|
|
58
57
|
"@rollup/plugin-replace": "4.0.0",
|
|
59
|
-
"@rollup/plugin-typescript": "8.3.
|
|
60
|
-
"@rollup/pluginutils": "4.2.
|
|
61
|
-
"@types/chrome": "0.0.
|
|
62
|
-
"@types/eslint": "8.4.
|
|
63
|
-
"@types/jasmine": "4.0.
|
|
64
|
-
"@types/jest": "
|
|
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",
|
|
65
64
|
"@types/karma": "6.3.3",
|
|
66
65
|
"@types/karma-coverage": "2.0.1",
|
|
67
|
-
"@types/node": "
|
|
68
|
-
"@types/offscreencanvas": "2019.
|
|
69
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
70
|
-
"@typescript-eslint/parser": "5.
|
|
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",
|
|
71
70
|
"chokidar": "3.5.3",
|
|
72
|
-
"eslint": "8.
|
|
71
|
+
"eslint": "8.21.0",
|
|
73
72
|
"eslint-plugin-compat": "4.0.2",
|
|
74
|
-
"eslint-plugin-import": "2.
|
|
73
|
+
"eslint-plugin-import": "2.26.0",
|
|
75
74
|
"eslint-plugin-local": "1.0.0",
|
|
76
75
|
"get-stream": "6.0.1",
|
|
77
|
-
"globby": "13.1.
|
|
78
|
-
"jasmine-core": "4.0
|
|
79
|
-
"jest": "
|
|
80
|
-
"jest-extended": "
|
|
81
|
-
"karma": "6.
|
|
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",
|
|
82
81
|
"karma-chrome-launcher": "3.1.1",
|
|
83
82
|
"karma-coverage": "2.2.0",
|
|
84
83
|
"karma-firefox-launcher": "2.1.2",
|
|
85
|
-
"karma-jasmine": "
|
|
84
|
+
"karma-jasmine": "5.1.0",
|
|
86
85
|
"karma-rollup-preprocessor": "7.0.8",
|
|
87
86
|
"karma-safari-launcher": "1.0.0",
|
|
88
|
-
"karma-spec-reporter": "0.0.
|
|
89
|
-
"less": "4.1.
|
|
87
|
+
"karma-spec-reporter": "0.0.34",
|
|
88
|
+
"less": "4.1.3",
|
|
90
89
|
"malevic": "0.19.1",
|
|
91
|
-
"prettier": "2.
|
|
92
|
-
"puppeteer-core": "
|
|
93
|
-
"rollup": "2.
|
|
90
|
+
"prettier": "2.7.1",
|
|
91
|
+
"puppeteer-core": "16.0.0",
|
|
92
|
+
"rollup": "2.77.2",
|
|
94
93
|
"rollup-plugin-istanbul2": "2.0.2",
|
|
95
|
-
"ts-jest": "
|
|
96
|
-
"tslib": "2.
|
|
97
|
-
"typescript": "4.
|
|
98
|
-
"web-ext": "
|
|
99
|
-
"ws": "8.
|
|
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",
|
|
100
99
|
"yazl": "2.5.1"
|
|
101
100
|
}
|
|
102
101
|
}
|