darkreader 4.9.67 → 4.9.71

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 +33 -6
  2. package/darkreader.js +83 -75
  3. package/package.json +25 -25
package/README.md CHANGED
@@ -41,7 +41,7 @@ You can build Dark Reader with alternative runtime called [Deno](https://deno.la
41
41
 
42
42
  Please note that if you encounter error `Too many open files (os error 24)`, then you should use the newer version of Deno (preferably built from source or canary).
43
43
 
44
- ### Bundling with official Firefox store signatures (Experimental)
44
+ ### Bundling with official Firefox store signatures (experimental)
45
45
 
46
46
  Prior to publication, extension stores provide digital signatures for extensions. These digital signatures certify the integrity of the archive (that extension bundle did not get corrupted or bit-rotted) and that extension store preformed very basic extension validation.
47
47
 
@@ -122,15 +122,42 @@ Automatically syncing the site fixes to every Dark Reader user was disabled beca
122
122
  However, this can be enabled using the following steps:
123
123
 
124
124
  - Click on the Dark Reader icon.
125
- - Click on the Dev tools button (in the bottom-right corner).
126
- - Click on the Preview new design button.
127
- - Enable the `Synchronize site fixes` setting under `Settings -> Manage Settings`.
125
+ - Click on the `Dev tools` button (in the bottom-right corner).
126
+ - Click on the `Preview new design` button.
127
+ - Enable the `Synchronize site fixes` setting under `Settings` -> `Manage settings`.
128
128
 
129
129
  To force a synchronization of the sites fixes (when the corresponding setting is enabled), perform the following steps:
130
130
 
131
131
  - Click on the Dark Reader icon.
132
- - Click on the Dev tools button (in the bottom-right corner).
133
- - Click on the Reset button. This will remove any custom site fixes you may have.
132
+ - Click on the `Dev tools` button (in the bottom-right corner).
133
+ - Click on the `Reset` button. This will remove any custom site fixes you may have.
134
+
135
+ ## Enable Dark Reader for restricted websites on Firefox
136
+
137
+ By default, Dark Reader does not work on some websites due to **security restrictions** enforced by Mozilla.
138
+
139
+ The following instructions will guide you on how to bypass those restrictions.
140
+
141
+ **Proceed with caution. This exposes you to a security risk if you do not know what you are doing.**
142
+
143
+ **These settings will apply to all extensions, and not just Dark Reader.**
144
+
145
+ Step 1: change Dark Reader's settings.
146
+
147
+ - Click on the Dark Reader icon.
148
+ - Click on the `Dev tools` button (in the bottom-right corner).
149
+ - Click on the `Preview new design button`.
150
+ - Enable the `Enable on restricted pages` setting under `Settings` -> `Site list`.
151
+
152
+ Step 2: change Firefox's settings.
153
+
154
+ - Type `about:config` in the address bar and press Enter.
155
+ A warning page may appear. Click `Accept the Risk and Continue` to go to the `about:config` page.
156
+ - Search for and set `extensions.webextensions.restrictedDomains` to an empty value.
157
+ - Create `extensions.webextensions.addons-restricted-domains@mozilla.com.disabled` with `boolean` as type and set its value to `true`.
158
+ - Set `extensions.quarantinedDomains.enabled` to `false`.
159
+ - Set `privacy.resistFingerprinting.block_mozAddonManager` with `boolean` as type and set its value to `true`.
160
+ - Restart Firefox.
134
161
 
135
162
  <h2 align="center">Contributors</h2>
136
163
  <br/>
package/darkreader.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Dark Reader v4.9.67
2
+ * Dark Reader v4.9.71
3
3
  * https://darkreader.org/
4
4
  */
5
5
 
@@ -7,10 +7,12 @@
7
7
  typeof exports === "object" && typeof module !== "undefined"
8
8
  ? factory(exports)
9
9
  : typeof define === "function" && define.amd
10
- ? define(["exports"], factory)
11
- : ((global =
12
- typeof globalThis !== "undefined" ? globalThis : global || self),
13
- factory((global.DarkReader = {})));
10
+ ? define(["exports"], factory)
11
+ : ((global =
12
+ typeof globalThis !== "undefined"
13
+ ? globalThis
14
+ : global || self),
15
+ factory((global.DarkReader = {})));
14
16
  })(this, function (exports) {
15
17
  "use strict";
16
18
 
@@ -117,9 +119,9 @@
117
119
  op[0] & 2
118
120
  ? y["return"]
119
121
  : op[0]
120
- ? y["throw"] ||
121
- ((t = y["return"]) && t.call(y), 0)
122
- : y.next) &&
122
+ ? y["throw"] ||
123
+ ((t = y["return"]) && t.call(y), 0)
124
+ : y.next) &&
123
125
  !(t = t.call(y, op[1])).done)
124
126
  )
125
127
  return t;
@@ -678,8 +680,8 @@
678
680
  fontFamily: isMacOS
679
681
  ? "Helvetica Neue"
680
682
  : isWindows
681
- ? "Segoe UI"
682
- : "Open Sans",
683
+ ? "Segoe UI"
684
+ : "Open Sans",
683
685
  textStroke: 0,
684
686
  engine: ThemeEngine.dynamicTheme,
685
687
  stylesheet: "",
@@ -695,14 +697,15 @@
695
697
  immediateModify: false
696
698
  };
697
699
  ({
700
+ schemeVersion: 0,
698
701
  enabled: true,
699
702
  fetchNews: true,
700
703
  theme: DEFAULT_THEME,
701
704
  presets: [],
702
705
  customThemes: [],
703
- siteList: [],
704
- siteListEnabled: [],
705
- applyToListedOnly: false,
706
+ enabledByDefault: true,
707
+ enabledFor: [],
708
+ disabledFor: [],
706
709
  changeBrowserTheme: false,
707
710
  syncSettings: true,
708
711
  syncSitesFixes: false,
@@ -1553,14 +1556,14 @@
1553
1556
  (h < 60
1554
1557
  ? [c, x, 0]
1555
1558
  : h < 120
1556
- ? [x, c, 0]
1557
- : h < 180
1558
- ? [0, c, x]
1559
- : h < 240
1560
- ? [0, x, c]
1561
- : h < 300
1562
- ? [x, 0, c]
1563
- : [c, 0, x]
1559
+ ? [x, c, 0]
1560
+ : h < 180
1561
+ ? [0, c, x]
1562
+ : h < 240
1563
+ ? [0, x, c]
1564
+ : h < 300
1565
+ ? [x, 0, c]
1566
+ : [c, 0, x]
1564
1567
  ).map(function (n) {
1565
1568
  return Math.round((n + m) * 255);
1566
1569
  }),
@@ -1591,8 +1594,8 @@
1591
1594
  (max === r
1592
1595
  ? ((g - b) / c) % 6
1593
1596
  : max === g
1594
- ? (b - r) / c + 2
1595
- : (r - g) / c + 4) * 60;
1597
+ ? (b - r) / c + 2
1598
+ : (r - g) / c + 4) * 60;
1596
1599
  if (h < 0) {
1597
1600
  h += 360;
1598
1601
  }
@@ -2658,15 +2661,20 @@
2658
2661
  case 5:
2659
2662
  image_1 = _a.sent();
2660
2663
  imageManager.addToQueue(function () {
2664
+ var analysis =
2665
+ analyzeImage(image_1);
2661
2666
  resolve(
2662
2667
  __assign(
2663
2668
  {
2664
2669
  src: url,
2665
- dataURL: dataURL,
2670
+ dataURL:
2671
+ analysis.isLarge
2672
+ ? ""
2673
+ : dataURL,
2666
2674
  width: image_1.naturalWidth,
2667
2675
  height: image_1.naturalHeight
2668
2676
  },
2669
- analyzeImage(image_1)
2677
+ analysis
2670
2678
  )
2671
2679
  );
2672
2680
  });
@@ -2727,12 +2735,12 @@
2727
2735
  });
2728
2736
  });
2729
2737
  }
2730
- var MAX_ANALIZE_PIXELS_COUNT = 32 * 32;
2738
+ var MAX_ANALYSIS_PIXELS_COUNT = 32 * 32;
2731
2739
  var canvas;
2732
2740
  var context;
2733
2741
  function createCanvas() {
2734
- var maxWidth = MAX_ANALIZE_PIXELS_COUNT;
2735
- var maxHeight = MAX_ANALIZE_PIXELS_COUNT;
2742
+ var maxWidth = MAX_ANALYSIS_PIXELS_COUNT;
2743
+ var maxHeight = MAX_ANALYSIS_PIXELS_COUNT;
2736
2744
  canvas = document.createElement("canvas");
2737
2745
  canvas.width = maxWidth;
2738
2746
  canvas.height = maxHeight;
@@ -2743,7 +2751,7 @@
2743
2751
  canvas = null;
2744
2752
  context = null;
2745
2753
  }
2746
- var MAX_IMAGE_SIZE = 5 * 1024 * 1024;
2754
+ var LARGE_IMAGE_PIXELS_COUNT = 512 * 512;
2747
2755
  function analyzeImage(image) {
2748
2756
  if (!canvas) {
2749
2757
  createCanvas();
@@ -2760,20 +2768,18 @@
2760
2768
  isTooLarge: false
2761
2769
  };
2762
2770
  }
2763
- var size = naturalWidth * naturalHeight * 4;
2764
- if (size > MAX_IMAGE_SIZE) {
2771
+ if (naturalWidth * naturalHeight > LARGE_IMAGE_PIXELS_COUNT) {
2765
2772
  return {
2766
2773
  isDark: false,
2767
2774
  isLight: false,
2768
2775
  isTransparent: false,
2769
- isLarge: false,
2770
- isTooLarge: true
2776
+ isLarge: true
2771
2777
  };
2772
2778
  }
2773
2779
  var naturalPixelsCount = naturalWidth * naturalHeight;
2774
2780
  var k = Math.min(
2775
2781
  1,
2776
- Math.sqrt(MAX_ANALIZE_PIXELS_COUNT / naturalPixelsCount)
2782
+ Math.sqrt(MAX_ANALYSIS_PIXELS_COUNT / naturalPixelsCount)
2777
2783
  );
2778
2784
  var width = Math.ceil(naturalWidth * k);
2779
2785
  var height = Math.ceil(naturalHeight * k);
@@ -2825,7 +2831,6 @@
2825
2831
  var DARK_IMAGE_THRESHOLD = 0.7;
2826
2832
  var LIGHT_IMAGE_THRESHOLD = 0.7;
2827
2833
  var TRANSPARENT_IMAGE_THRESHOLD = 0.1;
2828
- var LARGE_IMAGE_PIXELS_COUNT = 800 * 600;
2829
2834
  return {
2830
2835
  isDark: darkPixelsCount / opaquePixelsCount >= DARK_IMAGE_THRESHOLD,
2831
2836
  isLight:
@@ -2833,8 +2838,7 @@
2833
2838
  isTransparent:
2834
2839
  transparentPixelsCount / totalPixelsCount >=
2835
2840
  TRANSPARENT_IMAGE_THRESHOLD,
2836
- isLarge: naturalPixelsCount >= LARGE_IMAGE_PIXELS_COUNT,
2837
- isTooLarge: false
2841
+ isLarge: false
2838
2842
  };
2839
2843
  }
2840
2844
  function getFilteredImageDataURL(_a, theme) {
@@ -3268,6 +3272,11 @@
3268
3272
  return lines.join("\n");
3269
3273
  }
3270
3274
  function getModifiedFallbackStyle(filter, _a) {
3275
+ var strict = _a.strict;
3276
+ var factory = defaultFallbackFactory;
3277
+ return factory(filter, {strict: strict});
3278
+ }
3279
+ function defaultFallbackFactory(filter, _a) {
3271
3280
  var strict = _a.strict;
3272
3281
  var lines = [];
3273
3282
  var isMicrosoft = ["microsoft.com", "docs.microsoft.com"].includes(
@@ -3579,10 +3588,9 @@
3579
3588
  isLight = imageDetails.isLight,
3580
3589
  isTransparent = imageDetails.isTransparent,
3581
3590
  isLarge = imageDetails.isLarge,
3582
- isTooLarge = imageDetails.isTooLarge,
3583
3591
  width = imageDetails.width;
3584
3592
  var result;
3585
- if (isTooLarge) {
3593
+ if (isLarge) {
3586
3594
  logInfo(
3587
3595
  "Not modifying too large image ".concat(
3588
3596
  imageDetails.src
@@ -3593,7 +3601,6 @@
3593
3601
  isDark &&
3594
3602
  isTransparent &&
3595
3603
  filter.mode === 1 &&
3596
- !isLarge &&
3597
3604
  width > 2
3598
3605
  ) {
3599
3606
  logInfo("Inverting dark image ".concat(imageDetails.src));
@@ -3605,24 +3612,10 @@
3605
3612
  );
3606
3613
  result = 'url("'.concat(inverted, '")');
3607
3614
  } else if (isLight && !isTransparent && filter.mode === 1) {
3608
- if (isLarge) {
3609
- logInfo(
3610
- "Not modifying light non-transparent large image ".concat(
3611
- imageDetails.src
3612
- )
3613
- );
3614
- result = "none";
3615
- } else {
3616
- logInfo(
3617
- "Dimming light image ".concat(imageDetails.src)
3618
- );
3619
- var dimmed = getFilteredImageDataURL(
3620
- imageDetails,
3621
- filter
3622
- );
3623
- result = 'url("'.concat(dimmed, '")');
3624
- }
3625
- } else if (filter.mode === 0 && isLight && !isLarge) {
3615
+ logInfo("Dimming light image ".concat(imageDetails.src));
3616
+ var dimmed = getFilteredImageDataURL(imageDetails, filter);
3617
+ result = 'url("'.concat(dimmed, '")');
3618
+ } else if (filter.mode === 0 && isLight) {
3626
3619
  logInfo(
3627
3620
  "Applying filter to image ".concat(imageDetails.src)
3628
3621
  );
@@ -3844,14 +3837,14 @@
3844
3837
  VariablesStore.prototype.addRulesForMatching = function (rules) {
3845
3838
  this.rulesQueue.push(rules);
3846
3839
  };
3847
- VariablesStore.prototype.matchVariablesAndDependants = function () {
3840
+ VariablesStore.prototype.matchVariablesAndDependents = function () {
3848
3841
  var _this = this;
3849
3842
  this.changedTypeVars.clear();
3850
3843
  this.initialVarTypes = new Map(this.varTypes);
3851
3844
  this.collectRootVariables();
3852
3845
  this.collectVariablesAndVarDep(this.rulesQueue);
3853
3846
  this.rulesQueue.splice(0);
3854
- this.collectRootVarDependants();
3847
+ this.collectRootVarDependents();
3855
3848
  this.varRefs.forEach(function (refs, v) {
3856
3849
  refs.forEach(function (r) {
3857
3850
  if (_this.varTypes.has(v)) {
@@ -3889,7 +3882,7 @@
3889
3882
  );
3890
3883
  }) != null;
3891
3884
  if (hasColor) {
3892
- _this.itarateVarRefs(v, function (ref) {
3885
+ _this.iterateVarRefs(v, function (ref) {
3893
3886
  _this.resolveVariableType(ref, VAR_TYPE_BGCOLOR);
3894
3887
  });
3895
3888
  } else if (
@@ -4054,8 +4047,8 @@
4054
4047
  var modifier = isBg_1
4055
4048
  ? tryModifyBgColor
4056
4049
  : isText_1
4057
- ? tryModifyTextColor
4058
- : tryModifyBorderColor;
4050
+ ? tryModifyTextColor
4051
+ : tryModifyBorderColor;
4059
4052
  return modifier(value, theme);
4060
4053
  };
4061
4054
  }
@@ -4252,7 +4245,7 @@
4252
4245
  this.unknownColorVars.delete(varName);
4253
4246
  this.unknownBgVars.delete(varName);
4254
4247
  };
4255
- VariablesStore.prototype.collectRootVarDependants = function () {
4248
+ VariablesStore.prototype.collectRootVarDependents = function () {
4256
4249
  var _this = this;
4257
4250
  iterateCSSDeclarations(
4258
4251
  document.documentElement.style,
@@ -4311,7 +4304,7 @@
4311
4304
  )
4312
4305
  );
4313
4306
  }) != null;
4314
- _this.itarateVarRefs(v, function (ref) {
4307
+ _this.iterateVarRefs(v, function (ref) {
4315
4308
  if (isBgColor) {
4316
4309
  _this.resolveVariableType(ref, VAR_TYPE_BGCOLOR);
4317
4310
  } else {
@@ -4375,7 +4368,7 @@
4375
4368
  }
4376
4369
  return null;
4377
4370
  };
4378
- VariablesStore.prototype.itarateVarRefs = function (varName, iterator) {
4371
+ VariablesStore.prototype.iterateVarRefs = function (varName, iterator) {
4379
4372
  this.findVarRef(varName, function (ref) {
4380
4373
  iterator(ref);
4381
4374
  return false;
@@ -5280,8 +5273,19 @@
5280
5273
  " "
5281
5274
  );
5282
5275
  });
5276
+ var selectorText = selector;
5277
+ if (
5278
+ isChromium &&
5279
+ selector.startsWith(":is(") &&
5280
+ (selector.includes(":is()") ||
5281
+ selector.includes(":where()") ||
5282
+ (selector.includes(":where(") &&
5283
+ selector.includes(":-moz")))
5284
+ ) {
5285
+ selectorText = ".darkreader-unsupported-selector";
5286
+ }
5283
5287
  var ruleText = ""
5284
- .concat(selector, " { ")
5288
+ .concat(selectorText, " { ")
5285
5289
  .concat(cssRulesText, " }");
5286
5290
  target.insertRule(ruleText, index);
5287
5291
  }
@@ -5660,10 +5664,14 @@
5660
5664
  characterData: true
5661
5665
  };
5662
5666
  function containsCSSImport() {
5663
- return (
5664
- element instanceof HTMLStyleElement &&
5665
- element.textContent.trim().match(cssImportRegex)
5666
- );
5667
+ var _a;
5668
+ if (!(element instanceof HTMLStyleElement)) {
5669
+ return false;
5670
+ }
5671
+ var cssText = removeCSSComments(
5672
+ (_a = element.textContent) !== null && _a !== void 0 ? _a : ""
5673
+ ).trim();
5674
+ return cssText.match(cssImportRegex);
5667
5675
  }
5668
5676
  function hasImports(cssRules, checkCrossOrigin) {
5669
5677
  var result = false;
@@ -7366,7 +7374,7 @@
7366
7374
  .forEach(function (detail) {
7367
7375
  variablesStore.addRulesForMatching(detail.rules);
7368
7376
  });
7369
- variablesStore.matchVariablesAndDependants();
7377
+ variablesStore.matchVariablesAndDependents();
7370
7378
  variablesStore.setOnRootVariableChange(function () {
7371
7379
  var rootVarsStyle = createOrUpdateStyle("darkreader--root-vars");
7372
7380
  variablesStore.putRootVars(rootVarsStyle, filter);
@@ -7444,7 +7452,7 @@
7444
7452
  return;
7445
7453
  }
7446
7454
  variablesStore.addRulesForMatching(details.rules);
7447
- variablesStore.matchVariablesAndDependants();
7455
+ variablesStore.matchVariablesAndDependents();
7448
7456
  manager.render(filter, ignoredImageAnalysisSelectors);
7449
7457
  }
7450
7458
  var manager = manageStyle(element, {
@@ -7539,7 +7547,7 @@
7539
7547
  .forEach(function (detail) {
7540
7548
  variablesStore.addRulesForMatching(detail.rules);
7541
7549
  });
7542
- variablesStore.matchVariablesAndDependants();
7550
+ variablesStore.matchVariablesAndDependents();
7543
7551
  newManagers.forEach(function (manager) {
7544
7552
  return manager.render(
7545
7553
  filter,
@@ -7569,7 +7577,7 @@
7569
7577
  if (element === document.documentElement) {
7570
7578
  var styleAttr = element.getAttribute("style") || "";
7571
7579
  if (styleAttr.includes("--")) {
7572
- variablesStore.matchVariablesAndDependants();
7580
+ variablesStore.matchVariablesAndDependents();
7573
7581
  var rootVarsStyle = createOrUpdateStyle(
7574
7582
  "darkreader--root-vars"
7575
7583
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "darkreader",
3
- "version": "4.9.67",
3
+ "version": "4.9.71",
4
4
  "description": "Dark mode for every website",
5
5
  "scripts": {
6
6
  "api": "node --max-old-space-size=3072 tasks/cli.js build --api",
@@ -57,31 +57,31 @@
57
57
  "url": "https://opencollective.com/darkreader/donate"
58
58
  },
59
59
  "devDependencies": {
60
- "@rollup/plugin-node-resolve": "15.2.1",
61
- "@rollup/plugin-replace": "5.0.2",
62
- "@rollup/plugin-typescript": "11.1.4",
63
- "@rollup/pluginutils": "5.0.4",
64
- "@types/chrome": "0.0.246",
65
- "@types/eslint": "8.44.3",
66
- "@types/jasmine": "4.3.6",
67
- "@types/jest": "29.5.5",
68
- "@types/karma": "6.3.5",
69
- "@types/karma-coverage": "2.0.1",
70
- "@types/node": "20.7.2",
71
- "@types/offscreencanvas": "2019.7.1",
72
- "@types/ws": "8.5.6",
73
- "@typescript-eslint/eslint-plugin": "6.7.3",
74
- "@typescript-eslint/parser": "6.7.3",
60
+ "@rollup/plugin-node-resolve": "15.2.3",
61
+ "@rollup/plugin-replace": "5.0.5",
62
+ "@rollup/plugin-typescript": "11.1.5",
63
+ "@rollup/pluginutils": "5.1.0",
64
+ "@types/chrome": "0.0.253",
65
+ "@types/eslint": "8.44.8",
66
+ "@types/jasmine": "5.1.4",
67
+ "@types/jest": "29.5.10",
68
+ "@types/karma": "6.3.8",
69
+ "@types/karma-coverage": "2.0.3",
70
+ "@types/node": "20.10.2",
71
+ "@types/offscreencanvas": "2019.7.3",
72
+ "@types/ws": "8.5.10",
73
+ "@typescript-eslint/eslint-plugin": "6.13.1",
74
+ "@typescript-eslint/parser": "6.13.1",
75
75
  "chokidar": "3.5.3",
76
- "eslint": "8.50.0",
76
+ "eslint": "8.55.0",
77
77
  "eslint-plugin-compat": "4.2.0",
78
- "eslint-plugin-import": "2.28.1",
78
+ "eslint-plugin-import": "2.29.0",
79
79
  "eslint-plugin-local": "1.0.0",
80
80
  "get-stream": "7.0.1",
81
- "globby": "13.2.2",
81
+ "globby": "14.0.0",
82
82
  "jasmine-core": "5.1.1",
83
83
  "jest": "29.7.0",
84
- "jest-extended": "4.0.1",
84
+ "jest-extended": "4.0.2",
85
85
  "karma": "6.4.2",
86
86
  "karma-chrome-launcher": "3.2.0",
87
87
  "karma-coverage": "2.2.1",
@@ -92,13 +92,13 @@
92
92
  "karma-spec-reporter": "0.0.36",
93
93
  "less": "4.2.0",
94
94
  "malevic": "0.19.1",
95
- "prettier": "3.0.3",
96
- "puppeteer-core": "21.3.6",
97
- "rollup": "3.29.4",
98
- "rollup-plugin-istanbul": "4.0.0",
95
+ "prettier": "3.1.0",
96
+ "puppeteer-core": "21.5.2",
97
+ "rollup": "4.6.1",
98
+ "rollup-plugin-istanbul": "5.0.0",
99
99
  "ts-jest": "29.1.1",
100
100
  "tslib": "2.6.2",
101
- "typescript": "5.2.2",
101
+ "typescript": "5.3.2",
102
102
  "web-ext": "7.8.0",
103
103
  "ws": "8.14.2",
104
104
  "yazl": "2.5.1"