darkreader 4.9.87 → 4.9.92

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 +52 -22
  2. package/darkreader.js +47 -88
  3. package/package.json +22 -16
package/README.md CHANGED
@@ -50,9 +50,9 @@ Dark Reader repository contains these digital signatures and you can add them to
50
50
  npm run build -- --firefox --version=4.9.63
51
51
  ```
52
52
 
53
- Please note that only Firefox Add-ons store signatures are present in the repositiry right now. Also, due to NodeJS and TypeScript version compatibility, one might have to first check out the old revision (commit), then build the extension files, then check out the recent commit and create the bundle (by running only `signature` and `zip` steps).
53
+ Please note that only Firefox Add-ons store signatures are present in the repository right now. Also, due to NodeJS and TypeScript version compatibility, one might have to first check out the old revision (commit), then build the extension files, then check out the recent commit and create the bundle (by running only `signature` and `zip` steps).
54
54
 
55
- ## Using Dark Reader for a website
55
+ ## Using Dark Reader on a website
56
56
 
57
57
  You can use Dark Reader to enable dark mode on your website!
58
58
 
@@ -117,46 +117,76 @@ Be aware that Dark Reader will add the `chrome` object onto the `window` object.
117
117
 
118
118
  ## Site fixes
119
119
 
120
- 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.
120
+ Automatically syncing the site fixes for every Dark Reader user was disabled because the GitHub team does not allow using GitHub as a content delivery network (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 the new changes.
121
121
 
122
- However, this can be enabled using the following steps:
122
+ However, this can be manually enabled with the following steps:
123
123
 
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`.
124
+ 1. Click on the Dark Reader extension icon.
125
+ 2. Click on the `Dev tools` button (in the bottom-right corner).
126
+ 3. Go to `Advanced` and click on the `Preview new design` button.
127
+ 4. Close the developer tools window and click on the Dark Reader extension icon again.
128
+ 5. Go to `Settings` -> `Advanced` and enable the `Synchronize sites fixes` setting.
128
129
 
129
130
  To force a synchronization of the sites fixes (when the corresponding setting is enabled), perform the following steps:
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
+ 1. Click on the Dark Reader extension icon.
133
+ 2. Go to `Settings` -> `Advanced` -> `Dev tools`.
134
+ 3. For each "Editor" section, click on `Reset changes`, confirm with `OK`, and then click on `Apply`. Afterwards, close the developer tools window and reload the desired page(s).
134
135
 
135
- ## Enable Dark Reader for restricted websites on Firefox
136
+ ## Enable Dark Reader on restricted pages on Mozilla Firefox
136
137
 
137
138
  By default, Dark Reader does not work on some websites due to **security restrictions** enforced by Mozilla.
138
139
 
139
- The following instructions will guide you on how to bypass those restrictions.
140
+ The following instructions will guide you on how to disable those restrictions.
140
141
 
141
142
  **Proceed with caution. This exposes you to a security risk if you do not know what you are doing.**
142
143
 
144
+ **Be sure that you do not have any suspicious or malicious-looking extension installed before proceeding.**
145
+
143
146
  **These settings will apply to all extensions, and not just Dark Reader.**
144
147
 
145
148
  Step 1: change Dark Reader's settings.
146
149
 
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` -> `Advanced`.
150
+ 1. Click on the Dark Reader extension icon.
151
+ 2. Click on the `Dev tools` button (in the bottom-right corner).
152
+ 3. Go to `Advanced` and click on the `Preview new design` button.
153
+ 4. Close the developer tools window and click on the Dark Reader extension icon again.
154
+ 5. Go to `Settings` -> `Advanced` and enable the `Enable on restricted pages` setting.
151
155
 
152
156
  Step 2: change Firefox's settings.
153
157
 
154
158
  - Type `about:config` in the address bar and press Enter.
155
- A warning page may appear. Click `Accept the Risk and Continue` to proceed.
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 `privacy.resistFingerprinting.block_mozAddonManager` to `true`.
159
- - Restart Firefox.
159
+ - A warning page may appear. Click `Accept the Risk and Continue` to proceed.
160
+ - Search for and set `extensions.webextensions.restrictedDomains` to an empty value (if the preference does not exist, create with it `String` as the type).
161
+ - Set `privacy.resistFingerprinting.block_mozAddonManager` to `true` (if the preference does not exist, create with it `Boolean` as the type).
162
+
163
+ After changing the necessary settings for both Dark Reader and Firefox, reload the desired page(s).
164
+
165
+ **If you had previously changed any of the following preferences, please reset them to their default values as they are only related to security and are not necessary for Dark Reader to work on restricted websites.**
166
+ To reset them, click on the reset (or delete icon, if present) icon at the most-right corner of the preference line in `about:config`.
167
+ - `extensions.webextensions.addons-restricted-domains@mozilla.com.disabled`
168
+ - `extensions.quarantinedDomains.enabled`
169
+ - `extensions.quarantinedDomains.list`
170
+
171
+ ### Clarification about quarantined domains ("Run on sites with restrictions" option)
172
+ <details><summary>Quarantined domains and Dark Reader — an explanation</summary>
173
+
174
+ The option "Run on sites with restrictions", present in some extensions, is only related to quarantined domains, and is not needed for Dark Reader to work on restricted websites.
175
+
176
+ More information about quarantined domains: [Why are some add-ons not allowed on sites restricted by Mozilla?](https://support.mozilla.org/en-US/kb/quarantined-domains)
177
+
178
+ For Dark Reader, the option is not shown because Dark Reader is a [Recommended](https://support.mozilla.org/en-US/kb/recommended-extensions-program) extension by Mozilla.
179
+
180
+ Due to it being a Recommended extension, it means it meets the "highest standards of security, functionality, and user experience". The quarantined domains are only related to security, and because Dark Reader is considered secure by Mozilla, that option is not shown, meaning **it will always run even on quarantined domains**.
181
+
182
+ [From Firefox's source code:](https://searchfox.org/mozilla-central/source/toolkit/components/extensions/Extension.sys.mjs#2937-2938)
183
+
184
+ ```
185
+ // Privileged extensions and any extensions with a recommendation state are
186
+ // exempt from the quarantined domains.
187
+ ```
188
+
189
+ </details>
160
190
 
161
191
  <h2 align="center">Contributors</h2>
162
192
  <br/>
package/darkreader.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Dark Reader v4.9.87
2
+ * Dark Reader v4.9.92
3
3
  * https://darkreader.org/
4
4
  */
5
5
 
@@ -355,20 +355,35 @@
355
355
  darkSchemeTextColor: DEFAULT_COLORS.darkScheme.text,
356
356
  lightSchemeBackgroundColor: DEFAULT_COLORS.lightScheme.background,
357
357
  lightSchemeTextColor: DEFAULT_COLORS.lightScheme.text,
358
- scrollbarColor: isMacOS ? "" : "auto",
358
+ scrollbarColor: "",
359
359
  selectionColor: "auto",
360
360
  styleSystemControls: !isCSSColorSchemePropSupported,
361
361
  lightColorScheme: "Default",
362
362
  darkColorScheme: "Default",
363
363
  immediateModify: false
364
364
  };
365
+ const filterModeSites = [
366
+ "*.officeapps.live.com",
367
+ "*.sharepoint.com",
368
+ "docs.google.com",
369
+ "onedrive.live.com"
370
+ ];
365
371
  ({
366
372
  schemeVersion: 0,
367
373
  enabled: true,
368
374
  fetchNews: true,
369
375
  theme: DEFAULT_THEME,
370
376
  presets: [],
371
- customThemes: [],
377
+ customThemes: filterModeSites.map((url) => {
378
+ const engine = isChromium
379
+ ? ThemeEngine.svgFilter
380
+ : ThemeEngine.cssFilter;
381
+ return {
382
+ url: [url],
383
+ theme: {...DEFAULT_THEME, engine},
384
+ builtIn: true
385
+ };
386
+ }),
372
387
  enabledByDefault: true,
373
388
  enabledFor: [],
374
389
  disabledFor: [],
@@ -389,10 +404,11 @@
389
404
  longitude: null
390
405
  },
391
406
  previewNewDesign: false,
407
+ previewNewestDesign: false,
392
408
  enableForPDF: true,
393
409
  enableForProtectedPages: false,
394
410
  enableContextMenus: false,
395
- detectDarkTheme: false
411
+ detectDarkTheme: true
396
412
  });
397
413
 
398
414
  function isArrayLike(items) {
@@ -1935,12 +1951,6 @@
1935
1951
  fnCache.set(id, color);
1936
1952
  return color;
1937
1953
  }
1938
- function noopHSL(hsl) {
1939
- return hsl;
1940
- }
1941
- function modifyColor(rgb, theme) {
1942
- return modifyColorWithCache(rgb, theme, noopHSL);
1943
- }
1944
1954
  function modifyLightSchemeColor(rgb, theme) {
1945
1955
  const poleBg = getBgPole(theme);
1946
1956
  const poleFg = getFgPole(theme);
@@ -2738,7 +2748,7 @@
2738
2748
  lines.push(` color-scheme: dark !important;`);
2739
2749
  lines.push("}");
2740
2750
  lines.push("iframe {");
2741
- lines.push(` color-scheme: initial;`);
2751
+ lines.push(` color-scheme: dark !important;`);
2742
2752
  lines.push("}");
2743
2753
  }
2744
2754
  const bgSelectors = joinSelectors(
@@ -2846,70 +2856,26 @@
2846
2856
  return lines.join("\n");
2847
2857
  }
2848
2858
  function getModifiedScrollbarStyle(theme) {
2849
- const lines = [];
2850
2859
  let colorTrack;
2851
- let colorIcons;
2852
2860
  let colorThumb;
2853
- let colorThumbHover;
2854
- let colorThumbActive;
2855
- let colorCorner;
2856
2861
  if (theme.scrollbarColor === "auto") {
2857
2862
  colorTrack = modifyBackgroundColor({r: 241, g: 241, b: 241}, theme);
2858
- colorIcons = modifyForegroundColor({r: 96, g: 96, b: 96}, theme);
2859
2863
  colorThumb = modifyBackgroundColor({r: 176, g: 176, b: 176}, theme);
2860
- colorThumbHover = modifyBackgroundColor(
2861
- {r: 144, g: 144, b: 144},
2862
- theme
2863
- );
2864
- colorThumbActive = modifyBackgroundColor(
2865
- {r: 96, g: 96, b: 96},
2866
- theme
2867
- );
2868
- colorCorner = modifyBackgroundColor(
2869
- {r: 255, g: 255, b: 255},
2870
- theme
2871
- );
2872
2864
  } else {
2873
2865
  const rgb = parseColorWithCache(theme.scrollbarColor);
2874
2866
  const hsl = rgbToHSL(rgb);
2875
- const isLight = hsl.l > 0.5;
2876
- const lighten = (lighter) => ({
2877
- ...hsl,
2878
- l: clamp(hsl.l + lighter, 0, 1)
2879
- });
2880
2867
  const darken = (darker) => ({
2881
2868
  ...hsl,
2882
2869
  l: clamp(hsl.l - darker, 0, 1)
2883
2870
  });
2884
2871
  colorTrack = hslToString(darken(0.4));
2885
- colorIcons = hslToString(isLight ? darken(0.4) : lighten(0.4));
2886
2872
  colorThumb = hslToString(hsl);
2887
- colorThumbHover = hslToString(lighten(0.1));
2888
- colorThumbActive = hslToString(lighten(0.2));
2889
- colorCorner = hslToString(darken(0.5));
2890
2873
  }
2891
- lines.push("::-webkit-scrollbar {");
2892
- lines.push(` background-color: ${colorTrack};`);
2893
- lines.push(` color: ${colorIcons};`);
2894
- lines.push("}");
2895
- lines.push("::-webkit-scrollbar-thumb {");
2896
- lines.push(` background-color: ${colorThumb};`);
2897
- lines.push("}");
2898
- lines.push("::-webkit-scrollbar-thumb:hover {");
2899
- lines.push(` background-color: ${colorThumbHover};`);
2900
- lines.push("}");
2901
- lines.push("::-webkit-scrollbar-thumb:active {");
2902
- lines.push(` background-color: ${colorThumbActive};`);
2903
- lines.push("}");
2904
- lines.push("::-webkit-scrollbar-corner {");
2905
- lines.push(` background-color: ${colorCorner};`);
2906
- lines.push("}");
2907
- if (isFirefox) {
2908
- lines.push("* {");
2909
- lines.push(` scrollbar-color: ${colorThumb} ${colorTrack};`);
2910
- lines.push("}");
2911
- }
2912
- return lines.join("\n");
2874
+ return [
2875
+ `* {`,
2876
+ ` scrollbar-color: ${colorThumb} ${colorTrack};`,
2877
+ `}`
2878
+ ].join("\n");
2913
2879
  }
2914
2880
  function getModifiedFallbackStyle(theme, {strict}) {
2915
2881
  const factory = defaultFallbackFactory;
@@ -2996,6 +2962,9 @@
2996
2962
  isCancelled
2997
2963
  ) {
2998
2964
  try {
2965
+ if (shouldIgnoreImage(rule.selectorText, ignoreImageSelectors)) {
2966
+ return value;
2967
+ }
2999
2968
  const gradients = parseGradient(value);
3000
2969
  const urls = getMatches(cssURLRegex, value);
3001
2970
  if (urls.length === 0 && gradients.length === 0) {
@@ -3052,11 +3021,6 @@
3052
3021
  };
3053
3022
  };
3054
3023
  const getURLModifier = (urlValue) => {
3055
- if (
3056
- shouldIgnoreImage(rule.selectorText, ignoreImageSelectors)
3057
- ) {
3058
- return null;
3059
- }
3060
3024
  let url = getCSSURLValue(urlValue);
3061
3025
  const isURLEmpty = url.length === 0;
3062
3026
  const {parentStyleSheet} = rule;
@@ -4489,8 +4453,8 @@
4489
4453
  }
4490
4454
  const isSVGElement = element instanceof SVGElement;
4491
4455
  const svg = isSVGElement
4492
- ? element.ownerSVGElement ??
4493
- (element instanceof SVGSVGElement ? element : null)
4456
+ ? (element.ownerSVGElement ??
4457
+ (element instanceof SVGSVGElement ? element : null))
4494
4458
  : null;
4495
4459
  if (isSVGElement && theme.mode === 1 && svg) {
4496
4460
  if (svgInversionCache.has(svg)) {
@@ -6889,32 +6853,23 @@
6889
6853
  document.head.appendChild(overrideStyle);
6890
6854
  setupNodePositionWatcher(overrideStyle, "override");
6891
6855
  const variableStyle = createOrUpdateStyle("darkreader--variables");
6892
- const selectionColors = getSelectionColor(theme);
6893
- const {
6894
- darkSchemeBackgroundColor,
6895
- darkSchemeTextColor,
6896
- lightSchemeBackgroundColor,
6897
- lightSchemeTextColor,
6898
- mode
6899
- } = theme;
6900
- let schemeBackgroundColor =
6901
- mode === 0 ? lightSchemeBackgroundColor : darkSchemeBackgroundColor;
6902
- let schemeTextColor =
6903
- mode === 0 ? lightSchemeTextColor : darkSchemeTextColor;
6904
- schemeBackgroundColor = modifyBackgroundColor(
6905
- parseColorWithCache(schemeBackgroundColor),
6856
+ const selectionColors = theme?.selectionColor
6857
+ ? getSelectionColor(theme)
6858
+ : null;
6859
+ const neutralBackgroundColor = modifyBackgroundColor(
6860
+ parseColorWithCache("#ffffff"),
6906
6861
  theme
6907
6862
  );
6908
- schemeTextColor = modifyForegroundColor(
6909
- parseColorWithCache(schemeTextColor),
6863
+ const neutralTextColor = modifyForegroundColor(
6864
+ parseColorWithCache("#000000"),
6910
6865
  theme
6911
6866
  );
6912
6867
  variableStyle.textContent = [
6913
6868
  `:root {`,
6914
- ` --darkreader-neutral-background: ${schemeBackgroundColor};`,
6915
- ` --darkreader-neutral-text: ${schemeTextColor};`,
6916
- ` --darkreader-selection-background: ${selectionColors.backgroundColorSelection};`,
6917
- ` --darkreader-selection-text: ${selectionColors.foregroundColorSelection};`,
6869
+ ` --darkreader-neutral-background: ${neutralBackgroundColor};`,
6870
+ ` --darkreader-neutral-text: ${neutralTextColor};`,
6871
+ ` --darkreader-selection-background: ${selectionColors?.backgroundColorSelection ?? "initial"};`,
6872
+ ` --darkreader-selection-text: ${selectionColors?.foregroundColorSelection ?? "initial"};`,
6918
6873
  `}`
6919
6874
  ].join("\n");
6920
6875
  document.head.insertBefore(variableStyle, inlineStyle.nextSibling);
@@ -6999,7 +6954,11 @@
6999
6954
  return $cssText.replace(/\${(.+?)}/g, (_, $color) => {
7000
6955
  const color = parseColorWithCache($color);
7001
6956
  if (color) {
7002
- return modifyColor(color, theme);
6957
+ const lightness = getSRGBLightness(color.r, color.g, color.b);
6958
+ if (lightness > 0.5) {
6959
+ return modifyBackgroundColor(color, theme);
6960
+ }
6961
+ return modifyForegroundColor(color, theme);
7003
6962
  }
7004
6963
  return $color;
7005
6964
  });
package/package.json CHANGED
@@ -1,18 +1,22 @@
1
1
  {
2
2
  "name": "darkreader",
3
- "version": "4.9.87",
3
+ "version": "4.9.92",
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",
7
7
  "build": "node --max-old-space-size=3072 tasks/cli.js build --release",
8
8
  "build:all": "node --max-old-space-size=3072 tasks/cli.js build --debug --release --api",
9
+ "build:firefox": "node --max-old-space-size=3072 tasks/cli.js build --release --firefox",
10
+ "build:plus": "node --max-old-space-size=3072 tasks/cli.js build --plus --release",
9
11
  "code-style": "npm run lint",
10
12
  "debug": "node --max-old-space-size=3072 tasks/cli.js build --debug",
11
13
  "debug:watch": "node --max-old-space-size=3072 tasks/cli.js build --debug --watch --chrome --firefox",
12
14
  "debug:watch:mv3": "node --max-old-space-size=3072 tasks/cli.js build --debug --watch --chrome-mv3",
15
+ "debug:watch:plus": "node --max-old-space-size=3072 tasks/cli.js build --debug --watch --plus --chrome",
13
16
  "dependencies:upgrade": "node tasks/dependencies.js",
14
17
  "lint": "eslint --ignore-pattern '!.eslint-plugin-local.js' -- 'src/**/*.ts' 'src/**/*.tsx' 'tasks/**/*.js' 'tests/[!coverage]**/*.js' 'tests/**/*.ts' '.eslintrc.js' 'index.d.ts'",
15
18
  "lint:bundle": "(node ./tasks/check-exists.js ./build/debug/chrome || node tasks/build.js --debug --api --chrome) && eslint -- 'build/debug/chrome/**/*.js' 'darkreader.js'",
19
+ "plus-link": "cd src && ln -s ../../darkreader-plus plus",
16
20
  "prepublishOnly": "npm test && npm run api",
17
21
  "release": "npm test && npm run lint && node tasks/cli.js build --release",
18
22
  "test": "npm run test:unit",
@@ -55,30 +59,33 @@
55
59
  "type": "opencollective",
56
60
  "url": "https://opencollective.com/darkreader/donate"
57
61
  },
62
+ "dependencies": {
63
+ "malevic": "0.20.2"
64
+ },
58
65
  "devDependencies": {
59
66
  "@rollup/plugin-node-resolve": "15.2.3",
60
67
  "@rollup/plugin-replace": "5.0.7",
61
68
  "@rollup/plugin-typescript": "11.1.6",
62
- "@types/chrome": "0.0.268",
69
+ "@types/chrome": "0.0.269",
63
70
  "@types/eslint": "8.56.10",
64
71
  "@types/jasmine": "5.1.4",
65
72
  "@types/jest": "29.5.12",
66
73
  "@types/karma": "6.3.8",
67
74
  "@types/karma-coverage": "2.0.3",
68
- "@types/node": "20.14.9",
69
- "@types/ws": "8.5.10",
70
- "@typescript-eslint/eslint-plugin": "7.14.1",
71
- "@typescript-eslint/parser": "7.14.1",
75
+ "@types/node": "22.2.0",
76
+ "@types/ws": "8.5.12",
77
+ "@typescript-eslint/eslint-plugin": "7.16.0",
78
+ "@typescript-eslint/parser": "7.16.0",
72
79
  "chokidar": "3.6.0",
73
80
  "eslint": "8.57.0",
74
81
  "eslint-plugin-compat": "5.0.0",
75
82
  "eslint-plugin-import": "2.29.1",
76
83
  "eslint-plugin-local": "4.2.2",
77
- "globby": "14.0.1",
78
- "jasmine-core": "5.1.2",
84
+ "globby": "14.0.2",
85
+ "jasmine-core": "5.2.0",
79
86
  "jest": "29.7.0",
80
87
  "jest-extended": "4.0.2",
81
- "karma": "6.4.3",
88
+ "karma": "6.4.4",
82
89
  "karma-chrome-launcher": "3.2.0",
83
90
  "karma-coverage": "2.2.1",
84
91
  "karma-firefox-launcher": "2.1.3",
@@ -87,16 +94,15 @@
87
94
  "karma-safari-launcher": "1.0.0",
88
95
  "karma-spec-reporter": "0.0.36",
89
96
  "less": "4.2.0",
90
- "malevic": "0.20.1",
91
- "prettier": "3.3.2",
92
- "puppeteer-core": "22.12.1",
93
- "rollup": "4.18.0",
97
+ "prettier": "3.3.3",
98
+ "puppeteer-core": "23.0.2",
99
+ "rollup": "4.20.0",
94
100
  "rollup-plugin-istanbul": "5.0.0",
95
- "ts-jest": "29.1.5",
101
+ "ts-jest": "29.2.4",
96
102
  "tslib": "2.6.3",
97
- "typescript": "5.5.2",
103
+ "typescript": "5.5.4",
98
104
  "web-ext": "8.2.0",
99
- "ws": "8.17.1",
105
+ "ws": "8.18.0",
100
106
  "yazl": "2.5.1"
101
107
  }
102
108
  }