darkreader 4.9.51 → 4.9.52
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/darkreader.js +29 -5
- package/package.json +3 -2
package/darkreader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Dark Reader v4.9.
|
|
2
|
+
* Dark Reader v4.9.52
|
|
3
3
|
* https://darkreader.org/
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -928,7 +928,7 @@
|
|
|
928
928
|
var cssURLRegex = /url\((('.+?')|(".+?")|([^\)]*?))\)/g;
|
|
929
929
|
var cssImportRegex = /@import\s*(url\()?(('.+?')|(".+?")|([^\)]*?))\)? ?(screen)?;?/gi;
|
|
930
930
|
function getCSSURLValue(cssURL) {
|
|
931
|
-
return cssURL.trim().replace(/^url\((.*)\)$/, '$1').trim().replace(/^"(.*)"$/, '$1').replace(/^'(.*)'$/, '$1');
|
|
931
|
+
return cssURL.trim().replace(/^url\((.*)\)$/, '$1').trim().replace(/^"(.*)"$/, '$1').replace(/^'(.*)'$/, '$1').replace(/(?:\\(.))/g, '$1');
|
|
932
932
|
}
|
|
933
933
|
function getCSSBaseBath(url) {
|
|
934
934
|
var cssURL = parseURL(url);
|
|
@@ -2367,7 +2367,7 @@
|
|
|
2367
2367
|
function getModifiedFallbackStyle(filter, _a) {
|
|
2368
2368
|
var strict = _a.strict;
|
|
2369
2369
|
var lines = [];
|
|
2370
|
-
var isMicrosoft =
|
|
2370
|
+
var isMicrosoft = ['microsoft.com', 'docs.microsoft.com'].includes(location.hostname);
|
|
2371
2371
|
lines.push("html, body, ".concat(strict ? "body :not(iframe)".concat(isMicrosoft ? ':not(div[style^="position:absolute;top:0;left:-"]' : '') : 'body > :not(iframe)', " {"));
|
|
2372
2372
|
lines.push(" background-color: ".concat(modifyBackgroundColor({ r: 255, g: 255, b: 255 }, filter), " !important;"));
|
|
2373
2373
|
lines.push(" border-color: ".concat(modifyBorderColor({ r: 64, g: 64, b: 64 }, filter), " !important;"));
|
|
@@ -3912,6 +3912,19 @@
|
|
|
3912
3912
|
}
|
|
3913
3913
|
|
|
3914
3914
|
var STYLE_SELECTOR = 'style, link[rel*="stylesheet" i]:not([disabled])';
|
|
3915
|
+
function isFontsGoogleApiStyle(element) {
|
|
3916
|
+
if (!element.href) {
|
|
3917
|
+
return false;
|
|
3918
|
+
}
|
|
3919
|
+
try {
|
|
3920
|
+
var elementURL = new URL(element.href);
|
|
3921
|
+
return elementURL.hostname === 'fonts.googleapis.com';
|
|
3922
|
+
}
|
|
3923
|
+
catch (err) {
|
|
3924
|
+
logInfo("Couldn't construct ".concat(element.href, " as URL"));
|
|
3925
|
+
return false;
|
|
3926
|
+
}
|
|
3927
|
+
}
|
|
3915
3928
|
function shouldManageStyle(element) {
|
|
3916
3929
|
return (((element instanceof HTMLStyleElement) ||
|
|
3917
3930
|
(element instanceof SVGStyleElement) ||
|
|
@@ -3920,7 +3933,7 @@
|
|
|
3920
3933
|
element.rel.toLowerCase().includes('stylesheet') &&
|
|
3921
3934
|
!element.disabled &&
|
|
3922
3935
|
(isFirefox ? !element.href.startsWith('moz-extension://') : true) &&
|
|
3923
|
-
!element
|
|
3936
|
+
!isFontsGoogleApiStyle(element))) &&
|
|
3924
3937
|
!element.classList.contains('darkreader') &&
|
|
3925
3938
|
element.media.toLowerCase() !== 'print' &&
|
|
3926
3939
|
!element.classList.contains('stylus'));
|
|
@@ -4786,7 +4799,18 @@
|
|
|
4786
4799
|
var removeRuleDescriptor = Object.getOwnPropertyDescriptor(CSSStyleSheet.prototype, 'removeRule');
|
|
4787
4800
|
var documentStyleSheetsDescriptor = enableStyleSheetsProxy ?
|
|
4788
4801
|
Object.getOwnPropertyDescriptor(Document.prototype, 'styleSheets') : null;
|
|
4789
|
-
var shouldWrapHTMLElement =
|
|
4802
|
+
var shouldWrapHTMLElement = [
|
|
4803
|
+
'baidu.com',
|
|
4804
|
+
'baike.baidu.com',
|
|
4805
|
+
'ditu.baidu.com',
|
|
4806
|
+
'map.baidu.com',
|
|
4807
|
+
'maps.baidu.com',
|
|
4808
|
+
'haokan.baidu.com',
|
|
4809
|
+
'pan.baidu.com',
|
|
4810
|
+
'passport.baidu.com',
|
|
4811
|
+
'tieba.baidu.com',
|
|
4812
|
+
'www.baidu.com'
|
|
4813
|
+
].includes(location.hostname);
|
|
4790
4814
|
var getElementsByTagNameDescriptor = shouldWrapHTMLElement ?
|
|
4791
4815
|
Object.getOwnPropertyDescriptor(Element.prototype, 'getElementsByTagName') : null;
|
|
4792
4816
|
var cleanUp = function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "darkreader",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.52",
|
|
4
4
|
"description": "Dark mode for every website",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"api": "node tasks/build.js --api",
|
|
@@ -26,7 +26,8 @@
|
|
|
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",
|
|
29
|
-
"test:update-snapshots": "npm run test -- --updateSnapshot && npm run test:project -- --updateSnapshot"
|
|
29
|
+
"test:update-snapshots": "npm run test -- --updateSnapshot && npm run test:project -- --updateSnapshot",
|
|
30
|
+
"translate-line": "node ./tasks/translate.js --line"
|
|
30
31
|
},
|
|
31
32
|
"main": "darkreader.js",
|
|
32
33
|
"repository": {
|