darkreader 4.9.44 → 4.9.52
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 +9 -10
- package/darkreader.js +281 -220
- package/package.json +52 -56
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center"><a href="https://darkreader.org" target="_blank" rel="noreferrer noopener"><img width="250" alt="Dark Reader's mascot" src="https://raw.githubusercontent.com/darkreader/darkreader.github.io/master/images/darkreader-mascot.svg"></a></p>
|
|
2
|
-
<p align="center">Dark Reader <strong>analyzes</strong> web pages and aims to <strong>reduce
|
|
2
|
+
<p align="center">Dark Reader <strong>analyzes</strong> web pages and aims to <strong>reduce eyestrain</strong> while browsing the web.</p>
|
|
3
3
|
<br/>
|
|
4
4
|
<p align="center"><a rel="noreferrer noopener" href="https://chrome.google.com/webstore/detail/dark-reader/eimadpbcbfnmbkopoojfekhnkhdbieeh/"><img alt="Chrome Web Store" src="https://img.shields.io/badge/Chrome-141e24.svg?&style=for-the-badge&logo=google-chrome&logoColor=white"></a> <a rel="noreferrer noopener" href="https://addons.mozilla.org/firefox/addon/darkreader/"><img alt="Firefox Add-ons" src="https://img.shields.io/badge/Firefox-141e24.svg?&style=for-the-badge&logo=firefox-browser&logoColor=white"></a> <a rel="noreferrer noopener" href="https://darkreader.org/safari/"><img alt="Apple App Store" src="https://img.shields.io/badge/Safari-141e24.svg?&style=for-the-badge&logo=safari&logoColor=white"></a> <a rel="noreferrer noopener" href="https://microsoftedge.microsoft.com/addons/detail/dark-reader/ifoakfbpdcdoeenechcleahebpibofpc/"><img alt="Edge Addons" src="https://img.shields.io/badge/Edge-141e24.svg?&style=for-the-badge&logo=microsoft-edge&logoColor=white"></a> <a el="noreferrer noopener" href="https://addons.thunderbird.net/thunderbird/addon/darkreader"><img alt="Thunderbird" src="https://img.shields.io/badge/Thunderbird-141e24.svg?&style=for-the-badge&logo=thunderbird&logoColor=white"></a>
|
|
5
5
|
|
|
@@ -22,12 +22,12 @@ Read more about contributing to Dark Reader in [CONTRIBUTING.md](https://github.
|
|
|
22
22
|
|
|
23
23
|
You can install the extension from a file.
|
|
24
24
|
Install [Node.js LTS](https://nodejs.org/en/). Download the source code (or check out from git).
|
|
25
|
-
Open terminal in the root folder and run:
|
|
25
|
+
Open the terminal in the root folder and run:
|
|
26
26
|
|
|
27
|
-
- `npm install`
|
|
28
|
-
- `npm run build`
|
|
27
|
+
- `npm install`
|
|
28
|
+
- `npm run build`
|
|
29
29
|
|
|
30
|
-
This will
|
|
30
|
+
This will create a `build/release/darkreader-chrome.zip` file for use in a Chromium-based browser and a `build/release/darkreader-firefox.xpi` file for use in Firefox.
|
|
31
31
|
|
|
32
32
|
## Using Dark Reader for a website
|
|
33
33
|
|
|
@@ -90,14 +90,13 @@ const CSS = await collectCSS();
|
|
|
90
90
|
const isEnabled = isDarkReaderEnabled();
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
Be aware
|
|
94
|
-
the code will use. They originate from the webextension-api.
|
|
93
|
+
Be aware that darkreader will add the `chrome` object onto the `window` object. These are to stub certain functions that the code will use. They originate from the webextension-api.
|
|
95
94
|
|
|
96
95
|
## Site fixes
|
|
97
96
|
|
|
98
|
-
Automatically syncing the site fixes to every Dark Reader user was disabled because the GitHub team
|
|
97
|
+
Automatically syncing the site fixes to every Dark Reader user was disabled because the GitHub team does not allow using GitHub as a CDN. The storage of these files would be expensive, and making requests to other resources would look suspicious. Each new release of Dark Reader will include these changes.
|
|
99
98
|
|
|
100
|
-
However, this can be enabled
|
|
99
|
+
However, this can be enabled using the following steps:
|
|
101
100
|
|
|
102
101
|
- Click on the Dark Reader icon.
|
|
103
102
|
- Click on the Dev tools button (in the bottom-right corner).
|
|
@@ -119,7 +118,7 @@ However, this can be enabled by the following steps:
|
|
|
119
118
|
<p align="center"><a rel="noreferrer noopener" href="https://opencollective.com/darkreader#backers" target="_blank"><img src="https://opencollective.com/darkreader/backers.svg?width=890&limit=1000"></a></p>
|
|
120
119
|
|
|
121
120
|
<h2 align="center">Sponsors</h2>
|
|
122
|
-
<p>Does your company use Dark Reader? Ask your manager or the marketing team if your company would be interested in supporting our project. Your support will allow the maintainers to dedicate more time
|
|
121
|
+
<p>Does your company use Dark Reader? Ask your manager or the marketing team if your company would be interested in supporting our project. Your support will allow the maintainers to dedicate more time to maintenance and creating new features for everyone. Also, your company's logo will show on <a rel="noreferrer noopener" href="https://github.com/darkreader/darkreader#sponsors" target="_blank">GitHub</a>. Who doesn't want a little extra exposure? <a rel="noreferrer noopener" href="https://opencollective.com/darkreader" target="_blank">Here's the info</a>.</p>
|
|
123
122
|
|
|
124
123
|
<h3 align="center"><strong>Thank you to all our wonderful sponsors!</strong></h3>
|
|
125
124
|
<br/>
|
package/darkreader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Dark Reader v4.9.
|
|
2
|
+
* Dark Reader v4.9.52
|
|
3
3
|
* https://darkreader.org/
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -114,14 +114,14 @@
|
|
|
114
114
|
|
|
115
115
|
var MessageType = {
|
|
116
116
|
UI_GET_DATA: 'ui-get-data',
|
|
117
|
-
UI_GET_ACTIVE_TAB_INFO: 'ui-get-active-tab-info',
|
|
118
117
|
UI_SUBSCRIBE_TO_CHANGES: 'ui-subscribe-to-changes',
|
|
119
118
|
UI_UNSUBSCRIBE_FROM_CHANGES: 'ui-unsubscribe-from-changes',
|
|
120
119
|
UI_CHANGE_SETTINGS: 'ui-change-settings',
|
|
121
120
|
UI_SET_THEME: 'ui-set-theme',
|
|
122
121
|
UI_SET_SHORTCUT: 'ui-set-shortcut',
|
|
123
|
-
|
|
122
|
+
UI_TOGGLE_ACTIVE_TAB: 'ui-toggle-active-tab',
|
|
124
123
|
UI_MARK_NEWS_AS_READ: 'ui-mark-news-as-read',
|
|
124
|
+
UI_MARK_NEWS_AS_DISPLAYED: 'ui-mark-news-as-displayed',
|
|
125
125
|
UI_LOAD_CONFIG: 'ui-load-config',
|
|
126
126
|
UI_APPLY_DEV_DYNAMIC_THEME_FIXES: 'ui-apply-dev-dynamic-theme-fixes',
|
|
127
127
|
UI_RESET_DEV_DYNAMIC_THEME_FIXES: 'ui-reset-dev-dynamic-theme-fixes',
|
|
@@ -150,6 +150,8 @@
|
|
|
150
150
|
CS_FRAME_RESUME: 'cs-frame-resume',
|
|
151
151
|
CS_EXPORT_CSS_RESPONSE: 'cs-export-css-response',
|
|
152
152
|
CS_FETCH: 'cs-fetch',
|
|
153
|
+
CS_DARK_THEME_DETECTED: 'cs-dark-theme-detected',
|
|
154
|
+
CS_DARK_THEME_NOT_DETECTED: 'cs-dark-theme-not-detected',
|
|
153
155
|
};
|
|
154
156
|
|
|
155
157
|
var userAgent = typeof navigator === 'undefined' ? 'some useragent' : navigator.userAgent.toLowerCase();
|
|
@@ -191,7 +193,7 @@
|
|
|
191
193
|
}
|
|
192
194
|
var el = document.createElement('div');
|
|
193
195
|
el.setAttribute('style', 'color-scheme: dark');
|
|
194
|
-
return el.style.colorScheme === 'dark';
|
|
196
|
+
return el.style && el.style.colorScheme === 'dark';
|
|
195
197
|
})();
|
|
196
198
|
|
|
197
199
|
function getOKResponse(url, mimeType, origin) {
|
|
@@ -413,6 +415,7 @@
|
|
|
413
415
|
styleSystemControls: !isCSSColorSchemePropSupported,
|
|
414
416
|
lightColorScheme: 'Default',
|
|
415
417
|
darkColorScheme: 'Default',
|
|
418
|
+
immediateModify: false,
|
|
416
419
|
};
|
|
417
420
|
|
|
418
421
|
function isArrayLike(items) {
|
|
@@ -637,16 +640,22 @@
|
|
|
637
640
|
}
|
|
638
641
|
});
|
|
639
642
|
for (var node = (root.shadowRoot ? walker.currentNode : walker.nextNode()); node != null; node = walker.nextNode()) {
|
|
643
|
+
if (node.classList.contains('surfingkeys_hints_host')) {
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
640
646
|
iterator(node);
|
|
641
647
|
iterateShadowHosts(node.shadowRoot, iterator);
|
|
642
648
|
}
|
|
643
649
|
}
|
|
644
|
-
function
|
|
650
|
+
var isDOMReady = function () {
|
|
645
651
|
return document.readyState === 'complete' || document.readyState === 'interactive';
|
|
652
|
+
};
|
|
653
|
+
function setIsDOMReady(newFunc) {
|
|
654
|
+
isDOMReady = newFunc;
|
|
646
655
|
}
|
|
647
656
|
var readyStateListeners = new Set();
|
|
648
657
|
function addDOMReadyListener(listener) {
|
|
649
|
-
readyStateListeners.add(listener);
|
|
658
|
+
isDOMReady() ? listener() : readyStateListeners.add(listener);
|
|
650
659
|
}
|
|
651
660
|
function removeDOMReadyListener(listener) {
|
|
652
661
|
readyStateListeners.delete(listener);
|
|
@@ -656,7 +665,7 @@
|
|
|
656
665
|
}
|
|
657
666
|
var readyStateCompleteListeners = new Set();
|
|
658
667
|
function addReadyStateCompleteListener(listener) {
|
|
659
|
-
readyStateCompleteListeners.add(listener);
|
|
668
|
+
isReadyStateComplete() ? listener() : readyStateCompleteListeners.add(listener);
|
|
660
669
|
}
|
|
661
670
|
function cleanReadyStateCompleteListeners() {
|
|
662
671
|
readyStateCompleteListeners.clear();
|
|
@@ -917,9 +926,9 @@
|
|
|
917
926
|
}
|
|
918
927
|
}
|
|
919
928
|
var cssURLRegex = /url\((('.+?')|(".+?")|([^\)]*?))\)/g;
|
|
920
|
-
var cssImportRegex = /@import\s*(url\()?(('.+?')|(".+?")|([^\)]*?))\)? ?(screen)?;?/
|
|
929
|
+
var cssImportRegex = /@import\s*(url\()?(('.+?')|(".+?")|([^\)]*?))\)? ?(screen)?;?/gi;
|
|
921
930
|
function getCSSURLValue(cssURL) {
|
|
922
|
-
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');
|
|
923
932
|
}
|
|
924
933
|
function getCSSBaseBath(url) {
|
|
925
934
|
var cssURL = parseURL(url);
|
|
@@ -946,6 +955,159 @@
|
|
|
946
955
|
return $css.replace(fontFaceRegex, '');
|
|
947
956
|
}
|
|
948
957
|
|
|
958
|
+
function evalMath(expression) {
|
|
959
|
+
var rpnStack = [];
|
|
960
|
+
var workingStack = [];
|
|
961
|
+
var lastToken;
|
|
962
|
+
for (var i = 0, len = expression.length; i < len; i++) {
|
|
963
|
+
var token = expression[i];
|
|
964
|
+
if (!token || token === ' ') {
|
|
965
|
+
continue;
|
|
966
|
+
}
|
|
967
|
+
if (operators.has(token)) {
|
|
968
|
+
var op = operators.get(token);
|
|
969
|
+
while (workingStack.length) {
|
|
970
|
+
var currentOp = operators.get(workingStack[0]);
|
|
971
|
+
if (!currentOp) {
|
|
972
|
+
break;
|
|
973
|
+
}
|
|
974
|
+
if (op.lessOrEqualThan(currentOp)) {
|
|
975
|
+
rpnStack.push(workingStack.shift());
|
|
976
|
+
}
|
|
977
|
+
else {
|
|
978
|
+
break;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
workingStack.unshift(token);
|
|
982
|
+
}
|
|
983
|
+
else if (!lastToken || operators.has(lastToken)) {
|
|
984
|
+
rpnStack.push(token);
|
|
985
|
+
}
|
|
986
|
+
else {
|
|
987
|
+
rpnStack[rpnStack.length - 1] += token;
|
|
988
|
+
}
|
|
989
|
+
lastToken = token;
|
|
990
|
+
}
|
|
991
|
+
rpnStack.push.apply(rpnStack, __spreadArray([], __read(workingStack), false));
|
|
992
|
+
var stack = [];
|
|
993
|
+
for (var i = 0, len = rpnStack.length; i < len; i++) {
|
|
994
|
+
var op = operators.get(rpnStack[i]);
|
|
995
|
+
if (op) {
|
|
996
|
+
var args = stack.splice(0, 2);
|
|
997
|
+
stack.push(op.exec(args[1], args[0]));
|
|
998
|
+
}
|
|
999
|
+
else {
|
|
1000
|
+
stack.unshift(parseFloat(rpnStack[i]));
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
return stack[0];
|
|
1004
|
+
}
|
|
1005
|
+
var Operator = (function () {
|
|
1006
|
+
function Operator(precedence, method) {
|
|
1007
|
+
this.precendce = precedence;
|
|
1008
|
+
this.execMethod = method;
|
|
1009
|
+
}
|
|
1010
|
+
Operator.prototype.exec = function (left, right) {
|
|
1011
|
+
return this.execMethod(left, right);
|
|
1012
|
+
};
|
|
1013
|
+
Operator.prototype.lessOrEqualThan = function (op) {
|
|
1014
|
+
return this.precendce <= op.precendce;
|
|
1015
|
+
};
|
|
1016
|
+
return Operator;
|
|
1017
|
+
}());
|
|
1018
|
+
var operators = new Map([
|
|
1019
|
+
['+', new Operator(1, function (left, right) { return left + right; })],
|
|
1020
|
+
['-', new Operator(1, function (left, right) { return left - right; })],
|
|
1021
|
+
['*', new Operator(2, function (left, right) { return left * right; })],
|
|
1022
|
+
['/', new Operator(2, function (left, right) { return left / right; })],
|
|
1023
|
+
]);
|
|
1024
|
+
|
|
1025
|
+
function getMatches(regex, input, group) {
|
|
1026
|
+
if (group === void 0) { group = 0; }
|
|
1027
|
+
var matches = [];
|
|
1028
|
+
var m;
|
|
1029
|
+
while ((m = regex.exec(input))) {
|
|
1030
|
+
matches.push(m[group]);
|
|
1031
|
+
}
|
|
1032
|
+
return matches;
|
|
1033
|
+
}
|
|
1034
|
+
function formatCSS(text) {
|
|
1035
|
+
function trimLeft(text) {
|
|
1036
|
+
return text.replace(/^\s+/, '');
|
|
1037
|
+
}
|
|
1038
|
+
function getIndent(depth) {
|
|
1039
|
+
if (depth === 0) {
|
|
1040
|
+
return '';
|
|
1041
|
+
}
|
|
1042
|
+
return ' '.repeat(4 * depth);
|
|
1043
|
+
}
|
|
1044
|
+
if (text.length < 50000) {
|
|
1045
|
+
var emptyRuleRegexp = /[^{}]+{\s*}/;
|
|
1046
|
+
while (emptyRuleRegexp.test(text)) {
|
|
1047
|
+
text = text.replace(emptyRuleRegexp, '');
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
var css = (text
|
|
1051
|
+
.replace(/\s{2,}/g, ' ')
|
|
1052
|
+
.replace(/\{/g, '{\n')
|
|
1053
|
+
.replace(/\}/g, '\n}\n')
|
|
1054
|
+
.replace(/\;(?![^\(|\"]*(\)|\"))/g, ';\n')
|
|
1055
|
+
.replace(/\,(?![^\(|\"]*(\)|\"))/g, ',\n')
|
|
1056
|
+
.replace(/\n\s*\n/g, '\n')
|
|
1057
|
+
.split('\n'));
|
|
1058
|
+
var depth = 0;
|
|
1059
|
+
var formatted = [];
|
|
1060
|
+
for (var x = 0, len = css.length; x < len; x++) {
|
|
1061
|
+
var line = "".concat(css[x], "\n");
|
|
1062
|
+
if (line.includes('{')) {
|
|
1063
|
+
formatted.push(getIndent(depth++) + trimLeft(line));
|
|
1064
|
+
}
|
|
1065
|
+
else if (line.includes('\}')) {
|
|
1066
|
+
formatted.push(getIndent(--depth) + trimLeft(line));
|
|
1067
|
+
}
|
|
1068
|
+
else {
|
|
1069
|
+
formatted.push(getIndent(depth) + trimLeft(line));
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
return formatted.join('').trim();
|
|
1073
|
+
}
|
|
1074
|
+
function getParenthesesRange(input, searchStartIndex) {
|
|
1075
|
+
if (searchStartIndex === void 0) { searchStartIndex = 0; }
|
|
1076
|
+
var length = input.length;
|
|
1077
|
+
var depth = 0;
|
|
1078
|
+
var firstOpenIndex = -1;
|
|
1079
|
+
for (var i = searchStartIndex; i < length; i++) {
|
|
1080
|
+
if (depth === 0) {
|
|
1081
|
+
var openIndex = input.indexOf('(', i);
|
|
1082
|
+
if (openIndex < 0) {
|
|
1083
|
+
break;
|
|
1084
|
+
}
|
|
1085
|
+
firstOpenIndex = openIndex;
|
|
1086
|
+
depth++;
|
|
1087
|
+
i = openIndex;
|
|
1088
|
+
}
|
|
1089
|
+
else {
|
|
1090
|
+
var closingIndex = input.indexOf(')', i);
|
|
1091
|
+
if (closingIndex < 0) {
|
|
1092
|
+
break;
|
|
1093
|
+
}
|
|
1094
|
+
var openIndex = input.indexOf('(', i);
|
|
1095
|
+
if (openIndex < 0 || closingIndex < openIndex) {
|
|
1096
|
+
depth--;
|
|
1097
|
+
if (depth === 0) {
|
|
1098
|
+
return { start: firstOpenIndex, end: closingIndex + 1 };
|
|
1099
|
+
}
|
|
1100
|
+
i = closingIndex;
|
|
1101
|
+
}
|
|
1102
|
+
else {
|
|
1103
|
+
depth++;
|
|
1104
|
+
i = openIndex;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
return null;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
949
1111
|
function hslToRGB(_a) {
|
|
950
1112
|
var h = _a.h, s = _a.s, l = _a.l, _b = _a.a, a = _b === void 0 ? 1 : _b;
|
|
951
1113
|
if (s === 0) {
|
|
@@ -1142,69 +1304,21 @@
|
|
|
1142
1304
|
a: 1
|
|
1143
1305
|
};
|
|
1144
1306
|
}
|
|
1145
|
-
var isCharDigit = function (char) { return char >= '0' && char <= '9'; };
|
|
1146
|
-
var getAmountOfDigits = function (number) { return Math.floor(Math.log10(number)) + 1; };
|
|
1147
1307
|
function lowerCalcExpression(color) {
|
|
1148
1308
|
var searchIndex = 0;
|
|
1149
1309
|
var replaceBetweenIndices = function (start, end, replacement) {
|
|
1150
1310
|
color = color.substring(0, start) + replacement + color.substring(end);
|
|
1151
1311
|
};
|
|
1152
|
-
|
|
1153
|
-
var
|
|
1154
|
-
|
|
1155
|
-
var char = color[searchIndex + i];
|
|
1156
|
-
if (char === ' ') {
|
|
1157
|
-
break;
|
|
1158
|
-
}
|
|
1159
|
-
if (isCharDigit(char)) {
|
|
1160
|
-
resultNumber *= 10;
|
|
1161
|
-
resultNumber += Number(char);
|
|
1162
|
-
}
|
|
1163
|
-
else {
|
|
1164
|
-
break;
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
var lenDigits = getAmountOfDigits(resultNumber);
|
|
1168
|
-
searchIndex += lenDigits;
|
|
1169
|
-
var possibleType = color[searchIndex + 1];
|
|
1170
|
-
if (possibleType !== '%') {
|
|
1171
|
-
return;
|
|
1172
|
-
}
|
|
1173
|
-
searchIndex++;
|
|
1174
|
-
return resultNumber;
|
|
1175
|
-
};
|
|
1176
|
-
while ((searchIndex = color.indexOf('calc(')) !== 0) {
|
|
1177
|
-
var startIndex = searchIndex;
|
|
1178
|
-
searchIndex += 4;
|
|
1179
|
-
var firstNumber = getNumber();
|
|
1180
|
-
if (!firstNumber) {
|
|
1181
|
-
break;
|
|
1182
|
-
}
|
|
1183
|
-
if (color[searchIndex + 1] !== ' ') {
|
|
1184
|
-
break;
|
|
1185
|
-
}
|
|
1186
|
-
searchIndex++;
|
|
1187
|
-
var operation = color[searchIndex + 1];
|
|
1188
|
-
if (operation !== '+' && operation !== '-') {
|
|
1189
|
-
break;
|
|
1190
|
-
}
|
|
1191
|
-
searchIndex++;
|
|
1192
|
-
if (color[searchIndex + 1] !== ' ') {
|
|
1193
|
-
break;
|
|
1194
|
-
}
|
|
1195
|
-
searchIndex++;
|
|
1196
|
-
var secondNumber = getNumber();
|
|
1197
|
-
if (!secondNumber) {
|
|
1312
|
+
while ((searchIndex = color.indexOf('calc(')) !== -1) {
|
|
1313
|
+
var range = getParenthesesRange(color, searchIndex);
|
|
1314
|
+
if (!range) {
|
|
1198
1315
|
break;
|
|
1199
1316
|
}
|
|
1200
|
-
var
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
replacement = "".concat(firstNumber - secondNumber, "%");
|
|
1206
|
-
}
|
|
1207
|
-
replaceBetweenIndices(startIndex, searchIndex + 2, replacement);
|
|
1317
|
+
var slice = color.slice(range.start + 1, range.end - 1);
|
|
1318
|
+
var includesPercentage = slice.includes('%');
|
|
1319
|
+
slice = slice.split('%').join('');
|
|
1320
|
+
var output = Math.round(evalMath(slice));
|
|
1321
|
+
replaceBetweenIndices(range.start - 4, range.end, output + (includesPercentage ? '%' : ''));
|
|
1208
1322
|
}
|
|
1209
1323
|
return color;
|
|
1210
1324
|
}
|
|
@@ -1392,6 +1506,9 @@
|
|
|
1392
1506
|
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
1393
1507
|
return [key.toLowerCase(), value];
|
|
1394
1508
|
}));
|
|
1509
|
+
function getSRGBLightness(r, g, b) {
|
|
1510
|
+
return (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;
|
|
1511
|
+
}
|
|
1395
1512
|
|
|
1396
1513
|
function scale(x, inLow, inHigh, outLow, outHigh) {
|
|
1397
1514
|
return (x - inLow) * (outHigh - outLow) / (inHigh - inLow) + outLow;
|
|
@@ -1414,92 +1531,6 @@
|
|
|
1414
1531
|
return result;
|
|
1415
1532
|
}
|
|
1416
1533
|
|
|
1417
|
-
function getMatches(regex, input, group) {
|
|
1418
|
-
if (group === void 0) { group = 0; }
|
|
1419
|
-
var matches = [];
|
|
1420
|
-
var m;
|
|
1421
|
-
while ((m = regex.exec(input))) {
|
|
1422
|
-
matches.push(m[group]);
|
|
1423
|
-
}
|
|
1424
|
-
return matches;
|
|
1425
|
-
}
|
|
1426
|
-
function formatCSS(text) {
|
|
1427
|
-
function trimLeft(text) {
|
|
1428
|
-
return text.replace(/^\s+/, '');
|
|
1429
|
-
}
|
|
1430
|
-
function getIndent(depth) {
|
|
1431
|
-
if (depth === 0) {
|
|
1432
|
-
return '';
|
|
1433
|
-
}
|
|
1434
|
-
return ' '.repeat(4 * depth);
|
|
1435
|
-
}
|
|
1436
|
-
if (text.length < 50000) {
|
|
1437
|
-
var emptyRuleRegexp = /[^{}]+{\s*}/;
|
|
1438
|
-
while (emptyRuleRegexp.test(text)) {
|
|
1439
|
-
text = text.replace(emptyRuleRegexp, '');
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
var css = (text
|
|
1443
|
-
.replace(/\s{2,}/g, ' ')
|
|
1444
|
-
.replace(/\{/g, '{\n')
|
|
1445
|
-
.replace(/\}/g, '\n}\n')
|
|
1446
|
-
.replace(/\;(?![^\(|\"]*(\)|\"))/g, ';\n')
|
|
1447
|
-
.replace(/\,(?![^\(|\"]*(\)|\"))/g, ',\n')
|
|
1448
|
-
.replace(/\n\s*\n/g, '\n')
|
|
1449
|
-
.split('\n'));
|
|
1450
|
-
var depth = 0;
|
|
1451
|
-
var formatted = [];
|
|
1452
|
-
for (var x = 0, len = css.length; x < len; x++) {
|
|
1453
|
-
var line = "".concat(css[x], "\n");
|
|
1454
|
-
if (line.includes('{')) {
|
|
1455
|
-
formatted.push(getIndent(depth++) + trimLeft(line));
|
|
1456
|
-
}
|
|
1457
|
-
else if (line.includes('\}')) {
|
|
1458
|
-
formatted.push(getIndent(--depth) + trimLeft(line));
|
|
1459
|
-
}
|
|
1460
|
-
else {
|
|
1461
|
-
formatted.push(getIndent(depth) + trimLeft(line));
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1464
|
-
return formatted.join('').trim();
|
|
1465
|
-
}
|
|
1466
|
-
function getParenthesesRange(input, searchStartIndex) {
|
|
1467
|
-
if (searchStartIndex === void 0) { searchStartIndex = 0; }
|
|
1468
|
-
var length = input.length;
|
|
1469
|
-
var depth = 0;
|
|
1470
|
-
var firstOpenIndex = -1;
|
|
1471
|
-
for (var i = searchStartIndex; i < length; i++) {
|
|
1472
|
-
if (depth === 0) {
|
|
1473
|
-
var openIndex = input.indexOf('(', i);
|
|
1474
|
-
if (openIndex < 0) {
|
|
1475
|
-
break;
|
|
1476
|
-
}
|
|
1477
|
-
firstOpenIndex = openIndex;
|
|
1478
|
-
depth++;
|
|
1479
|
-
i = openIndex;
|
|
1480
|
-
}
|
|
1481
|
-
else {
|
|
1482
|
-
var closingIndex = input.indexOf(')', i);
|
|
1483
|
-
if (closingIndex < 0) {
|
|
1484
|
-
break;
|
|
1485
|
-
}
|
|
1486
|
-
var openIndex = input.indexOf('(', i);
|
|
1487
|
-
if (openIndex < 0 || closingIndex < openIndex) {
|
|
1488
|
-
depth--;
|
|
1489
|
-
if (depth === 0) {
|
|
1490
|
-
return { start: firstOpenIndex, end: closingIndex + 1 };
|
|
1491
|
-
}
|
|
1492
|
-
i = closingIndex;
|
|
1493
|
-
}
|
|
1494
|
-
else {
|
|
1495
|
-
depth++;
|
|
1496
|
-
i = openIndex;
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
return null;
|
|
1501
|
-
}
|
|
1502
|
-
|
|
1503
1534
|
function createFilterMatrix(config) {
|
|
1504
1535
|
var m = Matrix.identity();
|
|
1505
1536
|
if (config.sepia !== 0) {
|
|
@@ -1715,6 +1746,9 @@
|
|
|
1715
1746
|
hx = scale(h, 60, 120, 60, 105);
|
|
1716
1747
|
}
|
|
1717
1748
|
}
|
|
1749
|
+
if (hx > 40 && hx < 80) {
|
|
1750
|
+
lx *= 0.75;
|
|
1751
|
+
}
|
|
1718
1752
|
return { h: hx, s: s, l: lx, a: a };
|
|
1719
1753
|
}
|
|
1720
1754
|
function modifyBackgroundColor(rgb, theme) {
|
|
@@ -2050,15 +2084,15 @@
|
|
|
2050
2084
|
for (y = 0; y < height; y++) {
|
|
2051
2085
|
for (x = 0; x < width; x++) {
|
|
2052
2086
|
i = 4 * (y * width + x);
|
|
2053
|
-
r = d[i + 0]
|
|
2054
|
-
g = d[i + 1]
|
|
2055
|
-
b = d[i + 2]
|
|
2056
|
-
a = d[i + 3]
|
|
2057
|
-
if (a < TRANSPARENT_ALPHA_THRESHOLD) {
|
|
2087
|
+
r = d[i + 0];
|
|
2088
|
+
g = d[i + 1];
|
|
2089
|
+
b = d[i + 2];
|
|
2090
|
+
a = d[i + 3];
|
|
2091
|
+
if (a / 255 < TRANSPARENT_ALPHA_THRESHOLD) {
|
|
2058
2092
|
transparentPixelsCount++;
|
|
2059
2093
|
}
|
|
2060
2094
|
else {
|
|
2061
|
-
l =
|
|
2095
|
+
l = getSRGBLightness(r, g, b);
|
|
2062
2096
|
if (l < DARK_LIGHTNESS_THRESHOLD) {
|
|
2063
2097
|
darkPixelsCount++;
|
|
2064
2098
|
}
|
|
@@ -2117,11 +2151,13 @@
|
|
|
2117
2151
|
if (index - possibleType.length >= 0) {
|
|
2118
2152
|
var possibleGradient = value.substring(index - possibleType.length, index);
|
|
2119
2153
|
if (possibleGradient === possibleType) {
|
|
2120
|
-
if (index - possibleType.length - 1
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2154
|
+
if (value.slice(index - possibleType.length - 10, index - possibleType.length - 1) === 'repeating') {
|
|
2155
|
+
typeGradient = "repeating-".concat(possibleType, "gradient");
|
|
2156
|
+
return true;
|
|
2157
|
+
}
|
|
2158
|
+
if (value.slice(index - possibleType.length - 8, index - possibleType.length - 1) === '-webkit') {
|
|
2159
|
+
typeGradient = "-webkit-".concat(possibleType, "gradient");
|
|
2160
|
+
return true;
|
|
2125
2161
|
}
|
|
2126
2162
|
typeGradient = "".concat(possibleType, "gradient");
|
|
2127
2163
|
return true;
|
|
@@ -2132,11 +2168,13 @@
|
|
|
2132
2168
|
return "break";
|
|
2133
2169
|
}
|
|
2134
2170
|
var _a = getParenthesesRange(value, index + gradientLength), start = _a.start, end = _a.end;
|
|
2135
|
-
var
|
|
2171
|
+
var match = value.substring(start + 1, end - 1);
|
|
2136
2172
|
startIndex = end + 1 + conicGradientLength;
|
|
2137
2173
|
result.push({
|
|
2138
|
-
|
|
2139
|
-
|
|
2174
|
+
typeGradient: typeGradient,
|
|
2175
|
+
match: match,
|
|
2176
|
+
offset: typeGradient.length + 2,
|
|
2177
|
+
index: index - typeGradient.length + gradientLength,
|
|
2140
2178
|
hasComma: true,
|
|
2141
2179
|
});
|
|
2142
2180
|
};
|
|
@@ -2329,7 +2367,7 @@
|
|
|
2329
2367
|
function getModifiedFallbackStyle(filter, _a) {
|
|
2330
2368
|
var strict = _a.strict;
|
|
2331
2369
|
var lines = [];
|
|
2332
|
-
var isMicrosoft =
|
|
2370
|
+
var isMicrosoft = ['microsoft.com', 'docs.microsoft.com'].includes(location.hostname);
|
|
2333
2371
|
lines.push("html, body, ".concat(strict ? "body :not(iframe)".concat(isMicrosoft ? ':not(div[style^="position:absolute;top:0;left:-"]' : '') : 'body > :not(iframe)', " {"));
|
|
2334
2372
|
lines.push(" background-color: ".concat(modifyBackgroundColor({ r: 255, g: 255, b: 255 }, filter), " !important;"));
|
|
2335
2373
|
lines.push(" border-color: ".concat(modifyBorderColor({ r: 64, g: 64, b: 64 }, filter), " !important;"));
|
|
@@ -2424,15 +2462,14 @@
|
|
|
2424
2462
|
return { match: match, index: valueIndex };
|
|
2425
2463
|
});
|
|
2426
2464
|
};
|
|
2427
|
-
var matches_1 =
|
|
2428
|
-
.concat(
|
|
2465
|
+
var matches_1 = gradients.map(function (i) { return (__assign({ type: 'gradient' }, i)); })
|
|
2466
|
+
.concat(getIndices(urls).map(function (i) { return (__assign({ type: 'url', offset: 0 }, i)); }))
|
|
2467
|
+
.sort(function (a, b) { return a.index > b.index ? 1 : -1; });
|
|
2429
2468
|
var getGradientModifier_1 = function (gradient) {
|
|
2430
|
-
var
|
|
2431
|
-
var content = gradient.content;
|
|
2432
|
-
var hasComma = gradient.hasComma;
|
|
2469
|
+
var typeGradient = gradient.typeGradient, match = gradient.match, hasComma = gradient.hasComma;
|
|
2433
2470
|
var partsRegex = /([^\(\),]+(\([^\(\)]*(\([^\(\)]*\)*[^\(\)]*)?\))?[^\(\),]*),?/g;
|
|
2434
2471
|
var colorStopRegex = /^(from|color-stop|to)\(([^\(\)]*?,\s*)?(.*?)\)$/;
|
|
2435
|
-
var parts = getMatches(partsRegex,
|
|
2472
|
+
var parts = getMatches(partsRegex, match, 1).map(function (part) {
|
|
2436
2473
|
part = part.trim();
|
|
2437
2474
|
var rgb = tryParseColor(part);
|
|
2438
2475
|
if (rgb) {
|
|
@@ -2453,7 +2490,7 @@
|
|
|
2453
2490
|
return function () { return part; };
|
|
2454
2491
|
});
|
|
2455
2492
|
return function (filter) {
|
|
2456
|
-
return "".concat(
|
|
2493
|
+
return "".concat(typeGradient, "(").concat(parts.map(function (modify) { return modify(filter); }).join(', '), ")").concat(hasComma ? ', ' : '');
|
|
2457
2494
|
};
|
|
2458
2495
|
};
|
|
2459
2496
|
var getURLModifier_1 = function (urlValue) {
|
|
@@ -2548,31 +2585,29 @@
|
|
|
2548
2585
|
return result;
|
|
2549
2586
|
};
|
|
2550
2587
|
var modifiers_1 = [];
|
|
2551
|
-
var
|
|
2588
|
+
var matchIndex_1 = 0;
|
|
2552
2589
|
matches_1.forEach(function (_a, i) {
|
|
2553
|
-
var type = _a.type,
|
|
2590
|
+
var type = _a.type, match = _a.match, index = _a.index, typeGradient = _a.typeGradient, hasComma = _a.hasComma, offset = _a.offset;
|
|
2591
|
+
var matchStart = index;
|
|
2592
|
+
var prefixStart = matchIndex_1;
|
|
2593
|
+
var matchEnd = matchStart + match.length + offset;
|
|
2594
|
+
matchIndex_1 = matchEnd;
|
|
2595
|
+
prefixStart !== matchStart && modifiers_1.push(function () { return value.substring(prefixStart, matchStart); });
|
|
2554
2596
|
if (type === 'url') {
|
|
2555
|
-
var match = urlInfo.match;
|
|
2556
|
-
var matchStart_1 = urlInfo.index;
|
|
2557
|
-
var prefixStart_1 = index_1;
|
|
2558
|
-
var matchEnd_1 = matchStart_1 + match.length;
|
|
2559
|
-
index_1 = matchEnd_1;
|
|
2560
|
-
modifiers_1.push(function () { return value.substring(prefixStart_1, matchStart_1); });
|
|
2561
2597
|
modifiers_1.push(getURLModifier_1(match));
|
|
2562
|
-
if (i === matches_1.length - 1) {
|
|
2563
|
-
modifiers_1.push(function () { return value.substring(matchEnd_1); });
|
|
2564
|
-
}
|
|
2565
2598
|
}
|
|
2566
2599
|
else if (type === 'gradient') {
|
|
2567
|
-
modifiers_1.push(getGradientModifier_1(
|
|
2600
|
+
modifiers_1.push(getGradientModifier_1({ match: match, index: index, typeGradient: typeGradient, hasComma: hasComma, offset: offset }));
|
|
2601
|
+
}
|
|
2602
|
+
if (i === matches_1.length - 1) {
|
|
2603
|
+
modifiers_1.push(function () { return value.substring(matchEnd); });
|
|
2568
2604
|
}
|
|
2569
2605
|
});
|
|
2570
2606
|
return function (filter) {
|
|
2571
2607
|
var results = modifiers_1.filter(Boolean).map(function (modify) { return modify(filter); });
|
|
2572
2608
|
if (results.some(function (r) { return r instanceof Promise; })) {
|
|
2573
|
-
return Promise.all(results)
|
|
2574
|
-
.
|
|
2575
|
-
return asyncResults.join('');
|
|
2609
|
+
return Promise.all(results).then(function (asyncResults) {
|
|
2610
|
+
return asyncResults.filter(Boolean).join('');
|
|
2576
2611
|
});
|
|
2577
2612
|
}
|
|
2578
2613
|
return results.join('');
|
|
@@ -2585,14 +2620,14 @@
|
|
|
2585
2620
|
}
|
|
2586
2621
|
function getShadowModifierWithInfo(value) {
|
|
2587
2622
|
try {
|
|
2588
|
-
var
|
|
2623
|
+
var index_1 = 0;
|
|
2589
2624
|
var colorMatches_1 = getMatches(/(^|\s)(?!calc)([a-z]+\(.+?\)|#[0-9a-f]+|[a-z]+)(.*?(inset|outset)?($|,))/ig, value, 2);
|
|
2590
2625
|
var notParsed_1 = 0;
|
|
2591
2626
|
var modifiers_2 = colorMatches_1.map(function (match, i) {
|
|
2592
|
-
var prefixIndex =
|
|
2593
|
-
var matchIndex = value.indexOf(match,
|
|
2627
|
+
var prefixIndex = index_1;
|
|
2628
|
+
var matchIndex = value.indexOf(match, index_1);
|
|
2594
2629
|
var matchEnd = matchIndex + match.length;
|
|
2595
|
-
|
|
2630
|
+
index_1 = matchEnd;
|
|
2596
2631
|
var rgb = tryParseColor(match);
|
|
2597
2632
|
if (!rgb) {
|
|
2598
2633
|
notParsed_1++;
|
|
@@ -3191,7 +3226,7 @@
|
|
|
3191
3226
|
splitted.forEach(function (number) {
|
|
3192
3227
|
resultInRGB_1 += "".concat(number.trim(), ", ");
|
|
3193
3228
|
});
|
|
3194
|
-
resultInRGB_1 = resultInRGB_1.
|
|
3229
|
+
resultInRGB_1 = resultInRGB_1.substring(0, resultInRGB_1.length - 2);
|
|
3195
3230
|
resultInRGB_1 += ')';
|
|
3196
3231
|
return { isRaw: true, color: resultInRGB_1 };
|
|
3197
3232
|
}
|
|
@@ -3877,6 +3912,19 @@
|
|
|
3877
3912
|
}
|
|
3878
3913
|
|
|
3879
3914
|
var STYLE_SELECTOR = 'style, link[rel*="stylesheet" i]:not([disabled])';
|
|
3915
|
+
function isFontsGoogleApiStyle(element) {
|
|
3916
|
+
if (!element.href) {
|
|
3917
|
+
return false;
|
|
3918
|
+
}
|
|
3919
|
+
try {
|
|
3920
|
+
var elementURL = new URL(element.href);
|
|
3921
|
+
return elementURL.hostname === 'fonts.googleapis.com';
|
|
3922
|
+
}
|
|
3923
|
+
catch (err) {
|
|
3924
|
+
logInfo("Couldn't construct ".concat(element.href, " as URL"));
|
|
3925
|
+
return false;
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3880
3928
|
function shouldManageStyle(element) {
|
|
3881
3929
|
return (((element instanceof HTMLStyleElement) ||
|
|
3882
3930
|
(element instanceof SVGStyleElement) ||
|
|
@@ -3884,7 +3932,8 @@
|
|
|
3884
3932
|
element.rel &&
|
|
3885
3933
|
element.rel.toLowerCase().includes('stylesheet') &&
|
|
3886
3934
|
!element.disabled &&
|
|
3887
|
-
(isFirefox ? !element.href.startsWith('moz-extension://') : true)
|
|
3935
|
+
(isFirefox ? !element.href.startsWith('moz-extension://') : true) &&
|
|
3936
|
+
!isFontsGoogleApiStyle(element))) &&
|
|
3888
3937
|
!element.classList.contains('darkreader') &&
|
|
3889
3938
|
element.media.toLowerCase() !== 'print' &&
|
|
3890
3939
|
!element.classList.contains('stylus'));
|
|
@@ -4129,15 +4178,6 @@
|
|
|
4129
4178
|
}
|
|
4130
4179
|
cancelAsyncOperations = false;
|
|
4131
4180
|
function removeCSSRulesFromSheet(sheet) {
|
|
4132
|
-
try {
|
|
4133
|
-
if (sheet.replaceSync) {
|
|
4134
|
-
sheet.replaceSync('');
|
|
4135
|
-
return;
|
|
4136
|
-
}
|
|
4137
|
-
}
|
|
4138
|
-
catch (err) {
|
|
4139
|
-
logWarn('Could not use fastpath for removing rules from stylesheet', err);
|
|
4140
|
-
}
|
|
4141
4181
|
for (var i = sheet.cssRules.length - 1; i >= 0; i--) {
|
|
4142
4182
|
sheet.deleteRule(i);
|
|
4143
4183
|
}
|
|
@@ -4759,7 +4799,18 @@
|
|
|
4759
4799
|
var removeRuleDescriptor = Object.getOwnPropertyDescriptor(CSSStyleSheet.prototype, 'removeRule');
|
|
4760
4800
|
var documentStyleSheetsDescriptor = enableStyleSheetsProxy ?
|
|
4761
4801
|
Object.getOwnPropertyDescriptor(Document.prototype, 'styleSheets') : null;
|
|
4762
|
-
var shouldWrapHTMLElement =
|
|
4802
|
+
var shouldWrapHTMLElement = [
|
|
4803
|
+
'baidu.com',
|
|
4804
|
+
'baike.baidu.com',
|
|
4805
|
+
'ditu.baidu.com',
|
|
4806
|
+
'map.baidu.com',
|
|
4807
|
+
'maps.baidu.com',
|
|
4808
|
+
'haokan.baidu.com',
|
|
4809
|
+
'pan.baidu.com',
|
|
4810
|
+
'passport.baidu.com',
|
|
4811
|
+
'tieba.baidu.com',
|
|
4812
|
+
'www.baidu.com'
|
|
4813
|
+
].includes(location.hostname);
|
|
4763
4814
|
var getElementsByTagNameDescriptor = shouldWrapHTMLElement ?
|
|
4764
4815
|
Object.getOwnPropertyDescriptor(Element.prototype, 'getElementsByTagName') : null;
|
|
4765
4816
|
var cleanUp = function () {
|
|
@@ -4814,9 +4865,13 @@
|
|
|
4814
4865
|
var _this = this;
|
|
4815
4866
|
var getCurrentValue = function () {
|
|
4816
4867
|
var docSheets = documentStyleSheetsDescriptor.get.call(_this);
|
|
4817
|
-
|
|
4868
|
+
var filteredSheets = __spreadArray([], __read(docSheets), false).filter(function (styleSheet) {
|
|
4818
4869
|
return !styleSheet.ownerNode.classList.contains('darkreader');
|
|
4819
|
-
})
|
|
4870
|
+
});
|
|
4871
|
+
filteredSheets.item = function (item) {
|
|
4872
|
+
return filteredSheets[item];
|
|
4873
|
+
};
|
|
4874
|
+
return Object.setPrototypeOf(filteredSheets, StyleSheetList.prototype);
|
|
4820
4875
|
};
|
|
4821
4876
|
var elements = getCurrentValue();
|
|
4822
4877
|
var styleSheetListBehavior = {
|
|
@@ -4841,7 +4896,7 @@
|
|
|
4841
4896
|
var elements = getCurrentElementValue();
|
|
4842
4897
|
var nodeListBehavior = {
|
|
4843
4898
|
get: function (_, property) {
|
|
4844
|
-
return getCurrentElementValue()[Number(property)];
|
|
4899
|
+
return getCurrentElementValue()[Number(property) || property];
|
|
4845
4900
|
}
|
|
4846
4901
|
};
|
|
4847
4902
|
elements = new Proxy(elements, nodeListBehavior);
|
|
@@ -4917,20 +4972,16 @@
|
|
|
4917
4972
|
document.head.insertBefore(textStyle, fallbackStyle.nextSibling);
|
|
4918
4973
|
setupNodePositionWatcher(textStyle, 'text');
|
|
4919
4974
|
var invertStyle = createOrUpdateStyle('darkreader--invert');
|
|
4920
|
-
var invertStyleContent = '';
|
|
4921
4975
|
if (fixes && Array.isArray(fixes.invert) && fixes.invert.length > 0) {
|
|
4922
|
-
|
|
4976
|
+
invertStyle.textContent = [
|
|
4923
4977
|
"".concat(fixes.invert.join(', '), " {"),
|
|
4924
4978
|
" filter: ".concat(getCSSFilterValue(__assign(__assign({}, filter), { contrast: filter.mode === 0 ? filter.contrast : clamp(filter.contrast - 10, 0, 100) })), " !important;"),
|
|
4925
4979
|
'}',
|
|
4926
|
-
'',
|
|
4927
4980
|
].join('\n');
|
|
4928
4981
|
}
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
invertStyleContent += "img { filter: ".concat(imageFilter, " !important;\n");
|
|
4982
|
+
else {
|
|
4983
|
+
invertStyle.textContent = '';
|
|
4932
4984
|
}
|
|
4933
|
-
invertStyle.textContent = invertStyleContent;
|
|
4934
4985
|
document.head.insertBefore(invertStyle, textStyle.nextSibling);
|
|
4935
4986
|
setupNodePositionWatcher(invertStyle, 'invert');
|
|
4936
4987
|
var inlineStyle = createOrUpdateStyle('darkreader--inline');
|
|
@@ -5119,7 +5170,7 @@
|
|
|
5119
5170
|
createDynamicStyleOverrides();
|
|
5120
5171
|
watchForUpdates();
|
|
5121
5172
|
}
|
|
5122
|
-
if (document.hidden) {
|
|
5173
|
+
if (document.hidden && !filter.immediateModify) {
|
|
5123
5174
|
watchForDocumentVisibility(runDynamicStyle);
|
|
5124
5175
|
}
|
|
5125
5176
|
else {
|
|
@@ -5128,13 +5179,18 @@
|
|
|
5128
5179
|
changeMetaThemeColorWhenAvailable(filter);
|
|
5129
5180
|
}
|
|
5130
5181
|
function handleAdoptedStyleSheets(node) {
|
|
5131
|
-
|
|
5132
|
-
if (node.adoptedStyleSheets
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5182
|
+
try {
|
|
5183
|
+
if (Array.isArray(node.adoptedStyleSheets)) {
|
|
5184
|
+
if (node.adoptedStyleSheets.length > 0) {
|
|
5185
|
+
var newManger = createAdoptedStyleSheetOverride(node);
|
|
5186
|
+
adoptedStyleManagers.push(newManger);
|
|
5187
|
+
newManger.render(filter, ignoredImageAnalysisSelectors);
|
|
5188
|
+
}
|
|
5136
5189
|
}
|
|
5137
5190
|
}
|
|
5191
|
+
catch (err) {
|
|
5192
|
+
logWarn('Error occured in handleAdoptedStyleSheets: ', err);
|
|
5193
|
+
}
|
|
5138
5194
|
}
|
|
5139
5195
|
function watchForUpdates() {
|
|
5140
5196
|
var managedStyles = Array.from(styleManagers.keys());
|
|
@@ -5217,6 +5273,11 @@
|
|
|
5217
5273
|
ignoredImageAnalysisSelectors = [];
|
|
5218
5274
|
ignoredInlineSelectors = [];
|
|
5219
5275
|
}
|
|
5276
|
+
if (filter.immediateModify) {
|
|
5277
|
+
setIsDOMReady(function () {
|
|
5278
|
+
return true;
|
|
5279
|
+
});
|
|
5280
|
+
}
|
|
5220
5281
|
isIFrame$1 = iframe;
|
|
5221
5282
|
if (document.head) {
|
|
5222
5283
|
if (isAnotherDarkReaderInstanceActive()) {
|
package/package.json
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "darkreader",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.52",
|
|
4
4
|
"description": "Dark mode for every website",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"api": "node tasks/build.js --api",
|
|
7
7
|
"benchmark-server": "node tests/benchmark-server/index.js",
|
|
8
8
|
"build": "node tasks/build.js --release",
|
|
9
|
-
"
|
|
9
|
+
"build:all": "node tasks/build.js --debug --release --api",
|
|
10
|
+
"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'",
|
|
10
11
|
"debug": "node tasks/build.js --debug",
|
|
11
12
|
"debug:watch": "node tasks/build.js --debug --watch",
|
|
12
|
-
"lint": "eslint --ignore-pattern
|
|
13
|
+
"lint": "eslint --ignore-pattern '!.eslintplugin.js' -- 'src/**/*.ts' 'src/**/*.tsx' 'tasks/**/*.js' 'tests/**/*.ts' 'tests/[!coverage]**/*.js' 'index.d.ts' '.eslintplugin.js'",
|
|
14
|
+
"lint:bundle": "(node ./tasks/check-exists.js ./build/debug/chrome || node tasks/build.js --debug --api) && eslint -- 'build/debug/chrome/**/*.js' 'darkreader.js'",
|
|
13
15
|
"prepublishOnly": "npm test && npm run api",
|
|
14
16
|
"release": "npm test && npm run lint && node tasks/build.js --release",
|
|
15
|
-
"test": "
|
|
16
|
-
"test:
|
|
17
|
-
"test:
|
|
18
|
-
"test:
|
|
19
|
-
"test:
|
|
20
|
-
"test:
|
|
21
|
-
"test:
|
|
22
|
-
"test:
|
|
23
|
-
"test:inject": "node tests/inject/
|
|
24
|
-
"test:
|
|
25
|
-
"test:
|
|
26
|
-
"test:
|
|
17
|
+
"test": "npm run test:unit",
|
|
18
|
+
"test:all": "npm run test:unit; npm run test:browser; npm run test:inject; npm run test:project",
|
|
19
|
+
"test:browser": "npm run debug && npm run test:chrome && npm run test:firefox",
|
|
20
|
+
"test:chrome": "npm run debug && jest --config=tests/browser/jest.config.js --runInBand",
|
|
21
|
+
"test:ci": "npm run test:unit",
|
|
22
|
+
"test:coverage": "jest --config=tests/unit/jest.config.js --coverage",
|
|
23
|
+
"test:firefox": " npm run debug && jest --config=tests/browser/jest.config.firefox.js --runInBand",
|
|
24
|
+
"test:inject": "node --max-old-space-size=3072 node_modules/.bin/karma start ./tests/inject/karma.conf.js",
|
|
25
|
+
"test:inject:debug": "node --max-old-space-size=3072 node_modules/.bin/karma start ./tests/inject/karma.conf.js --debug",
|
|
26
|
+
"test:project": "jest --config=tests/project/jest.config.js",
|
|
27
|
+
"test:unit": "jest --config=tests/unit/jest.config.js",
|
|
28
|
+
"test:unit:debug": "node --inspect-brk ./node_modules/jest/bin/jest --config=tests/unit/jest.config.js --runInBand --no-cache --watch",
|
|
29
|
+
"test:update-snapshots": "npm run test -- --updateSnapshot && npm run test:project -- --updateSnapshot",
|
|
30
|
+
"translate-line": "node ./tasks/translate.js --line"
|
|
27
31
|
},
|
|
28
32
|
"main": "darkreader.js",
|
|
29
33
|
"repository": {
|
|
@@ -44,20 +48,6 @@
|
|
|
44
48
|
"accessibility",
|
|
45
49
|
"eye-care"
|
|
46
50
|
],
|
|
47
|
-
"browserslist": [
|
|
48
|
-
"supports es5",
|
|
49
|
-
"not ie > 0",
|
|
50
|
-
"not ie_mob > 0",
|
|
51
|
-
"not op_mini all",
|
|
52
|
-
"not op_mob < 59",
|
|
53
|
-
"not android < 50",
|
|
54
|
-
"not ios_saf < 6",
|
|
55
|
-
"not safari < 9.3",
|
|
56
|
-
"not opera < 36",
|
|
57
|
-
"not chrome < 49",
|
|
58
|
-
"not firefox < 33",
|
|
59
|
-
"not edge <= 18"
|
|
60
|
-
],
|
|
61
51
|
"homepage": "https://darkreader.org/",
|
|
62
52
|
"funding": {
|
|
63
53
|
"type": "opencollective",
|
|
@@ -65,42 +55,48 @@
|
|
|
65
55
|
},
|
|
66
56
|
"devDependencies": {
|
|
67
57
|
"@rollup/plugin-node-resolve": "13.1.3",
|
|
68
|
-
"@rollup/plugin-replace": "
|
|
69
|
-
"@rollup/plugin-typescript": "8.3.
|
|
70
|
-
"@rollup/pluginutils": "4.
|
|
71
|
-
"@types/chrome": "0.0.
|
|
72
|
-
"@types/
|
|
73
|
-
"@types/
|
|
74
|
-
"@types/
|
|
58
|
+
"@rollup/plugin-replace": "4.0.0",
|
|
59
|
+
"@rollup/plugin-typescript": "8.3.1",
|
|
60
|
+
"@rollup/pluginutils": "4.2.0",
|
|
61
|
+
"@types/chrome": "0.0.180",
|
|
62
|
+
"@types/eslint": "8.4.1",
|
|
63
|
+
"@types/jasmine": "4.0.0",
|
|
64
|
+
"@types/jest": "27.4.1",
|
|
65
|
+
"@types/karma": "6.3.3",
|
|
66
|
+
"@types/karma-coverage": "2.0.1",
|
|
67
|
+
"@types/node": "17.0.23",
|
|
75
68
|
"@types/offscreencanvas": "2019.6.4",
|
|
76
|
-
"@
|
|
77
|
-
"@typescript-eslint/
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"eslint": "
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "5.16.0",
|
|
70
|
+
"@typescript-eslint/parser": "5.16.0",
|
|
71
|
+
"chokidar": "3.5.3",
|
|
72
|
+
"eslint": "8.11.0",
|
|
73
|
+
"eslint-plugin-compat": "4.0.2",
|
|
81
74
|
"eslint-plugin-import": "2.25.4",
|
|
82
75
|
"eslint-plugin-local": "1.0.0",
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"karma
|
|
76
|
+
"get-stream": "6.0.1",
|
|
77
|
+
"globby": "13.1.1",
|
|
78
|
+
"jasmine-core": "4.0.1",
|
|
79
|
+
"jest": "27.5.1",
|
|
80
|
+
"jest-extended": "2.0.0",
|
|
81
|
+
"karma": "6.3.17",
|
|
82
|
+
"karma-chrome-launcher": "3.1.1",
|
|
83
|
+
"karma-coverage": "2.2.0",
|
|
89
84
|
"karma-firefox-launcher": "2.1.2",
|
|
90
85
|
"karma-jasmine": "4.0.1",
|
|
91
|
-
"karma-rollup-preprocessor": "7.0.
|
|
86
|
+
"karma-rollup-preprocessor": "7.0.8",
|
|
92
87
|
"karma-safari-launcher": "1.0.0",
|
|
88
|
+
"karma-spec-reporter": "0.0.33",
|
|
93
89
|
"less": "4.1.2",
|
|
94
|
-
"malevic": "0.
|
|
95
|
-
"prettier": "2.
|
|
96
|
-
"puppeteer-core": "13.
|
|
97
|
-
"rollup": "2.
|
|
90
|
+
"malevic": "0.19.1",
|
|
91
|
+
"prettier": "2.6.1",
|
|
92
|
+
"puppeteer-core": "13.5.1",
|
|
93
|
+
"rollup": "2.70.1",
|
|
98
94
|
"rollup-plugin-istanbul2": "2.0.2",
|
|
99
|
-
"ts-jest": "27.1.
|
|
95
|
+
"ts-jest": "27.1.4",
|
|
100
96
|
"tslib": "2.3.1",
|
|
101
|
-
"typescript": "4.
|
|
102
|
-
"web-ext": "6.
|
|
103
|
-
"ws": "8.
|
|
97
|
+
"typescript": "4.6.3",
|
|
98
|
+
"web-ext": "6.8.0",
|
|
99
|
+
"ws": "8.5.0",
|
|
104
100
|
"yazl": "2.5.1"
|
|
105
101
|
}
|
|
106
102
|
}
|