darkreader 4.9.46 → 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 +10 -11
- package/darkreader.js +417 -379
- package/package.json +40 -39
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,49 +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
|
-
|
|
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 = {}));
|
|
155
158
|
|
|
156
|
-
var
|
|
157
|
-
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';
|
|
158
166
|
var isChromium = userAgent.includes('chrome') || userAgent.includes('chromium');
|
|
159
167
|
var isThunderbird = userAgent.includes('thunderbird');
|
|
160
168
|
var isFirefox = userAgent.includes('firefox') || userAgent.includes('librewolf') || isThunderbird;
|
|
@@ -165,12 +173,19 @@
|
|
|
165
173
|
var isSafari = userAgent.includes('safari') && !isChromium;
|
|
166
174
|
var isWindows = platform.startsWith('win');
|
|
167
175
|
var isMacOS = platform.startsWith('mac');
|
|
168
|
-
userAgent.includes('mobile');
|
|
176
|
+
(isNavigatorDefined && navigator.userAgentData) ? navigator.userAgentData.mobile : userAgent.includes('mobile');
|
|
169
177
|
var isShadowDomSupported = typeof ShadowRoot === 'function';
|
|
170
178
|
var isMatchMediaChangeEventListenerSupported = (typeof MediaQueryList === 'function' &&
|
|
171
179
|
typeof MediaQueryList.prototype.addEventListener === 'function');
|
|
172
180
|
((function () {
|
|
173
|
-
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)(?:\/| )([^ ]+)/);
|
|
174
189
|
if (m && m[1]) {
|
|
175
190
|
return m[1];
|
|
176
191
|
}
|
|
@@ -185,14 +200,13 @@
|
|
|
185
200
|
return false;
|
|
186
201
|
}
|
|
187
202
|
})();
|
|
188
|
-
globalThis.chrome && globalThis.chrome.runtime && globalThis.chrome.runtime.getManifest && globalThis.chrome.runtime.getManifest().manifest_version === 3;
|
|
189
203
|
var isCSSColorSchemePropSupported = (function () {
|
|
190
204
|
if (typeof document === 'undefined') {
|
|
191
205
|
return false;
|
|
192
206
|
}
|
|
193
207
|
var el = document.createElement('div');
|
|
194
208
|
el.setAttribute('style', 'color-scheme: dark');
|
|
195
|
-
return el.style.colorScheme === 'dark';
|
|
209
|
+
return el.style && el.style.colorScheme === 'dark';
|
|
196
210
|
})();
|
|
197
211
|
|
|
198
212
|
function getOKResponse(url, mimeType, origin) {
|
|
@@ -455,16 +469,8 @@
|
|
|
455
469
|
}
|
|
456
470
|
|
|
457
471
|
function logInfo() {
|
|
458
|
-
var args = [];
|
|
459
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
460
|
-
args[_i] = arguments[_i];
|
|
461
|
-
}
|
|
462
472
|
}
|
|
463
473
|
function logWarn() {
|
|
464
|
-
var args = [];
|
|
465
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
466
|
-
args[_i] = arguments[_i];
|
|
467
|
-
}
|
|
468
474
|
}
|
|
469
475
|
|
|
470
476
|
function throttle(callback) {
|
|
@@ -569,7 +575,6 @@
|
|
|
569
575
|
}
|
|
570
576
|
else if (attempts >= MAX_ATTEMPTS_COUNT) {
|
|
571
577
|
if (now - start < ATTEMPTS_INTERVAL) {
|
|
572
|
-
logWarn("Node position watcher paused: retry in ".concat(RETRY_TIMEOUT, "ms"), node, prevSibling);
|
|
573
578
|
timeoutId = setTimeout(function () {
|
|
574
579
|
start = null;
|
|
575
580
|
attempts = 0;
|
|
@@ -583,23 +588,19 @@
|
|
|
583
588
|
}
|
|
584
589
|
if (mode === 'parent') {
|
|
585
590
|
if (prevSibling && prevSibling.parentNode !== parent) {
|
|
586
|
-
logWarn('Unable to restore node position: sibling parent changed', node, prevSibling, parent);
|
|
587
591
|
stop();
|
|
588
592
|
return;
|
|
589
593
|
}
|
|
590
594
|
}
|
|
591
595
|
if (mode === 'prev-sibling') {
|
|
592
596
|
if (prevSibling.parentNode == null) {
|
|
593
|
-
logWarn('Unable to restore node position: sibling was removed', node, prevSibling, parent);
|
|
594
597
|
stop();
|
|
595
598
|
return;
|
|
596
599
|
}
|
|
597
600
|
if (prevSibling.parentNode !== parent) {
|
|
598
|
-
logWarn('Style was moved to another parent', node, prevSibling, parent);
|
|
599
601
|
updateParent(prevSibling.parentNode);
|
|
600
602
|
}
|
|
601
603
|
}
|
|
602
|
-
logWarn('Restoring node position', node, prevSibling, parent);
|
|
603
604
|
parent.insertBefore(node, prevSibling ? prevSibling.nextSibling : parent.firstChild);
|
|
604
605
|
observer.takeRecords();
|
|
605
606
|
onRestore && onRestore();
|
|
@@ -654,7 +655,7 @@
|
|
|
654
655
|
}
|
|
655
656
|
var readyStateListeners = new Set();
|
|
656
657
|
function addDOMReadyListener(listener) {
|
|
657
|
-
readyStateListeners.add(listener);
|
|
658
|
+
isDOMReady() ? listener() : readyStateListeners.add(listener);
|
|
658
659
|
}
|
|
659
660
|
function removeDOMReadyListener(listener) {
|
|
660
661
|
readyStateListeners.delete(listener);
|
|
@@ -664,7 +665,7 @@
|
|
|
664
665
|
}
|
|
665
666
|
var readyStateCompleteListeners = new Set();
|
|
666
667
|
function addReadyStateCompleteListener(listener) {
|
|
667
|
-
readyStateCompleteListeners.add(listener);
|
|
668
|
+
isReadyStateComplete() ? listener() : readyStateCompleteListeners.add(listener);
|
|
668
669
|
}
|
|
669
670
|
function cleanReadyStateCompleteListeners() {
|
|
670
671
|
readyStateCompleteListeners.clear();
|
|
@@ -924,10 +925,10 @@
|
|
|
924
925
|
}
|
|
925
926
|
}
|
|
926
927
|
}
|
|
927
|
-
var cssURLRegex = /url\((('
|
|
928
|
+
var cssURLRegex = /url\((('.*?')|(".*?")|([^\)]*?))\)/g;
|
|
928
929
|
var cssImportRegex = /@import\s*(url\()?(('.+?')|(".+?")|([^\)]*?))\)? ?(screen)?;?/gi;
|
|
929
930
|
function getCSSURLValue(cssURL) {
|
|
930
|
-
return cssURL.replace(/^url\((.*)\)$/, '$1').trim().replace(/^"(.*)"$/, '$1').replace(/^'(.*)'$/, '$1');
|
|
931
|
+
return cssURL.trim().replace(/^url\((.*)\)$/, '$1').trim().replace(/^"(.*)"$/, '$1').replace(/^'(.*)'$/, '$1').replace(/(?:\\(.))/g, '$1');
|
|
931
932
|
}
|
|
932
933
|
function getCSSBaseBath(url) {
|
|
933
934
|
var cssURL = parseURL(url);
|
|
@@ -940,7 +941,6 @@
|
|
|
940
941
|
return "url(\"".concat(getAbsoluteURL(cssBasePath, pathValue), "\")");
|
|
941
942
|
}
|
|
942
943
|
catch (err) {
|
|
943
|
-
logWarn('Not able to replace relative URL with Absolute URL, skipping');
|
|
944
944
|
return match;
|
|
945
945
|
}
|
|
946
946
|
});
|
|
@@ -954,6 +954,189 @@
|
|
|
954
954
|
return $css.replace(fontFaceRegex, '');
|
|
955
955
|
}
|
|
956
956
|
|
|
957
|
+
function evalMath(expression) {
|
|
958
|
+
var rpnStack = [];
|
|
959
|
+
var workingStack = [];
|
|
960
|
+
var lastToken;
|
|
961
|
+
for (var i = 0, len = expression.length; i < len; i++) {
|
|
962
|
+
var token = expression[i];
|
|
963
|
+
if (!token || token === ' ') {
|
|
964
|
+
continue;
|
|
965
|
+
}
|
|
966
|
+
if (operators.has(token)) {
|
|
967
|
+
var op = operators.get(token);
|
|
968
|
+
while (workingStack.length) {
|
|
969
|
+
var currentOp = operators.get(workingStack[0]);
|
|
970
|
+
if (!currentOp) {
|
|
971
|
+
break;
|
|
972
|
+
}
|
|
973
|
+
if (op.lessOrEqualThan(currentOp)) {
|
|
974
|
+
rpnStack.push(workingStack.shift());
|
|
975
|
+
}
|
|
976
|
+
else {
|
|
977
|
+
break;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
workingStack.unshift(token);
|
|
981
|
+
}
|
|
982
|
+
else if (!lastToken || operators.has(lastToken)) {
|
|
983
|
+
rpnStack.push(token);
|
|
984
|
+
}
|
|
985
|
+
else {
|
|
986
|
+
rpnStack[rpnStack.length - 1] += token;
|
|
987
|
+
}
|
|
988
|
+
lastToken = token;
|
|
989
|
+
}
|
|
990
|
+
rpnStack.push.apply(rpnStack, __spreadArray([], __read(workingStack), false));
|
|
991
|
+
var stack = [];
|
|
992
|
+
for (var i = 0, len = rpnStack.length; i < len; i++) {
|
|
993
|
+
var op = operators.get(rpnStack[i]);
|
|
994
|
+
if (op) {
|
|
995
|
+
var args = stack.splice(0, 2);
|
|
996
|
+
stack.push(op.exec(args[1], args[0]));
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
stack.unshift(parseFloat(rpnStack[i]));
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return stack[0];
|
|
1003
|
+
}
|
|
1004
|
+
var Operator = (function () {
|
|
1005
|
+
function Operator(precedence, method) {
|
|
1006
|
+
this.precendce = precedence;
|
|
1007
|
+
this.execMethod = method;
|
|
1008
|
+
}
|
|
1009
|
+
Operator.prototype.exec = function (left, right) {
|
|
1010
|
+
return this.execMethod(left, right);
|
|
1011
|
+
};
|
|
1012
|
+
Operator.prototype.lessOrEqualThan = function (op) {
|
|
1013
|
+
return this.precendce <= op.precendce;
|
|
1014
|
+
};
|
|
1015
|
+
return Operator;
|
|
1016
|
+
}());
|
|
1017
|
+
var operators = new Map([
|
|
1018
|
+
['+', new Operator(1, function (left, right) { return left + right; })],
|
|
1019
|
+
['-', new Operator(1, function (left, right) { return left - right; })],
|
|
1020
|
+
['*', new Operator(2, function (left, right) { return left * right; })],
|
|
1021
|
+
['/', new Operator(2, function (left, right) { return left / right; })],
|
|
1022
|
+
]);
|
|
1023
|
+
|
|
1024
|
+
function getMatches(regex, input, group) {
|
|
1025
|
+
if (group === void 0) { group = 0; }
|
|
1026
|
+
var matches = [];
|
|
1027
|
+
var m;
|
|
1028
|
+
while ((m = regex.exec(input))) {
|
|
1029
|
+
matches.push(m[group]);
|
|
1030
|
+
}
|
|
1031
|
+
return matches;
|
|
1032
|
+
}
|
|
1033
|
+
function formatCSS(text) {
|
|
1034
|
+
function trimLeft(text) {
|
|
1035
|
+
return text.replace(/^\s+/, '');
|
|
1036
|
+
}
|
|
1037
|
+
function getIndent(depth) {
|
|
1038
|
+
if (depth === 0) {
|
|
1039
|
+
return '';
|
|
1040
|
+
}
|
|
1041
|
+
return ' '.repeat(4 * depth);
|
|
1042
|
+
}
|
|
1043
|
+
if (text.length < 50000) {
|
|
1044
|
+
var emptyRuleRegexp = /[^{}]+{\s*}/;
|
|
1045
|
+
while (emptyRuleRegexp.test(text)) {
|
|
1046
|
+
text = text.replace(emptyRuleRegexp, '');
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
var css = (text
|
|
1050
|
+
.replace(/\s{2,}/g, ' ')
|
|
1051
|
+
.replace(/\{/g, '{\n')
|
|
1052
|
+
.replace(/\}/g, '\n}\n')
|
|
1053
|
+
.replace(/\;(?![^\(|\"]*(\)|\"))/g, ';\n')
|
|
1054
|
+
.replace(/\,(?![^\(|\"]*(\)|\"))/g, ',\n')
|
|
1055
|
+
.replace(/\n\s*\n/g, '\n')
|
|
1056
|
+
.split('\n'));
|
|
1057
|
+
var depth = 0;
|
|
1058
|
+
var formatted = [];
|
|
1059
|
+
for (var x = 0, len = css.length; x < len; x++) {
|
|
1060
|
+
var line = "".concat(css[x], "\n");
|
|
1061
|
+
if (line.includes('{')) {
|
|
1062
|
+
formatted.push(getIndent(depth++) + trimLeft(line));
|
|
1063
|
+
}
|
|
1064
|
+
else if (line.includes('\}')) {
|
|
1065
|
+
formatted.push(getIndent(--depth) + trimLeft(line));
|
|
1066
|
+
}
|
|
1067
|
+
else {
|
|
1068
|
+
formatted.push(getIndent(depth) + trimLeft(line));
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return formatted.join('').trim();
|
|
1072
|
+
}
|
|
1073
|
+
function getParenthesesRange(input, searchStartIndex) {
|
|
1074
|
+
if (searchStartIndex === void 0) { searchStartIndex = 0; }
|
|
1075
|
+
var length = input.length;
|
|
1076
|
+
var depth = 0;
|
|
1077
|
+
var firstOpenIndex = -1;
|
|
1078
|
+
for (var i = searchStartIndex; i < length; i++) {
|
|
1079
|
+
if (depth === 0) {
|
|
1080
|
+
var openIndex = input.indexOf('(', i);
|
|
1081
|
+
if (openIndex < 0) {
|
|
1082
|
+
break;
|
|
1083
|
+
}
|
|
1084
|
+
firstOpenIndex = openIndex;
|
|
1085
|
+
depth++;
|
|
1086
|
+
i = openIndex;
|
|
1087
|
+
}
|
|
1088
|
+
else {
|
|
1089
|
+
var closingIndex = input.indexOf(')', i);
|
|
1090
|
+
if (closingIndex < 0) {
|
|
1091
|
+
break;
|
|
1092
|
+
}
|
|
1093
|
+
var openIndex = input.indexOf('(', i);
|
|
1094
|
+
if (openIndex < 0 || closingIndex < openIndex) {
|
|
1095
|
+
depth--;
|
|
1096
|
+
if (depth === 0) {
|
|
1097
|
+
return { start: firstOpenIndex, end: closingIndex + 1 };
|
|
1098
|
+
}
|
|
1099
|
+
i = closingIndex;
|
|
1100
|
+
}
|
|
1101
|
+
else {
|
|
1102
|
+
depth++;
|
|
1103
|
+
i = openIndex;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
return null;
|
|
1108
|
+
}
|
|
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
|
+
}
|
|
957
1140
|
function hslToRGB(_a) {
|
|
958
1141
|
var h = _a.h, s = _a.s, l = _a.l, _b = _a.a, a = _b === void 0 ? 1 : _b;
|
|
959
1142
|
if (s === 0) {
|
|
@@ -1053,7 +1236,7 @@
|
|
|
1053
1236
|
if ($color === 'transparent') {
|
|
1054
1237
|
return { r: 0, g: 0, b: 0, a: 0 };
|
|
1055
1238
|
}
|
|
1056
|
-
|
|
1239
|
+
return null;
|
|
1057
1240
|
}
|
|
1058
1241
|
function getNumbers($color) {
|
|
1059
1242
|
var numbers = [];
|
|
@@ -1130,7 +1313,7 @@
|
|
|
1130
1313
|
return { r: r, g: g, b: b, a: a };
|
|
1131
1314
|
}
|
|
1132
1315
|
}
|
|
1133
|
-
|
|
1316
|
+
return null;
|
|
1134
1317
|
}
|
|
1135
1318
|
function getColorByName($color) {
|
|
1136
1319
|
var n = knownColors.get($color);
|
|
@@ -1150,69 +1333,21 @@
|
|
|
1150
1333
|
a: 1
|
|
1151
1334
|
};
|
|
1152
1335
|
}
|
|
1153
|
-
var isCharDigit = function (char) { return char >= '0' && char <= '9'; };
|
|
1154
|
-
var getAmountOfDigits = function (number) { return Math.floor(Math.log10(number)) + 1; };
|
|
1155
1336
|
function lowerCalcExpression(color) {
|
|
1156
1337
|
var searchIndex = 0;
|
|
1157
1338
|
var replaceBetweenIndices = function (start, end, replacement) {
|
|
1158
1339
|
color = color.substring(0, start) + replacement + color.substring(end);
|
|
1159
1340
|
};
|
|
1160
|
-
|
|
1161
|
-
var
|
|
1162
|
-
|
|
1163
|
-
var char = color[searchIndex + i];
|
|
1164
|
-
if (char === ' ') {
|
|
1165
|
-
break;
|
|
1166
|
-
}
|
|
1167
|
-
if (isCharDigit(char)) {
|
|
1168
|
-
resultNumber *= 10;
|
|
1169
|
-
resultNumber += Number(char);
|
|
1170
|
-
}
|
|
1171
|
-
else {
|
|
1172
|
-
break;
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
var lenDigits = getAmountOfDigits(resultNumber);
|
|
1176
|
-
searchIndex += lenDigits;
|
|
1177
|
-
var possibleType = color[searchIndex + 1];
|
|
1178
|
-
if (possibleType !== '%') {
|
|
1179
|
-
return;
|
|
1180
|
-
}
|
|
1181
|
-
searchIndex++;
|
|
1182
|
-
return resultNumber;
|
|
1183
|
-
};
|
|
1184
|
-
while ((searchIndex = color.indexOf('calc(')) !== 0) {
|
|
1185
|
-
var startIndex = searchIndex;
|
|
1186
|
-
searchIndex += 4;
|
|
1187
|
-
var firstNumber = getNumber();
|
|
1188
|
-
if (!firstNumber) {
|
|
1189
|
-
break;
|
|
1190
|
-
}
|
|
1191
|
-
if (color[searchIndex + 1] !== ' ') {
|
|
1192
|
-
break;
|
|
1193
|
-
}
|
|
1194
|
-
searchIndex++;
|
|
1195
|
-
var operation = color[searchIndex + 1];
|
|
1196
|
-
if (operation !== '+' && operation !== '-') {
|
|
1341
|
+
while ((searchIndex = color.indexOf('calc(')) !== -1) {
|
|
1342
|
+
var range = getParenthesesRange(color, searchIndex);
|
|
1343
|
+
if (!range) {
|
|
1197
1344
|
break;
|
|
1198
1345
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
var secondNumber = getNumber();
|
|
1205
|
-
if (!secondNumber) {
|
|
1206
|
-
break;
|
|
1207
|
-
}
|
|
1208
|
-
var replacement = void 0;
|
|
1209
|
-
if (operation === '+') {
|
|
1210
|
-
replacement = "".concat(firstNumber + secondNumber, "%");
|
|
1211
|
-
}
|
|
1212
|
-
else {
|
|
1213
|
-
replacement = "".concat(firstNumber - secondNumber, "%");
|
|
1214
|
-
}
|
|
1215
|
-
replaceBetweenIndices(startIndex, searchIndex + 2, replacement);
|
|
1346
|
+
var slice = color.slice(range.start + 1, range.end - 1);
|
|
1347
|
+
var includesPercentage = slice.includes('%');
|
|
1348
|
+
slice = slice.split('%').join('');
|
|
1349
|
+
var output = Math.round(evalMath(slice));
|
|
1350
|
+
replaceBetweenIndices(range.start - 4, range.end, output + (includesPercentage ? '%' : ''));
|
|
1216
1351
|
}
|
|
1217
1352
|
return color;
|
|
1218
1353
|
}
|
|
@@ -1425,92 +1560,6 @@
|
|
|
1425
1560
|
return result;
|
|
1426
1561
|
}
|
|
1427
1562
|
|
|
1428
|
-
function getMatches(regex, input, group) {
|
|
1429
|
-
if (group === void 0) { group = 0; }
|
|
1430
|
-
var matches = [];
|
|
1431
|
-
var m;
|
|
1432
|
-
while ((m = regex.exec(input))) {
|
|
1433
|
-
matches.push(m[group]);
|
|
1434
|
-
}
|
|
1435
|
-
return matches;
|
|
1436
|
-
}
|
|
1437
|
-
function formatCSS(text) {
|
|
1438
|
-
function trimLeft(text) {
|
|
1439
|
-
return text.replace(/^\s+/, '');
|
|
1440
|
-
}
|
|
1441
|
-
function getIndent(depth) {
|
|
1442
|
-
if (depth === 0) {
|
|
1443
|
-
return '';
|
|
1444
|
-
}
|
|
1445
|
-
return ' '.repeat(4 * depth);
|
|
1446
|
-
}
|
|
1447
|
-
if (text.length < 50000) {
|
|
1448
|
-
var emptyRuleRegexp = /[^{}]+{\s*}/;
|
|
1449
|
-
while (emptyRuleRegexp.test(text)) {
|
|
1450
|
-
text = text.replace(emptyRuleRegexp, '');
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
var css = (text
|
|
1454
|
-
.replace(/\s{2,}/g, ' ')
|
|
1455
|
-
.replace(/\{/g, '{\n')
|
|
1456
|
-
.replace(/\}/g, '\n}\n')
|
|
1457
|
-
.replace(/\;(?![^\(|\"]*(\)|\"))/g, ';\n')
|
|
1458
|
-
.replace(/\,(?![^\(|\"]*(\)|\"))/g, ',\n')
|
|
1459
|
-
.replace(/\n\s*\n/g, '\n')
|
|
1460
|
-
.split('\n'));
|
|
1461
|
-
var depth = 0;
|
|
1462
|
-
var formatted = [];
|
|
1463
|
-
for (var x = 0, len = css.length; x < len; x++) {
|
|
1464
|
-
var line = "".concat(css[x], "\n");
|
|
1465
|
-
if (line.includes('{')) {
|
|
1466
|
-
formatted.push(getIndent(depth++) + trimLeft(line));
|
|
1467
|
-
}
|
|
1468
|
-
else if (line.includes('\}')) {
|
|
1469
|
-
formatted.push(getIndent(--depth) + trimLeft(line));
|
|
1470
|
-
}
|
|
1471
|
-
else {
|
|
1472
|
-
formatted.push(getIndent(depth) + trimLeft(line));
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
return formatted.join('').trim();
|
|
1476
|
-
}
|
|
1477
|
-
function getParenthesesRange(input, searchStartIndex) {
|
|
1478
|
-
if (searchStartIndex === void 0) { searchStartIndex = 0; }
|
|
1479
|
-
var length = input.length;
|
|
1480
|
-
var depth = 0;
|
|
1481
|
-
var firstOpenIndex = -1;
|
|
1482
|
-
for (var i = searchStartIndex; i < length; i++) {
|
|
1483
|
-
if (depth === 0) {
|
|
1484
|
-
var openIndex = input.indexOf('(', i);
|
|
1485
|
-
if (openIndex < 0) {
|
|
1486
|
-
break;
|
|
1487
|
-
}
|
|
1488
|
-
firstOpenIndex = openIndex;
|
|
1489
|
-
depth++;
|
|
1490
|
-
i = openIndex;
|
|
1491
|
-
}
|
|
1492
|
-
else {
|
|
1493
|
-
var closingIndex = input.indexOf(')', i);
|
|
1494
|
-
if (closingIndex < 0) {
|
|
1495
|
-
break;
|
|
1496
|
-
}
|
|
1497
|
-
var openIndex = input.indexOf('(', i);
|
|
1498
|
-
if (openIndex < 0 || closingIndex < openIndex) {
|
|
1499
|
-
depth--;
|
|
1500
|
-
if (depth === 0) {
|
|
1501
|
-
return { start: firstOpenIndex, end: closingIndex + 1 };
|
|
1502
|
-
}
|
|
1503
|
-
i = closingIndex;
|
|
1504
|
-
}
|
|
1505
|
-
else {
|
|
1506
|
-
depth++;
|
|
1507
|
-
i = openIndex;
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
return null;
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
1563
|
function createFilterMatrix(config) {
|
|
1515
1564
|
var m = Matrix.identity();
|
|
1516
1565
|
if (config.sepia !== 0) {
|
|
@@ -1605,19 +1654,8 @@
|
|
|
1605
1654
|
return theme[prop];
|
|
1606
1655
|
}
|
|
1607
1656
|
var colorModificationCache = new Map();
|
|
1608
|
-
var colorParseCache$1 = new Map();
|
|
1609
|
-
function parseToHSLWithCache(color) {
|
|
1610
|
-
if (colorParseCache$1.has(color)) {
|
|
1611
|
-
return colorParseCache$1.get(color);
|
|
1612
|
-
}
|
|
1613
|
-
var rgb = parse(color);
|
|
1614
|
-
var hsl = rgbToHSL(rgb);
|
|
1615
|
-
colorParseCache$1.set(color, hsl);
|
|
1616
|
-
return hsl;
|
|
1617
|
-
}
|
|
1618
1657
|
function clearColorModificationCache() {
|
|
1619
1658
|
colorModificationCache.clear();
|
|
1620
|
-
colorParseCache$1.clear();
|
|
1621
1659
|
}
|
|
1622
1660
|
var rgbCacheKeys = ['r', 'g', 'b', 'a'];
|
|
1623
1661
|
var themeCacheKeys$1 = ['mode', 'brightness', 'contrast', 'grayscale', 'sepia', 'darkSchemeBackgroundColor', 'darkSchemeTextColor', 'lightSchemeBackgroundColor', 'lightSchemeTextColor'];
|
|
@@ -2035,7 +2073,6 @@
|
|
|
2035
2073
|
}
|
|
2036
2074
|
var size = naturalWidth * naturalHeight * 4;
|
|
2037
2075
|
if (size > MAX_IMAGE_SIZE) {
|
|
2038
|
-
logInfo('Skipped large image analyzing(Larger than 5mb in memory)');
|
|
2039
2076
|
return {
|
|
2040
2077
|
isDark: false,
|
|
2041
2078
|
isLight: false,
|
|
@@ -2148,11 +2185,13 @@
|
|
|
2148
2185
|
return "break";
|
|
2149
2186
|
}
|
|
2150
2187
|
var _a = getParenthesesRange(value, index + gradientLength), start = _a.start, end = _a.end;
|
|
2151
|
-
var
|
|
2188
|
+
var match = value.substring(start + 1, end - 1);
|
|
2152
2189
|
startIndex = end + 1 + conicGradientLength;
|
|
2153
2190
|
result.push({
|
|
2154
|
-
|
|
2155
|
-
|
|
2191
|
+
typeGradient: typeGradient,
|
|
2192
|
+
match: match,
|
|
2193
|
+
offset: typeGradient.length + 2,
|
|
2194
|
+
index: index - typeGradient.length + gradientLength,
|
|
2156
2195
|
hasComma: true,
|
|
2157
2196
|
});
|
|
2158
2197
|
};
|
|
@@ -2183,11 +2222,14 @@
|
|
|
2183
2222
|
return { property: property, value: modifier, important: getPriority(rule.style, property), sourceValue: value };
|
|
2184
2223
|
}
|
|
2185
2224
|
}
|
|
2225
|
+
else if (property === 'color-scheme') {
|
|
2226
|
+
return null;
|
|
2227
|
+
}
|
|
2186
2228
|
else if ((property.includes('color') && property !== '-webkit-print-color-adjust') ||
|
|
2187
2229
|
property === 'fill' ||
|
|
2188
2230
|
property === 'stroke' ||
|
|
2189
2231
|
property === 'stop-color') {
|
|
2190
|
-
var modifier = getColorModifier(property, value);
|
|
2232
|
+
var modifier = getColorModifier(property, value, rule);
|
|
2191
2233
|
if (modifier) {
|
|
2192
2234
|
return { property: property, value: modifier, important: getPriority(rule.style, property), sourceValue: value };
|
|
2193
2235
|
}
|
|
@@ -2266,7 +2308,7 @@
|
|
|
2266
2308
|
foregroundColorSelection = modifyForegroundColor({ r: 255, g: 255, b: 255 }, __assign(__assign({}, theme), { grayscale: 0 }));
|
|
2267
2309
|
}
|
|
2268
2310
|
else {
|
|
2269
|
-
var rgb =
|
|
2311
|
+
var rgb = parseColorWithCache(theme.selectionColor);
|
|
2270
2312
|
var hsl = rgbToHSL(rgb);
|
|
2271
2313
|
backgroundColorSelection = theme.selectionColor;
|
|
2272
2314
|
if (hsl.l < 0.5) {
|
|
@@ -2308,7 +2350,7 @@
|
|
|
2308
2350
|
colorCorner = modifyBackgroundColor({ r: 255, g: 255, b: 255 }, theme);
|
|
2309
2351
|
}
|
|
2310
2352
|
else {
|
|
2311
|
-
var rgb =
|
|
2353
|
+
var rgb = parseColorWithCache(theme.scrollbarColor);
|
|
2312
2354
|
var hsl_1 = rgbToHSL(rgb);
|
|
2313
2355
|
var isLight = hsl_1.l > 0.5;
|
|
2314
2356
|
var lighten = function (lighter) { return (__assign(__assign({}, hsl_1), { l: clamp(hsl_1.l + lighter, 0, 1) })); };
|
|
@@ -2345,7 +2387,7 @@
|
|
|
2345
2387
|
function getModifiedFallbackStyle(filter, _a) {
|
|
2346
2388
|
var strict = _a.strict;
|
|
2347
2389
|
var lines = [];
|
|
2348
|
-
var isMicrosoft =
|
|
2390
|
+
var isMicrosoft = ['microsoft.com', 'docs.microsoft.com'].includes(location.hostname);
|
|
2349
2391
|
lines.push("html, body, ".concat(strict ? "body :not(iframe)".concat(isMicrosoft ? ':not(div[style^="position:absolute;top:0;left:-"]' : '') : 'body > :not(iframe)', " {"));
|
|
2350
2392
|
lines.push(" background-color: ".concat(modifyBackgroundColor({ r: 255, g: 255, b: 255 }, filter), " !important;"));
|
|
2351
2393
|
lines.push(" border-color: ".concat(modifyBorderColor({ r: 64, g: 64, b: 64 }, filter), " !important;"));
|
|
@@ -2361,45 +2403,27 @@
|
|
|
2361
2403
|
'none',
|
|
2362
2404
|
'unset',
|
|
2363
2405
|
]);
|
|
2364
|
-
|
|
2365
|
-
function parseColorWithCache($color) {
|
|
2366
|
-
$color = $color.trim();
|
|
2367
|
-
if (colorParseCache.has($color)) {
|
|
2368
|
-
return colorParseCache.get($color);
|
|
2369
|
-
}
|
|
2370
|
-
if ($color.includes('calc(')) {
|
|
2371
|
-
$color = lowerCalcExpression($color);
|
|
2372
|
-
}
|
|
2373
|
-
var color = parse($color);
|
|
2374
|
-
colorParseCache.set($color, color);
|
|
2375
|
-
return color;
|
|
2376
|
-
}
|
|
2377
|
-
function tryParseColor($color) {
|
|
2378
|
-
try {
|
|
2379
|
-
return parseColorWithCache($color);
|
|
2380
|
-
}
|
|
2381
|
-
catch (err) {
|
|
2382
|
-
return null;
|
|
2383
|
-
}
|
|
2384
|
-
}
|
|
2385
|
-
function getColorModifier(prop, value) {
|
|
2406
|
+
function getColorModifier(prop, value, rule) {
|
|
2386
2407
|
if (unparsableColors.has(value.toLowerCase())) {
|
|
2387
2408
|
return value;
|
|
2388
2409
|
}
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
if (
|
|
2395
|
-
|
|
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); };
|
|
2396
2420
|
}
|
|
2397
|
-
return function (filter) { return
|
|
2421
|
+
return function (filter) { return modifyBackgroundColor(rgb, filter); };
|
|
2398
2422
|
}
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
return null;
|
|
2423
|
+
if (prop.includes('border') || prop.includes('outline')) {
|
|
2424
|
+
return function (filter) { return modifyBorderColor(rgb, filter); };
|
|
2402
2425
|
}
|
|
2426
|
+
return function (filter) { return modifyForegroundColor(rgb, filter); };
|
|
2403
2427
|
}
|
|
2404
2428
|
var imageDetailsCache = new Map();
|
|
2405
2429
|
var awaitingForImageLoading = new Map();
|
|
@@ -2440,28 +2464,27 @@
|
|
|
2440
2464
|
return { match: match, index: valueIndex };
|
|
2441
2465
|
});
|
|
2442
2466
|
};
|
|
2443
|
-
var matches_1 =
|
|
2444
|
-
.concat(
|
|
2467
|
+
var matches_1 = gradients.map(function (i) { return (__assign({ type: 'gradient' }, i)); })
|
|
2468
|
+
.concat(getIndices(urls).map(function (i) { return (__assign({ type: 'url', offset: 0 }, i)); }))
|
|
2469
|
+
.sort(function (a, b) { return a.index > b.index ? 1 : -1; });
|
|
2445
2470
|
var getGradientModifier_1 = function (gradient) {
|
|
2446
|
-
var
|
|
2447
|
-
var
|
|
2448
|
-
var hasComma = gradient.hasComma;
|
|
2449
|
-
var partsRegex = /([^\(\),]+(\([^\(\)]*(\([^\(\)]*\)*[^\(\)]*)?\))?[^\(\),]*),?/g;
|
|
2471
|
+
var typeGradient = gradient.typeGradient, match = gradient.match, hasComma = gradient.hasComma;
|
|
2472
|
+
var partsRegex = /([^\(\),]+(\([^\(\)]*(\([^\(\)]*\)*[^\(\)]*)?\))?([^\(\), ]|( (?!calc)))*),?/g;
|
|
2450
2473
|
var colorStopRegex = /^(from|color-stop|to)\(([^\(\)]*?,\s*)?(.*?)\)$/;
|
|
2451
|
-
var parts = getMatches(partsRegex,
|
|
2474
|
+
var parts = getMatches(partsRegex, match, 1).map(function (part) {
|
|
2452
2475
|
part = part.trim();
|
|
2453
|
-
var rgb =
|
|
2476
|
+
var rgb = parseColorWithCache(part);
|
|
2454
2477
|
if (rgb) {
|
|
2455
2478
|
return function (filter) { return modifyGradientColor(rgb, filter); };
|
|
2456
2479
|
}
|
|
2457
2480
|
var space = part.lastIndexOf(' ');
|
|
2458
|
-
rgb =
|
|
2481
|
+
rgb = parseColorWithCache(part.substring(0, space));
|
|
2459
2482
|
if (rgb) {
|
|
2460
2483
|
return function (filter) { return "".concat(modifyGradientColor(rgb, filter), " ").concat(part.substring(space + 1)); };
|
|
2461
2484
|
}
|
|
2462
2485
|
var colorStopMatch = part.match(colorStopRegex);
|
|
2463
2486
|
if (colorStopMatch) {
|
|
2464
|
-
rgb =
|
|
2487
|
+
rgb = parseColorWithCache(colorStopMatch[3]);
|
|
2465
2488
|
if (rgb) {
|
|
2466
2489
|
return function (filter) { return "".concat(colorStopMatch[1], "(").concat(colorStopMatch[2] ? "".concat(colorStopMatch[2], ", ") : '').concat(modifyGradientColor(rgb, filter), ")"); };
|
|
2467
2490
|
}
|
|
@@ -2469,7 +2492,7 @@
|
|
|
2469
2492
|
return function () { return part; };
|
|
2470
2493
|
});
|
|
2471
2494
|
return function (filter) {
|
|
2472
|
-
return "".concat(
|
|
2495
|
+
return "".concat(typeGradient, "(").concat(parts.map(function (modify) { return modify(filter); }).join(', '), ")").concat(hasComma ? ', ' : '');
|
|
2473
2496
|
};
|
|
2474
2497
|
};
|
|
2475
2498
|
var getURLModifier_1 = function (urlValue) {
|
|
@@ -2478,6 +2501,7 @@
|
|
|
2478
2501
|
return null;
|
|
2479
2502
|
}
|
|
2480
2503
|
var url = getCSSURLValue(urlValue);
|
|
2504
|
+
var isURLEmpty = url.length === 0;
|
|
2481
2505
|
var parentStyleSheet = rule.parentStyleSheet;
|
|
2482
2506
|
var baseURL = (parentStyleSheet && parentStyleSheet.href) ?
|
|
2483
2507
|
getCSSBaseBath(parentStyleSheet.href) :
|
|
@@ -2489,6 +2513,9 @@
|
|
|
2489
2513
|
return __generator(this, function (_a) {
|
|
2490
2514
|
switch (_a.label) {
|
|
2491
2515
|
case 0:
|
|
2516
|
+
if (isURLEmpty) {
|
|
2517
|
+
return [2, "url('')"];
|
|
2518
|
+
}
|
|
2492
2519
|
if (!imageDetailsCache.has(url)) return [3, 1];
|
|
2493
2520
|
imageDetails = imageDetailsCache.get(url);
|
|
2494
2521
|
return [3, 7];
|
|
@@ -2564,66 +2591,68 @@
|
|
|
2564
2591
|
return result;
|
|
2565
2592
|
};
|
|
2566
2593
|
var modifiers_1 = [];
|
|
2567
|
-
var
|
|
2594
|
+
var matchIndex_1 = 0;
|
|
2595
|
+
var prevHasComma_1 = false;
|
|
2568
2596
|
matches_1.forEach(function (_a, i) {
|
|
2569
|
-
var type = _a.type,
|
|
2597
|
+
var type = _a.type, match = _a.match, index = _a.index, typeGradient = _a.typeGradient, hasComma = _a.hasComma, offset = _a.offset;
|
|
2598
|
+
var matchStart = index;
|
|
2599
|
+
var prefixStart = matchIndex_1;
|
|
2600
|
+
var matchEnd = matchStart + match.length + offset;
|
|
2601
|
+
matchIndex_1 = matchEnd;
|
|
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;
|
|
2570
2617
|
if (type === 'url') {
|
|
2571
|
-
var match = urlInfo.match;
|
|
2572
|
-
var matchStart_1 = urlInfo.index;
|
|
2573
|
-
var prefixStart_1 = index_1;
|
|
2574
|
-
var matchEnd_1 = matchStart_1 + match.length;
|
|
2575
|
-
index_1 = matchEnd_1;
|
|
2576
|
-
modifiers_1.push(function () { return value.substring(prefixStart_1, matchStart_1); });
|
|
2577
2618
|
modifiers_1.push(getURLModifier_1(match));
|
|
2578
|
-
if (i === matches_1.length - 1) {
|
|
2579
|
-
modifiers_1.push(function () { return value.substring(matchEnd_1); });
|
|
2580
|
-
}
|
|
2581
2619
|
}
|
|
2582
2620
|
else if (type === 'gradient') {
|
|
2583
|
-
modifiers_1.push(getGradientModifier_1(
|
|
2621
|
+
modifiers_1.push(getGradientModifier_1({ match: match, index: index, typeGradient: typeGradient, hasComma: hasComma, offset: offset }));
|
|
2622
|
+
}
|
|
2623
|
+
if (i === matches_1.length - 1) {
|
|
2624
|
+
modifiers_1.push(function () { return value.substring(matchEnd); });
|
|
2584
2625
|
}
|
|
2585
2626
|
});
|
|
2586
2627
|
return function (filter) {
|
|
2587
2628
|
var results = modifiers_1.filter(Boolean).map(function (modify) { return modify(filter); });
|
|
2588
2629
|
if (results.some(function (r) { return r instanceof Promise; })) {
|
|
2589
|
-
return Promise.all(results)
|
|
2590
|
-
.
|
|
2591
|
-
var result = '';
|
|
2592
|
-
var lastWasURL = false;
|
|
2593
|
-
asyncResults.filter(Boolean).forEach(function (asyncResult) {
|
|
2594
|
-
if (lastWasURL) {
|
|
2595
|
-
if (asyncResult) {
|
|
2596
|
-
result += ', ';
|
|
2597
|
-
}
|
|
2598
|
-
lastWasURL = false;
|
|
2599
|
-
}
|
|
2600
|
-
result += asyncResult;
|
|
2601
|
-
if (asyncResult.startsWith('url(')) {
|
|
2602
|
-
lastWasURL = true;
|
|
2603
|
-
}
|
|
2604
|
-
});
|
|
2605
|
-
return result;
|
|
2630
|
+
return Promise.all(results).then(function (asyncResults) {
|
|
2631
|
+
return asyncResults.filter(Boolean).join('');
|
|
2606
2632
|
});
|
|
2607
2633
|
}
|
|
2608
|
-
|
|
2634
|
+
var combinedResult = results.join('');
|
|
2635
|
+
if (combinedResult.endsWith(', initial')) {
|
|
2636
|
+
return combinedResult.slice(0, -9);
|
|
2637
|
+
}
|
|
2638
|
+
return combinedResult;
|
|
2609
2639
|
};
|
|
2610
2640
|
}
|
|
2611
2641
|
catch (err) {
|
|
2612
|
-
logWarn("Unable to parse gradient ".concat(value), err);
|
|
2613
2642
|
return null;
|
|
2614
2643
|
}
|
|
2615
2644
|
}
|
|
2616
2645
|
function getShadowModifierWithInfo(value) {
|
|
2617
2646
|
try {
|
|
2618
|
-
var
|
|
2647
|
+
var index_1 = 0;
|
|
2619
2648
|
var colorMatches_1 = getMatches(/(^|\s)(?!calc)([a-z]+\(.+?\)|#[0-9a-f]+|[a-z]+)(.*?(inset|outset)?($|,))/ig, value, 2);
|
|
2620
2649
|
var notParsed_1 = 0;
|
|
2621
2650
|
var modifiers_2 = colorMatches_1.map(function (match, i) {
|
|
2622
|
-
var prefixIndex =
|
|
2623
|
-
var matchIndex = value.indexOf(match,
|
|
2651
|
+
var prefixIndex = index_1;
|
|
2652
|
+
var matchIndex = value.indexOf(match, index_1);
|
|
2624
2653
|
var matchEnd = matchIndex + match.length;
|
|
2625
|
-
|
|
2626
|
-
var rgb =
|
|
2654
|
+
index_1 = matchEnd;
|
|
2655
|
+
var rgb = parseColorWithCache(match);
|
|
2627
2656
|
if (!rgb) {
|
|
2628
2657
|
notParsed_1++;
|
|
2629
2658
|
return function () { return value.substring(prefixIndex, matchEnd); };
|
|
@@ -2640,7 +2669,6 @@
|
|
|
2640
2669
|
};
|
|
2641
2670
|
}
|
|
2642
2671
|
catch (err) {
|
|
2643
|
-
logWarn("Unable to parse shadow ".concat(value), err);
|
|
2644
2672
|
return null;
|
|
2645
2673
|
}
|
|
2646
2674
|
}
|
|
@@ -2664,7 +2692,6 @@
|
|
|
2664
2692
|
return variablesStore.getModifierForVarDependant(prop, value);
|
|
2665
2693
|
}
|
|
2666
2694
|
function cleanModificationCache() {
|
|
2667
|
-
colorParseCache.clear();
|
|
2668
2695
|
clearColorModificationCache();
|
|
2669
2696
|
imageDetailsCache.clear();
|
|
2670
2697
|
cleanImageProcessingCache();
|
|
@@ -2951,7 +2978,7 @@
|
|
|
2951
2978
|
return;
|
|
2952
2979
|
}
|
|
2953
2980
|
this.definedVars.add(varName);
|
|
2954
|
-
var color =
|
|
2981
|
+
var color = parseColorWithCache(value);
|
|
2955
2982
|
if (color) {
|
|
2956
2983
|
this.unknownColorVars.add(varName);
|
|
2957
2984
|
}
|
|
@@ -3221,7 +3248,7 @@
|
|
|
3221
3248
|
splitted.forEach(function (number) {
|
|
3222
3249
|
resultInRGB_1 += "".concat(number.trim(), ", ");
|
|
3223
3250
|
});
|
|
3224
|
-
resultInRGB_1 = resultInRGB_1.
|
|
3251
|
+
resultInRGB_1 = resultInRGB_1.substring(0, resultInRGB_1.length - 2);
|
|
3225
3252
|
resultInRGB_1 += ')';
|
|
3226
3253
|
return { isRaw: true, color: resultInRGB_1 };
|
|
3227
3254
|
}
|
|
@@ -3229,11 +3256,11 @@
|
|
|
3229
3256
|
}
|
|
3230
3257
|
function handleRawValue(color, theme, modifyFunction) {
|
|
3231
3258
|
var _a = parseRawValue(color), isRaw = _a.isRaw, newColor = _a.color;
|
|
3232
|
-
var rgb =
|
|
3259
|
+
var rgb = parseColorWithCache(newColor);
|
|
3233
3260
|
if (rgb) {
|
|
3234
3261
|
var outputColor = modifyFunction(rgb, theme);
|
|
3235
3262
|
if (isRaw) {
|
|
3236
|
-
var outputInRGB =
|
|
3263
|
+
var outputInRGB = parseColorWithCache(outputColor);
|
|
3237
3264
|
return outputInRGB ? "".concat(outputInRGB.r, ", ").concat(outputInRGB.g, ", ").concat(outputInRGB.b) : outputColor;
|
|
3238
3265
|
}
|
|
3239
3266
|
return outputColor;
|
|
@@ -3502,7 +3529,7 @@
|
|
|
3502
3529
|
function setCustomProp(targetCSSProp, modifierCSSProp, cssVal) {
|
|
3503
3530
|
var isPropertyVariable = targetCSSProp.startsWith('--');
|
|
3504
3531
|
var _a = isPropertyVariable ? {} : overrides[targetCSSProp], customProp = _a.customProp, dataAttr = _a.dataAttr;
|
|
3505
|
-
var mod = getModifiableCSSDeclaration(modifierCSSProp, cssVal, {}, variablesStore, ignoreImageSelectors, null);
|
|
3532
|
+
var mod = getModifiableCSSDeclaration(modifierCSSProp, cssVal, { style: element.style }, variablesStore, ignoreImageSelectors, null);
|
|
3506
3533
|
if (!mod) {
|
|
3507
3534
|
return;
|
|
3508
3535
|
}
|
|
@@ -3611,13 +3638,11 @@
|
|
|
3611
3638
|
var observer = null;
|
|
3612
3639
|
function changeMetaThemeColor(meta, theme) {
|
|
3613
3640
|
srcMetaThemeColor = srcMetaThemeColor || meta.content;
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
}
|
|
3618
|
-
catch (err) {
|
|
3619
|
-
logWarn(err);
|
|
3641
|
+
var color = parseColorWithCache(srcMetaThemeColor);
|
|
3642
|
+
if (!color) {
|
|
3643
|
+
return;
|
|
3620
3644
|
}
|
|
3645
|
+
meta.content = modifyBackgroundColor(color, theme);
|
|
3621
3646
|
}
|
|
3622
3647
|
function changeMetaThemeColorWhenAvailable(theme) {
|
|
3623
3648
|
var meta = document.querySelector(metaThemeColorSelector);
|
|
@@ -3907,14 +3932,29 @@
|
|
|
3907
3932
|
}
|
|
3908
3933
|
|
|
3909
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
|
+
}
|
|
3910
3948
|
function shouldManageStyle(element) {
|
|
3911
3949
|
return (((element instanceof HTMLStyleElement) ||
|
|
3912
3950
|
(element instanceof SVGStyleElement) ||
|
|
3913
3951
|
(element instanceof HTMLLinkElement &&
|
|
3914
3952
|
element.rel &&
|
|
3915
3953
|
element.rel.toLowerCase().includes('stylesheet') &&
|
|
3954
|
+
element.href &&
|
|
3916
3955
|
!element.disabled &&
|
|
3917
|
-
(isFirefox ? !element.href.startsWith('moz-extension://') : true)
|
|
3956
|
+
(isFirefox ? !element.href.startsWith('moz-extension://') : true) &&
|
|
3957
|
+
!isFontsGoogleApiStyle(element))) &&
|
|
3918
3958
|
!element.classList.contains('darkreader') &&
|
|
3919
3959
|
element.media.toLowerCase() !== 'print' &&
|
|
3920
3960
|
!element.classList.contains('stylus'));
|
|
@@ -3989,26 +4029,20 @@
|
|
|
3989
4029
|
}
|
|
3990
4030
|
function getRulesSync() {
|
|
3991
4031
|
if (corsCopy) {
|
|
3992
|
-
logInfo('[getRulesSync] Using cors-copy.');
|
|
3993
4032
|
return corsCopy.sheet.cssRules;
|
|
3994
4033
|
}
|
|
3995
4034
|
if (containsCSSImport()) {
|
|
3996
|
-
logInfo('[getRulesSync] CSSImport detected.');
|
|
3997
4035
|
return null;
|
|
3998
4036
|
}
|
|
3999
4037
|
var cssRules = safeGetSheetRules();
|
|
4000
4038
|
if (element instanceof HTMLLinkElement &&
|
|
4001
4039
|
!isRelativeHrefOnAbsolutePath(element.href) &&
|
|
4002
4040
|
hasImports(cssRules, false)) {
|
|
4003
|
-
logInfo('[getRulesSync] CSSImportRule detected on non-local href.');
|
|
4004
4041
|
return null;
|
|
4005
4042
|
}
|
|
4006
4043
|
if (hasImports(cssRules, true)) {
|
|
4007
|
-
logInfo('[getRulesSync] Cross-Origin CSSImportRule detected.');
|
|
4008
4044
|
return null;
|
|
4009
4045
|
}
|
|
4010
|
-
logInfo('[getRulesSync] Using cssRules.');
|
|
4011
|
-
!cssRules && logWarn('[getRulesSync] cssRules is null, trying again.');
|
|
4012
4046
|
return cssRules;
|
|
4013
4047
|
}
|
|
4014
4048
|
function insertStyle() {
|
|
@@ -4041,30 +4075,25 @@
|
|
|
4041
4075
|
var loadingLinkId = ++loadingLinkCounter;
|
|
4042
4076
|
function getRulesAsync() {
|
|
4043
4077
|
return __awaiter(this, void 0, void 0, function () {
|
|
4044
|
-
var cssText, cssBasePath, _a, cssRules, accessError,
|
|
4078
|
+
var cssText, cssBasePath, _a, cssRules, accessError, fullCSSText;
|
|
4045
4079
|
var _b;
|
|
4046
4080
|
return __generator(this, function (_c) {
|
|
4047
4081
|
switch (_c.label) {
|
|
4048
4082
|
case 0:
|
|
4049
4083
|
if (!(element instanceof HTMLLinkElement)) return [3, 7];
|
|
4050
4084
|
_a = __read(getRulesOrError(), 2), cssRules = _a[0], accessError = _a[1];
|
|
4051
|
-
if (accessError) {
|
|
4052
|
-
logWarn(accessError);
|
|
4053
|
-
}
|
|
4054
4085
|
if (!((!cssRules && !accessError && !isSafari) ||
|
|
4055
4086
|
(isSafari && !element.sheet) ||
|
|
4056
4087
|
isStillLoadingError(accessError))) return [3, 5];
|
|
4057
4088
|
_c.label = 1;
|
|
4058
4089
|
case 1:
|
|
4059
4090
|
_c.trys.push([1, 3, , 4]);
|
|
4060
|
-
logInfo("Linkelement ".concat(loadingLinkId, " is not loaded yet and thus will be await for"), element);
|
|
4061
4091
|
return [4, linkLoading(element, loadingLinkId)];
|
|
4062
4092
|
case 2:
|
|
4063
4093
|
_c.sent();
|
|
4064
4094
|
return [3, 4];
|
|
4065
4095
|
case 3:
|
|
4066
|
-
|
|
4067
|
-
logWarn(err_1);
|
|
4096
|
+
_c.sent();
|
|
4068
4097
|
wasLoadingError = true;
|
|
4069
4098
|
return [3, 4];
|
|
4070
4099
|
case 4:
|
|
@@ -4072,9 +4101,6 @@
|
|
|
4072
4101
|
return [2, null];
|
|
4073
4102
|
}
|
|
4074
4103
|
_b = __read(getRulesOrError(), 2), cssRules = _b[0], accessError = _b[1];
|
|
4075
|
-
if (accessError) {
|
|
4076
|
-
logWarn(accessError);
|
|
4077
|
-
}
|
|
4078
4104
|
_c.label = 5;
|
|
4079
4105
|
case 5:
|
|
4080
4106
|
if (cssRules) {
|
|
@@ -4110,8 +4136,7 @@
|
|
|
4110
4136
|
corsCopy = createCORSCopy(element, fullCSSText);
|
|
4111
4137
|
return [3, 12];
|
|
4112
4138
|
case 11:
|
|
4113
|
-
|
|
4114
|
-
logWarn(err_2);
|
|
4139
|
+
_c.sent();
|
|
4115
4140
|
return [3, 12];
|
|
4116
4141
|
case 12:
|
|
4117
4142
|
if (corsCopy) {
|
|
@@ -4128,7 +4153,6 @@
|
|
|
4128
4153
|
var rules = getRulesSync();
|
|
4129
4154
|
if (!rules) {
|
|
4130
4155
|
if (options.secondRound) {
|
|
4131
|
-
logWarn('Detected dead-lock at details(), returning early to prevent it.');
|
|
4132
4156
|
return null;
|
|
4133
4157
|
}
|
|
4134
4158
|
if (isLoadingRules || wasLoadingError) {
|
|
@@ -4143,7 +4167,6 @@
|
|
|
4143
4167
|
update();
|
|
4144
4168
|
}
|
|
4145
4169
|
}).catch(function (err) {
|
|
4146
|
-
logWarn(err);
|
|
4147
4170
|
isLoadingRules = false;
|
|
4148
4171
|
loadingEnd();
|
|
4149
4172
|
});
|
|
@@ -4159,15 +4182,6 @@
|
|
|
4159
4182
|
}
|
|
4160
4183
|
cancelAsyncOperations = false;
|
|
4161
4184
|
function removeCSSRulesFromSheet(sheet) {
|
|
4162
|
-
try {
|
|
4163
|
-
if (sheet.replaceSync) {
|
|
4164
|
-
sheet.replaceSync('');
|
|
4165
|
-
return;
|
|
4166
|
-
}
|
|
4167
|
-
}
|
|
4168
|
-
catch (err) {
|
|
4169
|
-
logWarn('Could not use fastpath for removing rules from stylesheet', err);
|
|
4170
|
-
}
|
|
4171
4185
|
for (var i = sheet.cssRules.length - 1; i >= 0; i--) {
|
|
4172
4186
|
sheet.deleteRule(i);
|
|
4173
4187
|
}
|
|
@@ -4229,7 +4243,6 @@
|
|
|
4229
4243
|
function safeGetSheetRules() {
|
|
4230
4244
|
var _a = __read(getRulesOrError(), 2), cssRules = _a[0], err = _a[1];
|
|
4231
4245
|
if (err) {
|
|
4232
|
-
logWarn(err);
|
|
4233
4246
|
return null;
|
|
4234
4247
|
}
|
|
4235
4248
|
return cssRules;
|
|
@@ -4332,10 +4345,8 @@
|
|
|
4332
4345
|
}
|
|
4333
4346
|
moveCount++;
|
|
4334
4347
|
if (moveCount > maxMoveCount) {
|
|
4335
|
-
logWarn('Style sheet was moved multiple times', element);
|
|
4336
4348
|
return;
|
|
4337
4349
|
}
|
|
4338
|
-
logWarn('Restore style', syncStyle, element);
|
|
4339
4350
|
insertStyle();
|
|
4340
4351
|
corsCopyPositionWatcher && corsCopyPositionWatcher.skip();
|
|
4341
4352
|
syncStylePositionWatcher && syncStylePositionWatcher.skip();
|
|
@@ -4364,7 +4375,6 @@
|
|
|
4364
4375
|
};
|
|
4365
4376
|
var onLoad = function () {
|
|
4366
4377
|
cleanUp();
|
|
4367
|
-
logInfo("Linkelement ".concat(loadingId, " has been loaded"));
|
|
4368
4378
|
resolve();
|
|
4369
4379
|
};
|
|
4370
4380
|
var onError = function () {
|
|
@@ -4405,7 +4415,7 @@
|
|
|
4405
4415
|
function replaceCSSImports(cssText, basePath, cache) {
|
|
4406
4416
|
if (cache === void 0) { cache = new Map(); }
|
|
4407
4417
|
return __awaiter(this, void 0, void 0, function () {
|
|
4408
|
-
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;
|
|
4409
4419
|
var e_1, _a;
|
|
4410
4420
|
return __generator(this, function (_b) {
|
|
4411
4421
|
switch (_b.label) {
|
|
@@ -4439,8 +4449,7 @@
|
|
|
4439
4449
|
importedCSS = _b.sent();
|
|
4440
4450
|
return [3, 7];
|
|
4441
4451
|
case 6:
|
|
4442
|
-
|
|
4443
|
-
logWarn(err_3);
|
|
4452
|
+
_b.sent();
|
|
4444
4453
|
importedCSS = '';
|
|
4445
4454
|
return [3, 7];
|
|
4446
4455
|
case 7:
|
|
@@ -4664,7 +4673,7 @@
|
|
|
4664
4673
|
onHugeMutations: handleHugeTreeMutations,
|
|
4665
4674
|
});
|
|
4666
4675
|
var attrObserver = new MutationObserver(handleAttributeMutations);
|
|
4667
|
-
attrObserver.observe(root, { attributes: true, attributeFilter: ['rel', 'disabled', 'media'], subtree: true });
|
|
4676
|
+
attrObserver.observe(root, { attributes: true, attributeFilter: ['rel', 'disabled', 'media', 'href'], subtree: true });
|
|
4668
4677
|
observers.push(treeObserver, attrObserver);
|
|
4669
4678
|
observedRoots.add(root);
|
|
4670
4679
|
}
|
|
@@ -4789,7 +4798,18 @@
|
|
|
4789
4798
|
var removeRuleDescriptor = Object.getOwnPropertyDescriptor(CSSStyleSheet.prototype, 'removeRule');
|
|
4790
4799
|
var documentStyleSheetsDescriptor = enableStyleSheetsProxy ?
|
|
4791
4800
|
Object.getOwnPropertyDescriptor(Document.prototype, 'styleSheets') : null;
|
|
4792
|
-
var shouldWrapHTMLElement =
|
|
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);
|
|
4793
4813
|
var getElementsByTagNameDescriptor = shouldWrapHTMLElement ?
|
|
4794
4814
|
Object.getOwnPropertyDescriptor(Element.prototype, 'getElementsByTagName') : null;
|
|
4795
4815
|
var cleanUp = function () {
|
|
@@ -4976,8 +4996,8 @@
|
|
|
4976
4996
|
var darkSchemeBackgroundColor = filter.darkSchemeBackgroundColor, darkSchemeTextColor = filter.darkSchemeTextColor, lightSchemeBackgroundColor = filter.lightSchemeBackgroundColor, lightSchemeTextColor = filter.lightSchemeTextColor, mode = filter.mode;
|
|
4977
4997
|
var schemeBackgroundColor = mode === 0 ? lightSchemeBackgroundColor : darkSchemeBackgroundColor;
|
|
4978
4998
|
var schemeTextColor = mode === 0 ? lightSchemeTextColor : darkSchemeTextColor;
|
|
4979
|
-
schemeBackgroundColor = modifyBackgroundColor(
|
|
4980
|
-
schemeTextColor = modifyForegroundColor(
|
|
4999
|
+
schemeBackgroundColor = modifyBackgroundColor(parseColorWithCache(schemeBackgroundColor), filter);
|
|
5000
|
+
schemeTextColor = modifyForegroundColor(parseColorWithCache(schemeTextColor), filter);
|
|
4981
5001
|
variableStyle.textContent = [
|
|
4982
5002
|
":root {",
|
|
4983
5003
|
" --darkreader-neutral-background: ".concat(schemeBackgroundColor, ";"),
|
|
@@ -4990,10 +5010,13 @@
|
|
|
4990
5010
|
setupNodePositionWatcher(variableStyle, 'variables');
|
|
4991
5011
|
var rootVarsStyle = createOrUpdateStyle('darkreader--root-vars');
|
|
4992
5012
|
document.head.insertBefore(rootVarsStyle, variableStyle.nextSibling);
|
|
4993
|
-
var
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
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
|
+
}
|
|
4997
5020
|
}
|
|
4998
5021
|
var shadowRootsWithOverrides = new Set();
|
|
4999
5022
|
function createShadowStaticStyleOverrides(root) {
|
|
@@ -5019,11 +5042,10 @@
|
|
|
5019
5042
|
}
|
|
5020
5043
|
function replaceCSSTemplates($cssText) {
|
|
5021
5044
|
return $cssText.replace(/\${(.+?)}/g, function (_, $color) {
|
|
5022
|
-
var color =
|
|
5045
|
+
var color = parseColorWithCache($color);
|
|
5023
5046
|
if (color) {
|
|
5024
5047
|
return modifyColor(color, filter);
|
|
5025
5048
|
}
|
|
5026
|
-
logWarn("Couldn't parse CSSTemplate's color.");
|
|
5027
5049
|
return $color;
|
|
5028
5050
|
});
|
|
5029
5051
|
}
|
|
@@ -5070,7 +5092,6 @@
|
|
|
5070
5092
|
var loadingStyles = new Set();
|
|
5071
5093
|
function createManager(element) {
|
|
5072
5094
|
var loadingStyleId = ++loadingStylesCounter;
|
|
5073
|
-
logInfo("New manager for element, with loadingStyleID ".concat(loadingStyleId), element);
|
|
5074
5095
|
function loadingStart() {
|
|
5075
5096
|
if (!isDOMReady() || !didDocumentShowUp) {
|
|
5076
5097
|
loadingStyles.add(loadingStyleId);
|
|
@@ -5084,7 +5105,6 @@
|
|
|
5084
5105
|
function loadingEnd() {
|
|
5085
5106
|
loadingStyles.delete(loadingStyleId);
|
|
5086
5107
|
logInfo("Removed loadingStyle ".concat(loadingStyleId, ", now awaiting: ").concat(loadingStyles.size));
|
|
5087
|
-
logInfo("To-do to be loaded", loadingStyles);
|
|
5088
5108
|
if (loadingStyles.size === 0 && isDOMReady()) {
|
|
5089
5109
|
cleanFallbackStyle();
|
|
5090
5110
|
}
|
|
@@ -5122,7 +5142,6 @@
|
|
|
5122
5142
|
cleanFallbackStyle();
|
|
5123
5143
|
return;
|
|
5124
5144
|
}
|
|
5125
|
-
logWarn("DOM is ready, but still have styles being loaded.", loadingStyles);
|
|
5126
5145
|
}
|
|
5127
5146
|
var documentVisibilityListener = null;
|
|
5128
5147
|
var didDocumentShowUp = !document.hidden;
|
|
@@ -5158,13 +5177,17 @@
|
|
|
5158
5177
|
changeMetaThemeColorWhenAvailable(filter);
|
|
5159
5178
|
}
|
|
5160
5179
|
function handleAdoptedStyleSheets(node) {
|
|
5161
|
-
|
|
5162
|
-
if (node.adoptedStyleSheets
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5180
|
+
try {
|
|
5181
|
+
if (Array.isArray(node.adoptedStyleSheets)) {
|
|
5182
|
+
if (node.adoptedStyleSheets.length > 0) {
|
|
5183
|
+
var newManger = createAdoptedStyleSheetOverride(node);
|
|
5184
|
+
adoptedStyleManagers.push(newManger);
|
|
5185
|
+
newManger.render(filter, ignoredImageAnalysisSelectors);
|
|
5186
|
+
}
|
|
5166
5187
|
}
|
|
5167
5188
|
}
|
|
5189
|
+
catch (err) {
|
|
5190
|
+
}
|
|
5168
5191
|
}
|
|
5169
5192
|
function watchForUpdates() {
|
|
5170
5193
|
var managedStyles = Array.from(styleManagers.keys());
|
|
@@ -5175,7 +5198,6 @@
|
|
|
5175
5198
|
.filter(function (style) { return !styleManagers.has(style); });
|
|
5176
5199
|
var stylesToRestore = moved
|
|
5177
5200
|
.filter(function (style) { return styleManagers.has(style); });
|
|
5178
|
-
logInfo("Styles to be removed:", stylesToRemove);
|
|
5179
5201
|
stylesToRemove.forEach(function (style) { return removeManager(style); });
|
|
5180
5202
|
var newManagers = stylesToManage
|
|
5181
5203
|
.map(function (style) { return createManager(style); });
|
|
@@ -5219,6 +5241,16 @@
|
|
|
5219
5241
|
removeDOMReadyListener(onDOMReady);
|
|
5220
5242
|
cleanReadyStateCompleteListeners();
|
|
5221
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
|
+
}
|
|
5222
5254
|
function createDarkReaderInstanceMarker() {
|
|
5223
5255
|
var metaElement = document.createElement('meta');
|
|
5224
5256
|
metaElement.name = 'darkreader';
|
|
@@ -5226,6 +5258,9 @@
|
|
|
5226
5258
|
document.head.appendChild(metaElement);
|
|
5227
5259
|
}
|
|
5228
5260
|
function isAnotherDarkReaderInstanceActive() {
|
|
5261
|
+
if (document.querySelector('meta[name="darkreader-lock"]')) {
|
|
5262
|
+
return true;
|
|
5263
|
+
}
|
|
5229
5264
|
var meta = document.querySelector('meta[name="darkreader"]');
|
|
5230
5265
|
if (meta) {
|
|
5231
5266
|
if (meta.content !== INSTANCE_ID) {
|
|
@@ -5234,6 +5269,7 @@
|
|
|
5234
5269
|
return false;
|
|
5235
5270
|
}
|
|
5236
5271
|
createDarkReaderInstanceMarker();
|
|
5272
|
+
addMetaListener();
|
|
5237
5273
|
return false;
|
|
5238
5274
|
}
|
|
5239
5275
|
function createOrUpdateDynamicTheme(filterConfig, dynamicThemeFixes, iframe) {
|
|
@@ -5314,6 +5350,7 @@
|
|
|
5314
5350
|
manager.destroy();
|
|
5315
5351
|
});
|
|
5316
5352
|
adoptedStyleManagers.splice(0);
|
|
5353
|
+
metaObserver && metaObserver.disconnect();
|
|
5317
5354
|
}
|
|
5318
5355
|
function cleanDynamicThemeCache() {
|
|
5319
5356
|
variablesStore.clear();
|
|
@@ -5322,6 +5359,7 @@
|
|
|
5322
5359
|
cancelRendering();
|
|
5323
5360
|
stopWatchingForUpdates();
|
|
5324
5361
|
cleanModificationCache();
|
|
5362
|
+
clearColorCache();
|
|
5325
5363
|
}
|
|
5326
5364
|
|
|
5327
5365
|
var blobRegex = /url\(\"(blob\:.*?)\"\)/g;
|
|
@@ -5344,7 +5382,7 @@
|
|
|
5344
5382
|
});
|
|
5345
5383
|
});
|
|
5346
5384
|
}
|
|
5347
|
-
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";
|
|
5348
5386
|
function collectCSS() {
|
|
5349
5387
|
return __awaiter(this, void 0, void 0, function () {
|
|
5350
5388
|
function addStaticCSS(selector, comment) {
|