darkreader 4.9.94 → 4.9.96

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 (2) hide show
  1. package/darkreader.js +44 -4
  2. package/package.json +1 -1
package/darkreader.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Dark Reader v4.9.94
2
+ * Dark Reader v4.9.96
3
3
  * https://darkreader.org/
4
4
  */
5
5
 
@@ -170,9 +170,11 @@
170
170
  })();
171
171
 
172
172
  async function getOKResponse(url, mimeType, origin) {
173
+ const credentials =
174
+ origin && url.startsWith(`${origin}/`) ? undefined : "omit";
173
175
  const response = await fetch(url, {
174
176
  cache: "force-cache",
175
- credentials: "omit",
177
+ credentials,
176
178
  referrer: origin
177
179
  });
178
180
  if (
@@ -2734,6 +2736,7 @@
2734
2736
  function joinSelectors(...selectors) {
2735
2737
  return selectors.filter(Boolean).join(", ");
2736
2738
  }
2739
+ const hostsWithOddScrollbars = ["calendar.google.com"];
2737
2740
  function getModifiedUserAgentStyle(theme, isIFrame, styleSystemControls) {
2738
2741
  const lines = [];
2739
2742
  if (!isIFrame) {
@@ -2802,7 +2805,10 @@
2802
2805
  ` color: ${modifyForegroundColor({r: 0, g: 0, b: 0}, theme)} !important;`
2803
2806
  );
2804
2807
  lines.push("}");
2805
- if (theme.scrollbarColor) {
2808
+ if (
2809
+ theme.scrollbarColor &&
2810
+ !hostsWithOddScrollbars.includes(location.hostname)
2811
+ ) {
2806
2812
  lines.push(getModifiedScrollbarStyle(theme));
2807
2813
  }
2808
2814
  if (theme.selectionColor) {
@@ -5749,6 +5755,20 @@
5749
5755
  },
5750
5756
  {once: true, passive: true}
5751
5757
  );
5758
+ const unhandledShadowHosts = new Set();
5759
+ document.addEventListener("__darkreader__shadowDomAttaching", (e) => {
5760
+ const host = e.target;
5761
+ if (unhandledShadowHosts.size === 0) {
5762
+ queueMicrotask(() => {
5763
+ const hosts = [...unhandledShadowHosts].filter(
5764
+ (el) => el.shadowRoot
5765
+ );
5766
+ elementsDefinitionCallback?.(hosts);
5767
+ unhandledShadowHosts.clear();
5768
+ });
5769
+ }
5770
+ unhandledShadowHosts.add(host);
5771
+ });
5752
5772
  const resolvers = new Map();
5753
5773
  function handleIsDefined(e) {
5754
5774
  canOptimizeUsingProxy = true;
@@ -5812,6 +5832,7 @@
5812
5832
 
5813
5833
  const observers = [];
5814
5834
  let observedRoots;
5835
+ let handledShadowHosts;
5815
5836
  function watchForStylePositions(
5816
5837
  currentStyles,
5817
5838
  update,
@@ -5995,6 +6016,7 @@
5995
6016
  observe(document);
5996
6017
  deepObserve(document.documentElement);
5997
6018
  watchWhenCustomElementsDefined((hosts) => {
6019
+ hosts = hosts.filter((node) => !handledShadowHosts.has(node));
5998
6020
  const newStyles = [];
5999
6021
  hosts.forEach((host) =>
6000
6022
  push(newStyles, getManageableStyles(host.shadowRoot))
@@ -6009,6 +6031,7 @@
6009
6031
  deepObserve(shadowRoot);
6010
6032
  collectUndefinedElements(shadowRoot);
6011
6033
  });
6034
+ hosts.forEach((node) => handledShadowHosts.add(node));
6012
6035
  });
6013
6036
  document.addEventListener("__darkreader__isDefined", handleIsDefined);
6014
6037
  collectUndefinedElements(document);
@@ -6017,6 +6040,7 @@
6017
6040
  observers.forEach((o) => o.disconnect());
6018
6041
  observers.splice(0, observers.length);
6019
6042
  observedRoots = new WeakSet();
6043
+ handledShadowHosts = new WeakSet();
6020
6044
  }
6021
6045
  function stopWatchingForStylePositions() {
6022
6046
  resetObservers();
@@ -6327,7 +6351,10 @@
6327
6351
  function overrideProperty(cls, prop, overrides) {
6328
6352
  const proto = cls.prototype;
6329
6353
  const oldDescriptor = Object.getOwnPropertyDescriptor(proto, prop);
6330
- const newDescriptor = oldDescriptor ? {...oldDescriptor} : {};
6354
+ if (!oldDescriptor) {
6355
+ return;
6356
+ }
6357
+ const newDescriptor = {...oldDescriptor};
6331
6358
  Object.keys(overrides).forEach((key) => {
6332
6359
  const factory = overrides[key];
6333
6360
  newDescriptor[key] = factory(oldDescriptor[key]);
@@ -6350,6 +6377,10 @@
6350
6377
  const adoptedSheetChangeEvent = new CustomEvent(
6351
6378
  "__darkreader__adoptedStyleSheetChange"
6352
6379
  );
6380
+ const shadowDomAttachingEvent = new CustomEvent(
6381
+ "__darkreader__shadowDomAttaching",
6382
+ {bubbles: true}
6383
+ );
6353
6384
  const adoptedSheetOwners = new WeakMap();
6354
6385
  const adoptedDeclarationSheets = new WeakMap();
6355
6386
  function onAdoptedSheetChange(sheet) {
@@ -6443,6 +6474,15 @@
6443
6474
  reportSheetChange(this);
6444
6475
  }
6445
6476
  );
6477
+ override(
6478
+ Element,
6479
+ "attachShadow",
6480
+ (native) =>
6481
+ function (options) {
6482
+ this.dispatchEvent(shadowDomAttachingEvent);
6483
+ return native.call(this, options);
6484
+ }
6485
+ );
6446
6486
  const shouldWrapHTMLElement =
6447
6487
  location.hostname === "baidu.com" ||
6448
6488
  location.hostname.endsWith(".baidu.com");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "darkreader",
3
- "version": "4.9.94",
3
+ "version": "4.9.96",
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",