darkreader 4.9.85 → 4.9.87
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 +1 -1
- package/darkreader.js +104 -29
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
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
|
-
<p align="center"><a rel="noreferrer noopener" href="https://
|
|
4
|
+
<p align="center"><a rel="noreferrer noopener" href="https://chromewebstore.google.com/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
|
|
|
6
6
|
<h2 align="center">Dark Reader</h2>
|
|
7
7
|
<br/>
|
package/darkreader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Dark Reader v4.9.
|
|
2
|
+
* Dark Reader v4.9.87
|
|
3
3
|
* https://darkreader.org/
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -2217,6 +2217,9 @@
|
|
|
2217
2217
|
const resolvers$1 = new Map();
|
|
2218
2218
|
const rejectors = new Map();
|
|
2219
2219
|
async function bgFetch(request) {
|
|
2220
|
+
if (window.DarkReader?.Plugins?.fetch) {
|
|
2221
|
+
return window.DarkReader.Plugins.fetch(request);
|
|
2222
|
+
}
|
|
2220
2223
|
return new Promise((resolve, reject) => {
|
|
2221
2224
|
const id = generateUID();
|
|
2222
2225
|
resolvers$1.set(id, resolve);
|
|
@@ -3325,7 +3328,7 @@
|
|
|
3325
3328
|
class VariablesStore {
|
|
3326
3329
|
constructor() {
|
|
3327
3330
|
this.varTypes = new Map();
|
|
3328
|
-
this.rulesQueue =
|
|
3331
|
+
this.rulesQueue = new Set();
|
|
3329
3332
|
this.inlineStyleQueue = [];
|
|
3330
3333
|
this.definedVars = new Set();
|
|
3331
3334
|
this.varRefs = new Map();
|
|
@@ -3339,7 +3342,7 @@
|
|
|
3339
3342
|
}
|
|
3340
3343
|
clear() {
|
|
3341
3344
|
this.varTypes.clear();
|
|
3342
|
-
this.rulesQueue.
|
|
3345
|
+
this.rulesQueue.clear();
|
|
3343
3346
|
this.inlineStyleQueue.splice(0);
|
|
3344
3347
|
this.definedVars.clear();
|
|
3345
3348
|
this.varRefs.clear();
|
|
@@ -3358,14 +3361,14 @@
|
|
|
3358
3361
|
);
|
|
3359
3362
|
}
|
|
3360
3363
|
addRulesForMatching(rules) {
|
|
3361
|
-
this.rulesQueue.
|
|
3364
|
+
this.rulesQueue.add(rules);
|
|
3362
3365
|
}
|
|
3363
3366
|
addInlineStyleForMatching(style) {
|
|
3364
3367
|
this.inlineStyleQueue.push(style);
|
|
3365
3368
|
}
|
|
3366
3369
|
matchVariablesAndDependents() {
|
|
3367
3370
|
if (
|
|
3368
|
-
this.rulesQueue.
|
|
3371
|
+
this.rulesQueue.size === 0 &&
|
|
3369
3372
|
this.inlineStyleQueue.length === 0
|
|
3370
3373
|
) {
|
|
3371
3374
|
return;
|
|
@@ -3643,7 +3646,7 @@
|
|
|
3643
3646
|
const modified = modify();
|
|
3644
3647
|
if (unknownVars.size > 0) {
|
|
3645
3648
|
const isFallbackResolved = modified.match(
|
|
3646
|
-
/^var\(.*?, var\(--darkreader-bg--.*\)\)$/
|
|
3649
|
+
/^var\(.*?, (var\(--darkreader-bg--.*\))|(#[0-9A-Fa-f]+)|([a-z]+)|(rgba?\(.+\))|(hsla?\(.+\))\)$/
|
|
3647
3650
|
);
|
|
3648
3651
|
if (isFallbackResolved) {
|
|
3649
3652
|
return modified;
|
|
@@ -3707,7 +3710,7 @@
|
|
|
3707
3710
|
this.inlineStyleQueue.forEach((style) => {
|
|
3708
3711
|
this.collectVarsFromCSSDeclarations(style);
|
|
3709
3712
|
});
|
|
3710
|
-
this.rulesQueue.
|
|
3713
|
+
this.rulesQueue.clear();
|
|
3711
3714
|
this.inlineStyleQueue.splice(0);
|
|
3712
3715
|
}
|
|
3713
3716
|
collectVarsFromCSSDeclarations(style) {
|
|
@@ -3722,7 +3725,7 @@
|
|
|
3722
3725
|
}
|
|
3723
3726
|
shouldProcessRootVariables() {
|
|
3724
3727
|
return (
|
|
3725
|
-
this.rulesQueue.
|
|
3728
|
+
this.rulesQueue.size > 0 &&
|
|
3726
3729
|
document.documentElement.getAttribute("style")?.includes("--")
|
|
3727
3730
|
);
|
|
3728
3731
|
}
|
|
@@ -6099,7 +6102,6 @@
|
|
|
6099
6102
|
const sheet = newSheets[i];
|
|
6100
6103
|
if (overrides.has(sheet)) {
|
|
6101
6104
|
newSheets.splice(i, 1);
|
|
6102
|
-
overrides.delete(sheet);
|
|
6103
6105
|
}
|
|
6104
6106
|
}
|
|
6105
6107
|
if (node.adoptedStyleSheets.length !== newSheets.length) {
|
|
@@ -6345,7 +6347,19 @@
|
|
|
6345
6347
|
document.addEventListener(type, listener, options);
|
|
6346
6348
|
cleaners.push(() => document.removeEventListener(type, listener));
|
|
6347
6349
|
}
|
|
6350
|
+
function disableConflictingPlugins() {
|
|
6351
|
+
const disableWPDarkMode = () => {
|
|
6352
|
+
if (window?.WPDarkMode?.deactivate) {
|
|
6353
|
+
window.WPDarkMode.deactivate();
|
|
6354
|
+
}
|
|
6355
|
+
};
|
|
6356
|
+
disableWPDarkMode();
|
|
6357
|
+
}
|
|
6348
6358
|
documentEventListener("__darkreader__cleanUp", cleanUp);
|
|
6359
|
+
documentEventListener(
|
|
6360
|
+
"__darkreader__disableConflictingPlugins",
|
|
6361
|
+
disableConflictingPlugins
|
|
6362
|
+
);
|
|
6349
6363
|
function overrideProperty(cls, prop, overrides) {
|
|
6350
6364
|
const proto = cls.prototype;
|
|
6351
6365
|
const oldDescriptor = Object.getOwnPropertyDescriptor(proto, prop);
|
|
@@ -7324,10 +7338,10 @@
|
|
|
7324
7338
|
metaElement.content = INSTANCE_ID;
|
|
7325
7339
|
document.head.appendChild(metaElement);
|
|
7326
7340
|
}
|
|
7341
|
+
function isDRLocked() {
|
|
7342
|
+
return document.querySelector('meta[name="darkreader-lock"]') != null;
|
|
7343
|
+
}
|
|
7327
7344
|
function isAnotherDarkReaderInstanceActive() {
|
|
7328
|
-
if (document.querySelector('meta[name="darkreader-lock"]')) {
|
|
7329
|
-
return true;
|
|
7330
|
-
}
|
|
7331
7345
|
const meta = document.querySelector('meta[name="darkreader"]');
|
|
7332
7346
|
if (meta) {
|
|
7333
7347
|
if (meta.content !== INSTANCE_ID) {
|
|
@@ -7339,6 +7353,56 @@
|
|
|
7339
7353
|
addMetaListener();
|
|
7340
7354
|
return false;
|
|
7341
7355
|
}
|
|
7356
|
+
let interceptorAttempts = 2;
|
|
7357
|
+
function interceptOldScript({success, failure}) {
|
|
7358
|
+
if (--interceptorAttempts <= 0) {
|
|
7359
|
+
failure();
|
|
7360
|
+
return;
|
|
7361
|
+
}
|
|
7362
|
+
const oldMeta = document.head.querySelector('meta[name="darkreader"]');
|
|
7363
|
+
if (!oldMeta || oldMeta.content === INSTANCE_ID) {
|
|
7364
|
+
return;
|
|
7365
|
+
}
|
|
7366
|
+
const lock = document.createElement("meta");
|
|
7367
|
+
lock.name = "darkreader-lock";
|
|
7368
|
+
document.head.append(lock);
|
|
7369
|
+
queueMicrotask(() => {
|
|
7370
|
+
lock.remove();
|
|
7371
|
+
success();
|
|
7372
|
+
});
|
|
7373
|
+
}
|
|
7374
|
+
function disableConflictingPlugins() {
|
|
7375
|
+
if (document.documentElement.hasAttribute("data-wp-dark-mode-preset")) {
|
|
7376
|
+
const disableWPDarkMode = () => {
|
|
7377
|
+
document.dispatchEvent(
|
|
7378
|
+
new CustomEvent("__darkreader__disableConflictingPlugins")
|
|
7379
|
+
);
|
|
7380
|
+
document.documentElement.classList.remove(
|
|
7381
|
+
"wp-dark-mode-active"
|
|
7382
|
+
);
|
|
7383
|
+
document.documentElement.removeAttribute(
|
|
7384
|
+
"data-wp-dark-mode-active"
|
|
7385
|
+
);
|
|
7386
|
+
};
|
|
7387
|
+
disableWPDarkMode();
|
|
7388
|
+
const observer = new MutationObserver(() => {
|
|
7389
|
+
if (
|
|
7390
|
+
document.documentElement.classList.contains(
|
|
7391
|
+
"wp-dark-mode-active"
|
|
7392
|
+
) ||
|
|
7393
|
+
document.documentElement.hasAttribute(
|
|
7394
|
+
"data-wp-dark-mode-active"
|
|
7395
|
+
)
|
|
7396
|
+
) {
|
|
7397
|
+
disableWPDarkMode();
|
|
7398
|
+
}
|
|
7399
|
+
});
|
|
7400
|
+
observer.observe(document.documentElement, {
|
|
7401
|
+
attributes: true,
|
|
7402
|
+
attributeFilter: ["class", "data-wp-dark-mode-active"]
|
|
7403
|
+
});
|
|
7404
|
+
}
|
|
7405
|
+
}
|
|
7342
7406
|
function createOrUpdateDynamicThemeInternal(
|
|
7343
7407
|
themeConfig,
|
|
7344
7408
|
dynamicThemeFixes,
|
|
@@ -7365,20 +7429,35 @@
|
|
|
7365
7429
|
});
|
|
7366
7430
|
}
|
|
7367
7431
|
isIFrame$1 = iframe;
|
|
7368
|
-
|
|
7369
|
-
|
|
7432
|
+
const ready = () => {
|
|
7433
|
+
const success = () => {
|
|
7434
|
+
disableConflictingPlugins();
|
|
7435
|
+
document.documentElement.setAttribute(
|
|
7436
|
+
"data-darkreader-mode",
|
|
7437
|
+
"dynamic"
|
|
7438
|
+
);
|
|
7439
|
+
document.documentElement.setAttribute(
|
|
7440
|
+
"data-darkreader-scheme",
|
|
7441
|
+
theme.mode ? "dark" : "dimmed"
|
|
7442
|
+
);
|
|
7443
|
+
createThemeAndWatchForUpdates();
|
|
7444
|
+
};
|
|
7445
|
+
const failure = () => {
|
|
7370
7446
|
removeDynamicTheme();
|
|
7371
|
-
|
|
7447
|
+
};
|
|
7448
|
+
if (isDRLocked()) {
|
|
7449
|
+
removeNode(document.querySelector(".darkreader--fallback"));
|
|
7450
|
+
} else if (isAnotherDarkReaderInstanceActive()) {
|
|
7451
|
+
interceptOldScript({
|
|
7452
|
+
success,
|
|
7453
|
+
failure
|
|
7454
|
+
});
|
|
7455
|
+
} else {
|
|
7456
|
+
success();
|
|
7372
7457
|
}
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
);
|
|
7377
|
-
document.documentElement.setAttribute(
|
|
7378
|
-
"data-darkreader-scheme",
|
|
7379
|
-
theme.mode ? "dark" : "dimmed"
|
|
7380
|
-
);
|
|
7381
|
-
createThemeAndWatchForUpdates();
|
|
7458
|
+
};
|
|
7459
|
+
if (document.head) {
|
|
7460
|
+
ready();
|
|
7382
7461
|
} else {
|
|
7383
7462
|
if (!isFirefox) {
|
|
7384
7463
|
const fallbackStyle = createOrUpdateStyle(
|
|
@@ -7392,11 +7471,7 @@
|
|
|
7392
7471
|
const headObserver = new MutationObserver(() => {
|
|
7393
7472
|
if (document.head) {
|
|
7394
7473
|
headObserver.disconnect();
|
|
7395
|
-
|
|
7396
|
-
removeDynamicTheme();
|
|
7397
|
-
return;
|
|
7398
|
-
}
|
|
7399
|
-
createThemeAndWatchForUpdates();
|
|
7474
|
+
ready();
|
|
7400
7475
|
}
|
|
7401
7476
|
});
|
|
7402
7477
|
headObserver.observe(document, {childList: true, subtree: true});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "darkreader",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.87",
|
|
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,21 +57,21 @@
|
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@rollup/plugin-node-resolve": "15.2.3",
|
|
60
|
-
"@rollup/plugin-replace": "5.0.
|
|
60
|
+
"@rollup/plugin-replace": "5.0.7",
|
|
61
61
|
"@rollup/plugin-typescript": "11.1.6",
|
|
62
|
-
"@types/chrome": "0.0.
|
|
62
|
+
"@types/chrome": "0.0.268",
|
|
63
63
|
"@types/eslint": "8.56.10",
|
|
64
64
|
"@types/jasmine": "5.1.4",
|
|
65
65
|
"@types/jest": "29.5.12",
|
|
66
66
|
"@types/karma": "6.3.8",
|
|
67
67
|
"@types/karma-coverage": "2.0.3",
|
|
68
|
-
"@types/node": "20.
|
|
68
|
+
"@types/node": "20.14.9",
|
|
69
69
|
"@types/ws": "8.5.10",
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "7.
|
|
71
|
-
"@typescript-eslint/parser": "7.
|
|
70
|
+
"@typescript-eslint/eslint-plugin": "7.14.1",
|
|
71
|
+
"@typescript-eslint/parser": "7.14.1",
|
|
72
72
|
"chokidar": "3.6.0",
|
|
73
73
|
"eslint": "8.57.0",
|
|
74
|
-
"eslint-plugin-compat": "
|
|
74
|
+
"eslint-plugin-compat": "5.0.0",
|
|
75
75
|
"eslint-plugin-import": "2.29.1",
|
|
76
76
|
"eslint-plugin-local": "4.2.2",
|
|
77
77
|
"globby": "14.0.1",
|
|
@@ -88,15 +88,15 @@
|
|
|
88
88
|
"karma-spec-reporter": "0.0.36",
|
|
89
89
|
"less": "4.2.0",
|
|
90
90
|
"malevic": "0.20.1",
|
|
91
|
-
"prettier": "3.2
|
|
92
|
-
"puppeteer-core": "22.
|
|
93
|
-
"rollup": "4.
|
|
91
|
+
"prettier": "3.3.2",
|
|
92
|
+
"puppeteer-core": "22.12.1",
|
|
93
|
+
"rollup": "4.18.0",
|
|
94
94
|
"rollup-plugin-istanbul": "5.0.0",
|
|
95
|
-
"ts-jest": "29.1.
|
|
96
|
-
"tslib": "2.6.
|
|
97
|
-
"typescript": "5.
|
|
98
|
-
"web-ext": "
|
|
99
|
-
"ws": "8.17.
|
|
95
|
+
"ts-jest": "29.1.5",
|
|
96
|
+
"tslib": "2.6.3",
|
|
97
|
+
"typescript": "5.5.2",
|
|
98
|
+
"web-ext": "8.2.0",
|
|
99
|
+
"ws": "8.17.1",
|
|
100
100
|
"yazl": "2.5.1"
|
|
101
101
|
}
|
|
102
102
|
}
|