darkreader 4.9.46 → 4.9.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +9 -10
  2. package/darkreader.js +208 -206
  3. package/package.json +20 -19
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 the eyestrain</strong> while browsing the web.</p>
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 generate a `build/release/darkreader-chrome.zip` file that is useable in a Chromium-based browser and also a `build/release/darkreader-firefox.xpi` file that is useable in Firefox.
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, that darkreader will add the `chrome` object onto the `window` object, these are to stub certain functions that
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 doesn't allow using GitHub as a CDN. Storing these files and making requests to other resources would be expensive and look suspicious. As such, changes are included with each new Dark Reader release.
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 by the following steps:
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 for maintenance and 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>
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.46
2
+ * Dark Reader v4.9.51
3
3
  * https://darkreader.org/
4
4
  */
5
5
 
@@ -121,6 +121,7 @@
121
121
  UI_SET_SHORTCUT: 'ui-set-shortcut',
122
122
  UI_TOGGLE_ACTIVE_TAB: 'ui-toggle-active-tab',
123
123
  UI_MARK_NEWS_AS_READ: 'ui-mark-news-as-read',
124
+ UI_MARK_NEWS_AS_DISPLAYED: 'ui-mark-news-as-displayed',
124
125
  UI_LOAD_CONFIG: 'ui-load-config',
125
126
  UI_APPLY_DEV_DYNAMIC_THEME_FIXES: 'ui-apply-dev-dynamic-theme-fixes',
126
127
  UI_RESET_DEV_DYNAMIC_THEME_FIXES: 'ui-reset-dev-dynamic-theme-fixes',
@@ -192,7 +193,7 @@
192
193
  }
193
194
  var el = document.createElement('div');
194
195
  el.setAttribute('style', 'color-scheme: dark');
195
- return el.style.colorScheme === 'dark';
196
+ return el.style && el.style.colorScheme === 'dark';
196
197
  })();
197
198
 
198
199
  function getOKResponse(url, mimeType, origin) {
@@ -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();
@@ -927,7 +928,7 @@
927
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');
931
932
  }
932
933
  function getCSSBaseBath(url) {
933
934
  var cssURL = parseURL(url);
@@ -954,6 +955,159 @@
954
955
  return $css.replace(fontFaceRegex, '');
955
956
  }
956
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
+
957
1111
  function hslToRGB(_a) {
958
1112
  var h = _a.h, s = _a.s, l = _a.l, _b = _a.a, a = _b === void 0 ? 1 : _b;
959
1113
  if (s === 0) {
@@ -1150,69 +1304,21 @@
1150
1304
  a: 1
1151
1305
  };
1152
1306
  }
1153
- var isCharDigit = function (char) { return char >= '0' && char <= '9'; };
1154
- var getAmountOfDigits = function (number) { return Math.floor(Math.log10(number)) + 1; };
1155
1307
  function lowerCalcExpression(color) {
1156
1308
  var searchIndex = 0;
1157
1309
  var replaceBetweenIndices = function (start, end, replacement) {
1158
1310
  color = color.substring(0, start) + replacement + color.substring(end);
1159
1311
  };
1160
- var getNumber = function () {
1161
- var resultNumber = 0;
1162
- for (var i = 1; i < 4; i++) {
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 !== '-') {
1312
+ while ((searchIndex = color.indexOf('calc(')) !== -1) {
1313
+ var range = getParenthesesRange(color, searchIndex);
1314
+ if (!range) {
1197
1315
  break;
1198
1316
  }
1199
- searchIndex++;
1200
- if (color[searchIndex + 1] !== ' ') {
1201
- break;
1202
- }
1203
- searchIndex++;
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);
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 ? '%' : ''));
1216
1322
  }
1217
1323
  return color;
1218
1324
  }
@@ -1425,92 +1531,6 @@
1425
1531
  return result;
1426
1532
  }
1427
1533
 
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
1534
  function createFilterMatrix(config) {
1515
1535
  var m = Matrix.identity();
1516
1536
  if (config.sepia !== 0) {
@@ -2148,11 +2168,13 @@
2148
2168
  return "break";
2149
2169
  }
2150
2170
  var _a = getParenthesesRange(value, index + gradientLength), start = _a.start, end = _a.end;
2151
- var content = value.substring(start + 1, end - 1);
2171
+ var match = value.substring(start + 1, end - 1);
2152
2172
  startIndex = end + 1 + conicGradientLength;
2153
2173
  result.push({
2154
- type: typeGradient,
2155
- content: content,
2174
+ typeGradient: typeGradient,
2175
+ match: match,
2176
+ offset: typeGradient.length + 2,
2177
+ index: index - typeGradient.length + gradientLength,
2156
2178
  hasComma: true,
2157
2179
  });
2158
2180
  };
@@ -2440,15 +2462,14 @@
2440
2462
  return { match: match, index: valueIndex };
2441
2463
  });
2442
2464
  };
2443
- var matches_1 = getIndices(urls).map(function (i) { return ({ type: 'url', urlInfo: i }); })
2444
- .concat(gradients.map(function (i) { return ({ type: 'gradient', gradientInfo: i }); }));
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; });
2445
2468
  var getGradientModifier_1 = function (gradient) {
2446
- var type = gradient.type;
2447
- var content = gradient.content;
2448
- var hasComma = gradient.hasComma;
2469
+ var typeGradient = gradient.typeGradient, match = gradient.match, hasComma = gradient.hasComma;
2449
2470
  var partsRegex = /([^\(\),]+(\([^\(\)]*(\([^\(\)]*\)*[^\(\)]*)?\))?[^\(\),]*),?/g;
2450
2471
  var colorStopRegex = /^(from|color-stop|to)\(([^\(\)]*?,\s*)?(.*?)\)$/;
2451
- var parts = getMatches(partsRegex, content, 1).map(function (part) {
2472
+ var parts = getMatches(partsRegex, match, 1).map(function (part) {
2452
2473
  part = part.trim();
2453
2474
  var rgb = tryParseColor(part);
2454
2475
  if (rgb) {
@@ -2469,7 +2490,7 @@
2469
2490
  return function () { return part; };
2470
2491
  });
2471
2492
  return function (filter) {
2472
- return "".concat(type, "(").concat(parts.map(function (modify) { return modify(filter); }).join(', '), ")").concat(hasComma ? ', ' : '');
2493
+ return "".concat(typeGradient, "(").concat(parts.map(function (modify) { return modify(filter); }).join(', '), ")").concat(hasComma ? ', ' : '');
2473
2494
  };
2474
2495
  };
2475
2496
  var getURLModifier_1 = function (urlValue) {
@@ -2564,45 +2585,29 @@
2564
2585
  return result;
2565
2586
  };
2566
2587
  var modifiers_1 = [];
2567
- var index_1 = 0;
2588
+ var matchIndex_1 = 0;
2568
2589
  matches_1.forEach(function (_a, i) {
2569
- var type = _a.type, urlInfo = _a.urlInfo, gradientInfo = _a.gradientInfo;
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); });
2570
2596
  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
2597
  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
2598
  }
2582
2599
  else if (type === 'gradient') {
2583
- modifiers_1.push(getGradientModifier_1(gradientInfo));
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); });
2584
2604
  }
2585
2605
  });
2586
2606
  return function (filter) {
2587
2607
  var results = modifiers_1.filter(Boolean).map(function (modify) { return modify(filter); });
2588
2608
  if (results.some(function (r) { return r instanceof Promise; })) {
2589
- return Promise.all(results)
2590
- .then(function (asyncResults) {
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;
2609
+ return Promise.all(results).then(function (asyncResults) {
2610
+ return asyncResults.filter(Boolean).join('');
2606
2611
  });
2607
2612
  }
2608
2613
  return results.join('');
@@ -2615,14 +2620,14 @@
2615
2620
  }
2616
2621
  function getShadowModifierWithInfo(value) {
2617
2622
  try {
2618
- var index_2 = 0;
2623
+ var index_1 = 0;
2619
2624
  var colorMatches_1 = getMatches(/(^|\s)(?!calc)([a-z]+\(.+?\)|#[0-9a-f]+|[a-z]+)(.*?(inset|outset)?($|,))/ig, value, 2);
2620
2625
  var notParsed_1 = 0;
2621
2626
  var modifiers_2 = colorMatches_1.map(function (match, i) {
2622
- var prefixIndex = index_2;
2623
- var matchIndex = value.indexOf(match, index_2);
2627
+ var prefixIndex = index_1;
2628
+ var matchIndex = value.indexOf(match, index_1);
2624
2629
  var matchEnd = matchIndex + match.length;
2625
- index_2 = matchEnd;
2630
+ index_1 = matchEnd;
2626
2631
  var rgb = tryParseColor(match);
2627
2632
  if (!rgb) {
2628
2633
  notParsed_1++;
@@ -3221,7 +3226,7 @@
3221
3226
  splitted.forEach(function (number) {
3222
3227
  resultInRGB_1 += "".concat(number.trim(), ", ");
3223
3228
  });
3224
- resultInRGB_1 = resultInRGB_1.substr(0, resultInRGB_1.length - 2);
3229
+ resultInRGB_1 = resultInRGB_1.substring(0, resultInRGB_1.length - 2);
3225
3230
  resultInRGB_1 += ')';
3226
3231
  return { isRaw: true, color: resultInRGB_1 };
3227
3232
  }
@@ -3914,7 +3919,8 @@
3914
3919
  element.rel &&
3915
3920
  element.rel.toLowerCase().includes('stylesheet') &&
3916
3921
  !element.disabled &&
3917
- (isFirefox ? !element.href.startsWith('moz-extension://') : true))) &&
3922
+ (isFirefox ? !element.href.startsWith('moz-extension://') : true) &&
3923
+ !element.href.startsWith('https://fonts.googleapis.com'))) &&
3918
3924
  !element.classList.contains('darkreader') &&
3919
3925
  element.media.toLowerCase() !== 'print' &&
3920
3926
  !element.classList.contains('stylus'));
@@ -4159,15 +4165,6 @@
4159
4165
  }
4160
4166
  cancelAsyncOperations = false;
4161
4167
  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
4168
  for (var i = sheet.cssRules.length - 1; i >= 0; i--) {
4172
4169
  sheet.deleteRule(i);
4173
4170
  }
@@ -5158,13 +5155,18 @@
5158
5155
  changeMetaThemeColorWhenAvailable(filter);
5159
5156
  }
5160
5157
  function handleAdoptedStyleSheets(node) {
5161
- if (Array.isArray(node.adoptedStyleSheets)) {
5162
- if (node.adoptedStyleSheets.length > 0) {
5163
- var newManger = createAdoptedStyleSheetOverride(node);
5164
- adoptedStyleManagers.push(newManger);
5165
- newManger.render(filter, ignoredImageAnalysisSelectors);
5158
+ try {
5159
+ if (Array.isArray(node.adoptedStyleSheets)) {
5160
+ if (node.adoptedStyleSheets.length > 0) {
5161
+ var newManger = createAdoptedStyleSheetOverride(node);
5162
+ adoptedStyleManagers.push(newManger);
5163
+ newManger.render(filter, ignoredImageAnalysisSelectors);
5164
+ }
5166
5165
  }
5167
5166
  }
5167
+ catch (err) {
5168
+ logWarn('Error occured in handleAdoptedStyleSheets: ', err);
5169
+ }
5168
5170
  }
5169
5171
  function watchForUpdates() {
5170
5172
  var managedStyles = Array.from(styleManagers.keys());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "darkreader",
3
- "version": "4.9.46",
3
+ "version": "4.9.51",
4
4
  "description": "Dark mode for every website",
5
5
  "scripts": {
6
6
  "api": "node tasks/build.js --api",
@@ -17,12 +17,12 @@
17
17
  "test": "npm run test:unit",
18
18
  "test:all": "npm run test:unit; npm run test:browser; npm run test:inject; npm run test:project",
19
19
  "test:browser": "npm run debug && npm run test:chrome && npm run test:firefox",
20
- "test:chrome": "npm run debug && TEST_BROWSER=chrome jest --config=tests/browser/jest.config.js --runInBand",
20
+ "test:chrome": "npm run debug && jest --config=tests/browser/jest.config.js --runInBand",
21
21
  "test:ci": "npm run test:unit",
22
22
  "test:coverage": "jest --config=tests/unit/jest.config.js --coverage",
23
- "test:firefox": "npm run debug && TEST_BROWSER=firefox jest --config=tests/browser/jest.config.js --runInBand",
24
- "test:inject": "node tests/inject/run.js",
25
- "test:inject:debug": "node tests/inject/run.js --debug",
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
26
  "test:project": "jest --config=tests/project/jest.config.js",
27
27
  "test:unit": "jest --config=tests/unit/jest.config.js",
28
28
  "test:unit:debug": "node --inspect-brk ./node_modules/jest/bin/jest --config=tests/unit/jest.config.js --runInBand --no-cache --watch",
@@ -56,19 +56,19 @@
56
56
  "@rollup/plugin-node-resolve": "13.1.3",
57
57
  "@rollup/plugin-replace": "4.0.0",
58
58
  "@rollup/plugin-typescript": "8.3.1",
59
- "@rollup/pluginutils": "4.1.2",
60
- "@types/chrome": "0.0.179",
59
+ "@rollup/pluginutils": "4.2.0",
60
+ "@types/chrome": "0.0.180",
61
61
  "@types/eslint": "8.4.1",
62
- "@types/jasmine": "3.10.3",
62
+ "@types/jasmine": "4.0.0",
63
63
  "@types/jest": "27.4.1",
64
64
  "@types/karma": "6.3.3",
65
65
  "@types/karma-coverage": "2.0.1",
66
- "@types/node": "17.0.21",
66
+ "@types/node": "17.0.23",
67
67
  "@types/offscreencanvas": "2019.6.4",
68
- "@typescript-eslint/eslint-plugin": "5.13.0",
69
- "@typescript-eslint/parser": "5.13.0",
68
+ "@typescript-eslint/eslint-plugin": "5.16.0",
69
+ "@typescript-eslint/parser": "5.16.0",
70
70
  "chokidar": "3.5.3",
71
- "eslint": "8.10.0",
71
+ "eslint": "8.11.0",
72
72
  "eslint-plugin-compat": "4.0.2",
73
73
  "eslint-plugin-import": "2.25.4",
74
74
  "eslint-plugin-local": "1.0.0",
@@ -78,22 +78,23 @@
78
78
  "jest": "27.5.1",
79
79
  "jest-extended": "2.0.0",
80
80
  "karma": "6.3.17",
81
- "karma-chrome-launcher": "3.1.0",
81
+ "karma-chrome-launcher": "3.1.1",
82
82
  "karma-coverage": "2.2.0",
83
83
  "karma-firefox-launcher": "2.1.2",
84
84
  "karma-jasmine": "4.0.1",
85
85
  "karma-rollup-preprocessor": "7.0.8",
86
86
  "karma-safari-launcher": "1.0.0",
87
+ "karma-spec-reporter": "0.0.33",
87
88
  "less": "4.1.2",
88
89
  "malevic": "0.19.1",
89
- "prettier": "2.5.1",
90
- "puppeteer-core": "13.4.1",
91
- "rollup": "2.69.0",
90
+ "prettier": "2.6.1",
91
+ "puppeteer-core": "13.5.1",
92
+ "rollup": "2.70.1",
92
93
  "rollup-plugin-istanbul2": "2.0.2",
93
- "ts-jest": "27.1.3",
94
+ "ts-jest": "27.1.4",
94
95
  "tslib": "2.3.1",
95
- "typescript": "4.6.2",
96
- "web-ext": "6.7.0",
96
+ "typescript": "4.6.3",
97
+ "web-ext": "6.8.0",
97
98
  "ws": "8.5.0",
98
99
  "yazl": "2.5.1"
99
100
  }